Life, the Universe, and Everything

PHOTO EMBED

Sun May 01 2022 17:54:03 GMT+0000 (Coordinated Universal Time)

Saved by @GreenMark #javascript

// Life, the Universe, and Everything
// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //process.stdout.write("Hi, " + input + ".\n");       // Writing output to STDOUT
var data= input.toString().split("\n");
var arr = data.map(item => Number(item));

const flag = true;
var i = 0;
while (flag)  {
    
    if (arr[i]==42) {
        break;
    } else console.log(arr[i]);
    i++; 
}   

}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail



// Write your code here
// Sample code to perform I/O:
//Enter your code here
content_copyCOPY

Problem Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/life-the-universe-and-everything/