172
\$\begingroup\$

A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

  • Gets a number (either 0 or 1) from STDIN.

  • If that number is 0, print out 0 and terminate.

  • If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

  • take input from STDIN or an acceptable alternative
    • If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program
  • must output to STDOUT or an acceptable alternative
    • If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.
  • when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory
  • the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

  • if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 320px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62732; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 12012; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>

\$\endgroup\$
18
  • 3
    \$\begingroup\$ Assuming any behaviour is fine for all invalid inputs? \$\endgroup\$
    – Cruncher
    Nov 3, 2015 at 17:33
  • 3
    \$\begingroup\$ @Cruncher Yes, the only inputs you should expect to get are 0 and 1. \$\endgroup\$ Nov 3, 2015 at 17:38
  • 5
    \$\begingroup\$ Catalog is borked. \$\endgroup\$ Nov 6, 2015 at 15:18
  • 2
    \$\begingroup\$ Catalog appears to consider Bf and bf to be different languages. \$\endgroup\$ Nov 10, 2015 at 1:13
  • 1
    \$\begingroup\$ Is one allowed to print an infinite number of 1s? That is, not print out 1s forever, but print out an infinite list of 1s all at once? This would be theoretically demonstrated, but the language has no notion of printing more than once. It just generates an output. So is it okay if it runs indefinitely, but would print infinite 1s given infinite time (to finish executing)? \$\endgroup\$
    – AviFS
    Apr 26, 2020 at 1:42

494 Answers 494

1
10 11
12
13 14
17
1
\$\begingroup\$

Gaia, 3 bytes

:p↺

Try it online!

Explanation

  ↺  While...
:    Duplicating the top of stack leaves a true value on top:
 p   Print the top of the stack

Input is taken implicitly in Gaia. Every iteration leaves the stack empty, but if there is no input left when it attempts to grab some, it simply takes the most recently given input again.

\$\endgroup\$
1
\$\begingroup\$

Keg, 12 8 7 4 bytes

