Skip to main content
Commonmark migration
Source Link

#Whitespace (with vii5ard compiler), 18 17 bytes

Whitespace (with vii5ard compiler), 18 17 bytes

#Whitespace (with TIO compiler), 48 bytes

Whitespace (with TIO compiler), 48 bytes

#Whitespace (with vii5ard compiler), 18 17 bytes

#Whitespace (with TIO compiler), 48 bytes

Whitespace (with vii5ard compiler), 18 17 bytes

Whitespace (with TIO compiler), 48 bytes

Try it online. You'll have to copy-paste the code yourself (note that SE converts the tabs to a bunch of spaces!) in order to run the code at the online Whitespace-compiler vii5ard. When clicking run, it will ask for an input (i.e. -285283.5), and after clicking enter it will continue and output -283.

Whitespace can only use I/O as integers or single characters, so in this case it would read, the input is read as integer and ignore anyall other trailingsubsequent characters are ignored. I.e. -283.5 or -283abc5 would both be input (and thus output) as -283.

Try it online. You'll have to copy-paste the code yourself (note that SE converts the tabs to a bunch of spaces!) in order to run the code at the online Whitespace-compiler vii5ard. When clicking run, it will ask for an input (i.e. -285.5), and after clicking enter it will continue and output -283.

Whitespace can only use I/O as integers or single characters, so in this case it would read the input as integer and ignore any other trailing characters. I.e. -283.5 or -283abc5 would both be input (and thus output) as -283.

Try it online. You'll have to copy-paste the code yourself (note that SE converts the tabs to a bunch of spaces!) in order to run the code at the online Whitespace-compiler vii5ard. When clicking run, it will ask for an input (i.e. -283.5), and after clicking enter it will continue and output -283.

Whitespace can only use I/O as integers or single characters, so in this case, the input is read as integer and all other subsequent characters are ignored. I.e. -283.5 or -283abc5 would both be input (and thus output) as -283.

added 705 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Whitespace (with vii5ard compiler), 1818 17 bytes

[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][T  N
S T _Print_as_integer]

Unfortunately this above doesn't work on TIO. It will give a no parse error for two reasons (all Whitespace compilers are slightly different).. So, instead we'll read one character at a time, and stop (with an error) as soon as we've encountered the . or there is no more input (i.e. 50/-50):

  1. It will give a no parse error when we try to read an input as integer, which isn't an a valid integer. So, instead we'll read one character at a time, and stop (with an error) as soon as we've encountered the . or there is no more input (i.e. 50/-50).
  2. In the vii5ard compiler it's also possible to push 0 with just SSN, whereas on TIO it requires an additional S or T: SSSN/SSTN. The first S is Enable Stack Manipulation; the second S is Push what follows as integer; the third S/T is positive/negative respectively; and any S/T after that (followed by an N) is the number we want to push in binary, where S=0 and T=1. For integer 0 this binary part doesn't matter, since it's 0 by default. But on TIO we'd still have to specify the positive/negative, and with most other Whitespace compilers like vii5ard not.

#Whitespace (with vii5ard compiler), 18 bytes

[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][T  N
S T _Print_as_integer]

Unfortunately this doesn't work on TIO. It will give a no parse error (all Whitespace compilers are slightly different).. So, instead we'll read one character at a time, and stop (with an error) as soon as we've encountered the . or there is no more input (i.e. 50/-50):

#Whitespace (with vii5ard compiler), 18 17 bytes

[S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][T  N
S T _Print_as_integer]

Unfortunately this above doesn't work on TIO for two reasons (all Whitespace compilers are slightly different..):

  1. It will give a no parse error when we try to read an input as integer, which isn't an a valid integer. So, instead we'll read one character at a time, and stop (with an error) as soon as we've encountered the . or there is no more input (i.e. 50/-50).
  2. In the vii5ard compiler it's also possible to push 0 with just SSN, whereas on TIO it requires an additional S or T: SSSN/SSTN. The first S is Enable Stack Manipulation; the second S is Push what follows as integer; the third S/T is positive/negative respectively; and any S/T after that (followed by an N) is the number we want to push in binary, where S=0 and T=1. For integer 0 this binary part doesn't matter, since it's 0 by default. But on TIO we'd still have to specify the positive/negative, and with most other Whitespace compilers like vii5ard not.
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading