TEST - Life, the Universe, and Everything

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.

Example

Input:
1
2
88
42
99

Output:
1
2
88

Information

In case of any problems with your code, you can take a look in the forum, you'll find the answer, only for this problem, in various languages.


Added by:mima
Date:2004-05-01
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Douglas Adams, The Hitchhiker's Guide to the Galaxy

hide comments
2025-06-22 08:23:29
Procedure Find_Answer is
Number : Integer;
Begin
Loop

Get(Number);


Exit When Number = 42;


Put_Line(Integer'Image(Number));
End Loop;
End Find_Answer;
2025-06-16 19:01:19
<snip>
is this wrong i submitted and every time it is wrong
[Simes]: don't post code here, use the forum.

Last edit: 2025-06-16 20:30:36
2025-06-10 08:21:48
nice
2025-05-28 07:56:14
read the statement 10 times in row specially last line then u will get solution i hope ur problem statement reading is good or better enough for the same.
2025-05-18 06:08:20
Good
2025-03-31 11:13:13
<snip>
what's wrong in this program showing wrong answer can anyone suggest?
[Simes]: Don't post code here, use the forum. But this line "printf("Enter Number You wanted: \n");" Your output should match the expected output exactly. Nothing more nothing less.

Last edit: 2025-04-01 12:10:25
2025-03-15 19:07:00
run a infinite loop and break it once you get 42
2025-02-08 15:22:43
Just Need to Add To Scanner In the Loop Unit the Input Match To 42 If it Match To We Need to Break it
2025-01-28 17:24:46
how many inputs to take :/ ?
2024-12-04 20:15:18

Procedure Find_Answer is
Number : Integer;
Begin
Loop

Get(Number);


Exit When Number = 42;


Put_Line(Integer'Image(Number));
End Loop;
End Find_Answer;
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.