{:|④

Try it online!

Explanation

# Implicit input
{:|  # While the duplicated item is nonzero:
   ④ # Output the item without popping
     # After that, Output the item remaining on the stack and stop the program
\$\endgroup\$
2
  • \$\begingroup\$ This can now be 8 bytes due to implicit input \$\endgroup\$
    – EdgyNerd
    Aug 10, 2019 at 9:30
  • \$\begingroup\$ 4 bytes Try it online! \$\endgroup\$
    – lyxal
    Dec 15, 2019 at 21:11
1
\$\begingroup\$

Python 3, 35 bytes

a=input()
while a:a=int(a);print(a)

This is the best I can do, don't know if it's the optimal solution though.

Explanation

In Python 3, input() stores the input as a string, so even if the user types 0, it will be stored as '0', which is truthy. This allows me to make a kind of do-while loop, which will always run at least once since '0' and '1' are both truthy. However, I then convert a to an integer ('0' becomes 0 and '1' becomes 1). Now, if the user typed 0, it will not run again since the while loop is now while 0 and 0 is falsy. However, if the user typed 1, it will run forever since the while loop is now while 1 and 1 is truthy.

\$\endgroup\$
2
  • \$\begingroup\$ 34 bytes \$\endgroup\$
    – user85052
    Dec 26, 2019 at 15:17
  • \$\begingroup\$ @a'_' oh nice, didn't know that was a thing in Python 3.8 \$\endgroup\$ Dec 27, 2019 at 1:22
1
\$\begingroup\$

JavaScript, 39 32 Bytes

x=+prompt();do{alert(x)}while(x)

x=+prompt() gets input from user, and transforms it from a string to a number

do{alert(x)}while(x) is a post test loop, so it always alerts X, then executes again if x not = 0

\$\endgroup\$
0
1
\$\begingroup\$

Comp, 6 or 8 bytes

The first golfing language (sort of :) ) from 2020!

;{^&}&

That could be a mistake. An alternative program is:

;{^£}£

Explanation

;      Take an input from the console as an integer
 {^£}  While that's nonzero, duplicate & print
     £ If that's zero, directly print
\$\endgroup\$
1
\$\begingroup\$

Python3, 40Bytes

a=input()
while int(a):print(a)
print(a)
  • If input is 0 it will be printed once.
  • If input is 1 it will be printed forever.
\$\endgroup\$
1
\$\begingroup\$

RAKIAC machine language, 6 bytes (34 real for asm)

00000100
00000011
00110100
00100001
00000001
00000010

Representing the assembly:

in
s: out
jez v
jmp s
v: hlt
end

Tried out one of my things for fun (definitely not made for golf).

\$\endgroup\$
1
\$\begingroup\$

Turing Machine Code, 19 29 19 bytes

0 0 * * h
0 * 1 r 0

Try it online!

Saved 10 bytes thanks to @Laikoni

\$\endgroup\$
1
  • \$\begingroup\$ This is doable with just two rules: 0 0 * * h and 0 * 1 r 0. \$\endgroup\$
    – Laikoni
    Feb 26, 2020 at 12:54
1
\$\begingroup\$

Arn, 4 bytes

“l○|

Explained

Unpacked: &&[{1

Takes advantage of the fact that Arn's interpreter is written in Javascript. This means the && and || operator can be used as control flow.

  _     % Variable initialized to STDIN. Implied
&&      % Boolean AND
  [     % Sequence
    {   % Block; used to calculate future entries in a sequence
      1 % Literal one
    }   % End block. Implied
  ]     % End sequence. Implied
\$\endgroup\$
4
  • \$\begingroup\$ One more answer and I'm going to learn Arn. \$\endgroup\$ Aug 21, 2020 at 13:59
  • \$\begingroup\$ ;) haha, like your esolang 1+ a lot too \$\endgroup\$ Aug 21, 2020 at 14:00
  • \$\begingroup\$ (Although, common mistake is I created 1+ - Parcly Taxel created it.) \$\endgroup\$ Aug 21, 2020 at 14:01
  • \$\begingroup\$ Oh wow, you use it so much I assumed it was yours haha. Apologies to the creator then. \$\endgroup\$ Aug 21, 2020 at 14:03
1
\$\begingroup\$

sed 4.2.2, 8 bytes

Uses the -n flag to suppress printing without an explicit p command.

:
p
/1/b

Try it online!

Commented:

#create an unnamed label
:
#print pattern space
p
#If pattern space contains 1, branch to beginning
/1/b
\$\endgroup\$
1
\$\begingroup\$

Poetic, 137 bytes

TRUTHFUL MACHINE
A:I=true,O=false
B:get a number or get a value
C:if falsy,a zero
D:if truthy,a one
D.a:repeat it if value=I
E:suspend it

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python - 40 bytes

a=int(input())
while a:
  print(a)
print(a)

This is simple but effective. A fun thing about this is that while we could put a condition that a==1 in, this is more fun because it reuses a, and a will be 1 causing the loop to run forever (works with any a != 0)

\$\endgroup\$
1
\$\begingroup\$

Starry, 16 bytes

, +'. '` +. +' `

Try it online!

Pretty simple, it reads the input onto the stack, if it's zero, it prints it, and if it's non-zero, prints it forever.

\$\endgroup\$
1
\$\begingroup\$

Ocaml, 46 bytes

let a=read_int()in while print_int a;a=1 do 0

urk the functions name and the control flow takes a lot of chars. The trick since there is no do-while is to put the print directly in the condition (sometime ago when I did that in a course lab, the teach called me a "connoisseur of monstrosities" (approx tl))

The 0 in the end causes a warning, so you need to disable werror.

\$\endgroup\$
1
\$\begingroup\$

sed, 13 bytes

:l;s/1/1/p;tl

Try it online!

\$\endgroup\$
1
\$\begingroup\$

yuno, 4 bytes

ᴀ_¹¿

Try it online!

Or, using the flag to disable implicit output:

yuno d, 3 bytes

ᴀ_¿

Try it online!

Explanation

The W flag caps output at 10,000 characters just so it doesn't freeze your browser window for too long.

ᴀ_¹¿    Main Link
   ¿    While
  ¹     The element is truthy
ᴀ_      Output it
        <Implicitly output the value>

ᴀ_¿     Main Link
  ¿     While
ᴀ_      Output the element, then assess if it's truthy
        <d flag disables implicit output>
\$\endgroup\$
1
\$\begingroup\$

Dis, 49 bytes.

}{*|*^__________!||_^_____________*{___^___****!*

Usage

  • Input from STDIN, as an ASCII number character.
  • Output to STDOUT, in ASCII.

With comments

(
0: }{*|*^
'*'+1: ****!* 

'*'+1: * changed to 48-42or49-42 by |:
   12 10t - 11 20t is 01 20t is 15
   12 11t - 11 20t is 01 21t is 16 

'*'+2: * for * command 

'*'+1: 15or16 for ^ 

15+1: ! reaches when zero
16+1: ||^ reaches when one 

obtw '*'+3: * and '*'+4: * are for | to have the register A have 49 again 

'*'+5: ! for ^ 

After that '*'+4: '1' BUT whatever 

'!'+1: *{___^ repeatedly output one 

* 42 ! 33 

) 

(
0123456789 0123456789 0123456789 0123456789
)
}{*|*^____ ______!||_ ^_________ ____*{___^
(
0123456789 0123456789 0123456789 0123456789
)
___****!*

Try with 0!

Try with 1!

\$\endgroup\$
1
  • \$\begingroup\$ I think I can golf more. \$\endgroup\$
    – user100411
    Jun 23, 2021 at 10:03
1
\$\begingroup\$

Mascarpone, 18.125 bytes

['1.:!]v*['0.]v*1[:!]v*'1<,>!

Try It Online!

I'm surprised to see so few Mascarpone answers even on the big questions like this. It's a shame, it's such a beautiful language even if it is a bit of a tarpit.

\$\endgroup\$
1
\$\begingroup\$

n/t/roff, 27 bytes.

.de a
\\$1
.if \\$1 .a 1
..

Defines a macro a.

Usage

.a 0
.a 1

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ No wait I need to modify to accept from STDIN, not from macro argument. \$\endgroup\$
    – user100411
    Aug 19, 2021 at 2:52
  • \$\begingroup\$ How the hell can I do so? \$\endgroup\$
    – user100411
    Aug 19, 2021 at 12:13
1
\$\begingroup\$

Arduino, 133 129 117 bytes

Thanks to @tail spark rabbit ear for shaving off 12 bytes!

#define S Serial
int x=0;void setup(){S.begin(300);}void loop(){S.available()&&S.print(x=S.read()-48);x&&S.print(1);}

Arduino is basically C++, but with this bit implied:

int main() {
  setup();
  while (true) {
    loop();
  }
  return 0; // to make the compiler happy, I guess
}

The setup() and loop() functions must be implemented.
Explanation:

#define S Serial /* macro to make referencing the Serial monitor shorter */
int x = 0; // must either be global, or declared `static` inside `loop()`

void setup() {
  S.begin(300);
  // The argument to Serial.begin() is the baud rate
  // 300 is the slowest supported option, but therefore takes the fewest bytes
}

void loop() {
  S.available() &&
    // Serial.available() returns truthy when there are unread bytes from the serial input
    // Using && as a shortcut for an if statement (like minified JS)

    S.print(
      x = S.read() - 48
    );
    // Serial.read() dequeues the next byte from the input
    // 48 is ASCII '0'
    // Serial.print() converts 0 back to "0"; Serial.write() wouldn't

  x &&
    S.print(1);
}

As loop() is called indefinitely, it's impossible to terminate, so inputting "0" settles into a loop that prints nothing until something else is input.

Original:

int x=0;void setup(){Serial.begin(300);}void loop(){if(Serial.available()){x=Serial.read()-48;Serial.print(x);}if(x)Serial.print(1);}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice first answer! Would it be possible for you to provide either a link to the language, or a link to a testing environment, so that others can run your code? \$\endgroup\$ Aug 13, 2021 at 2:27
  • 1
    \$\begingroup\$ @Dudecoinheringaahing Unfortunately no. In order to run Arduino code you have to deploy it to a physical Arduino board. \$\endgroup\$
    – Bbrk24
    Aug 13, 2021 at 2:30
  • 1
    \$\begingroup\$ 117 bytes: does this work well? \$\endgroup\$
    – user100411
    Aug 16, 2021 at 3:55
1
\$\begingroup\$

Braingolf, 5 bytes

[!_];

Try it online!

Explanation

[!_];   Implicit input
[..]    Do-while, run once and loop while top of stack is >0
 !_     Print top of stack without popping
    ;   Prevent implicit output
\$\endgroup\$
1
\$\begingroup\$

Pure Bash, 32 + 1 = 33 bytes

The 1-byte penalty is for filename specification; the following program must be saved as x.

((x))||read x
echo $x
((x))&&. x

Try it online!

Tracing how it works

  • The variable x is not initialized.
  • ((x)) evaluates to ((0)): command is failure.
  • So read x is done.
  • Then echo $x.
  • Final line is for branching.
    • If x is zero, the program ends.
    • If x is one, . x is done.
      • It loads the file x: the program itself.
      • First command evaluates to ((1)) so no more reading.
      • Then rest two lines are executed and it loops forever.
\$\endgroup\$
1
\$\begingroup\$

BASH

read a; [ $a -eq 0 ] && echo 0 || ( [ $a -eq 1 ] && while true; do echo 1; done ) 
\$\endgroup\$
4
  • \$\begingroup\$ Testing now. may need tweaked \$\endgroup\$
    – Nate T
    Nov 16, 2021 at 6:06
  • 2
    \$\begingroup\$ Welcome to Code Golf, and nice first answer! Please edit your answer to include the language (I'm guessing Bash?) and byte count \$\endgroup\$ Nov 16, 2021 at 6:10
  • \$\begingroup\$ @cairdcoinheringaahing Thanks. Forgot the $s as well. Added. How do we get count? Is it count as in ascii? If its in the link, I'm reading now. Thanks again. EDIT: Wait a char is 2 bytes on X64, no? \$\endgroup\$
    – Nate T
    Nov 16, 2021 at 6:21
  • 2
    \$\begingroup\$ I believe most Bash answers simply count the number of ascii bytes \$\endgroup\$ Nov 16, 2021 at 6:24
1
\$\begingroup\$

APOL, 34 16 bytes

My original version was written back when I first made APOL and used none of the newer convenience instructions.

¿(⧣ w(T p(1)) 0)

Explanation

¿(          Returning if
  ⧣         Integer input (used as condition, 0 evaluates to false)
  w(T       While true (true condition)
    p(1)    Print 1
  )
  0         A literal 0 (false condition)
)
Implicit print (¿ returns 0 if input is 0)
\$\endgroup\$
1
\$\begingroup\$

Pari/GP, 26 bytes

i=input;until(!i,print(i))

Try it online!

\$\endgroup\$
1
\$\begingroup\$

10IPL, 34 bytes

11001000 01001100 00100010 10100001 10100100 00100010 10100001 10100100 00100010 10100001 10100100 00100010 10100001 10100100 00100010 10100001 10100100 00100010 10100001 10100100 00100010 10100001 00100010 00011010 00101010 00101010 00101010 00101010 00101010 00000100 00000100 00000100 00110010 11110000

Try it online!

Program:

; input

inp rp0

; r1

xor r1, rp0

; rp0 OR r1

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
nor rp0, rp0

rtr r1
nor rp0, r1
rtr r1

; pointer

inr rp1
rtr rp1
rtr rp1
rtr rp1
rtr rp1
rtr rp1
zro r2
zro r2
zro r2

; print

prt r1

; jump

jmp

What is 10IPL?

10IPL, short for 10 Instruction Programming Language, is a simple compiled language I made for use in a computer I'm building in Minecraft. I made an online interpreter for it (with a few extra features), since I think it's a neat language.

How does this work?

This program consists of a few parts:

  1. Take input
  2. Set rp0 (the upper 8 bits of a pointer) to either 00000000 (if the input is truthy) or 11111111 (if the input is falsy)
  3. Set rp1 (the lower 8 bits of the pointer) to point to the prt instruction after it
  4. Print the inputted value
  5. Jump to the pointer

This will jump into a few KiB of zeroed out RAM if the input is 00000000, then terminate. Otherwise, it keep going forever. Don't try it online.

\$\endgroup\$
1
\$\begingroup\$

Applesoft BASIC, 28 26 bytes

1INPUTA
2PRINTA
3IFA GOTO2
\$\endgroup\$
1
\$\begingroup\$

Eukleides, 40 bytes

a=number();for i=0to 0;print a;i=i-a;end

Pretty straightforward. number() takes in a number as input. For loop seems to be the golfiest means of looping for this task. While loop skips the i=i-a; but requires two prints.

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 54 bytes

A JavaScript answer that actually uses both STDIN and STDOUT

n=process.argv[2];do{process.stdout.write(n)}while(+n)
\$\endgroup\$
1
\$\begingroup\$

Prolog (SWI), 28 bytes

:-get(X),repeat,put(X),X=48.

Try it online!

Gets a single character, then repeatedly print it, stopping if it is a zero.

\$\endgroup\$
1
10 11
12
13 14
17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.