TI-BASIC (TI-84+/SE), 36 bytes
startTmr→rand:1/(1<randInt(1,6:"I survived!
There is no input, as the challenge specifies.
Output is I survived!
if successful, a DIVIDE BY 0
error otherwise.
The DIVIDE BY 0
error screen looks like the following:
ERR:DIVIDE BY 0
1:Quit
2:Goto
Selecting either option (and returning to home screen if 2
is selected) shows Error
after the program call.
Examples:
prgmCDGFE
Error
prgmCDGFE
I survived!
prgmCDGFE
I survived!
prgmCDGFE
Error
Explanation:
startTmr→rand:1/(1<randInt(1,6:"I survived! ;full program
startTmr→rand ;store the current time into "rand"
; this is necessary because "rand" is 0 after
; factory reset, the default state for TI-BASIC
; submissions
randInt(1,6 ;get a random integer in [1,6]
1< ;is greater than 1? 1 if true, 0 if false
1/( ;divide 1 by the result
; throws "DIVIDE BY 0" error if result was
; false
"I survived! ;leave this string in "Ans"
;implicitly print "Ans"
Notes:
TI-BASIC is a tokenized language. Byte count does not equal character count.
Lowercase letters are two bytes each.
- Lowercase letters can be enabled using this assembly program.
startTmr
is a command only on the TI-84+ and TI-84+ SE calculators. Said calculators have different operating systems.
randrange(5)
olarak uygulanabilirrandrange(MAX_INT)%6
.