56
\$\begingroup\$

yes, from coreutils, is 91 lines long. Many of them are comments, but that is still WAY too long.

Edit from September 2019: the source file grew over the past five years and is now 126 lines long.

Write a program that imitates yes:

  • outputting to stdout an infinite stream of "y\n"'s
  • there must be an option to stop it other than killing the process with SIGKILL: but SIGINT and SIGPIPE are fine
  • you are not allowed to use "y" or "\n" or their ASCII values (121, 0x79, 0171, 10, 0xA or 012)

Shortest answer wins.

Bonus:

  • subtract 10 from your code length, if you can receive a phrase in stdin and print it out instead of "y" (but still including the line-break). The program doesn't have to print y on an empty input.
\$\endgroup\$
28
  • 14
    \$\begingroup\$ "you are not allowed to use "y" or "\n"" -- should I read this as "You may not use y or \n inside of a string literal"? \$\endgroup\$
    – apsillers
    Commented Dec 17, 2014 at 14:28
  • 16
    \$\begingroup\$ On a related note, GNU true.c is 80 lines long. \$\endgroup\$ Commented Dec 17, 2014 at 22:32
  • 10
    \$\begingroup\$ @DennisWilliamson On a similarly related note, false.c is 2 lines long.... ;_; \$\endgroup\$
    – LordAro
    Commented Dec 18, 2014 at 2:30
  • 8
    \$\begingroup\$ the coreutils yes takes an optional argument on the command line, not stdin. \$\endgroup\$ Commented Dec 18, 2014 at 20:05
  • 10
    \$\begingroup\$ @MrLore: to pipe into other programs that might constantly ask for confirmation of the various things they are doing, so you dont have to sit there typing the ys yourself. \$\endgroup\$ Commented Dec 20, 2014 at 16:57

92 Answers 92

37
\$\begingroup\$

CJam, 13 bytes - 10 = 3

l_'x)?{_oNo}h

You'll need to use the Java interpreter for this, because the online interpreter only returns once the program terminates.

You can abort the program with SIGINT (by pressing Ctrl-C). It will read a line from STDIN, and print that line, or y if the input was empty.

Explanation

l             "Read line from STDIN.";
 _            "Duplicate.";
  'x          "Push character x.";
    )         "Increment to get y.";
     ?        "Ternary operator. Replaces line with y if it was empty.";
      {    }h "Repeat while true. Leaves condition on the stack, which is the output string.";
       _o     "Duplicate line and print.";
         No   "Push string with newline and print.";

After clarification of the OP, the following seems more to spec:

l{_o9c)o1}g

I'll wait with updating the submission until the OP replies to my comment, though.

\$\endgroup\$
1
  • 18
    \$\begingroup\$ I like that your program happens to match /no/i, considering what the challenge it. \$\endgroup\$
    – Kevin
    Commented Dec 18, 2014 at 2:27
22
\$\begingroup\$

Brainfuck - 38 bytes

++++++++++[>++++++++++++>+<<-]>+[.>.<]

It doesn't use 10 or 121, because +-<>.,[] are all the meaningful characters in the language anyway, but it does calculate them pretty naively (0+1+1+1+1+1+1+1+1+1+1=10, 10*12+1=121).

This probably depends on the interpreter, but it dies to ^C on my machine.

Brainfuck - (63-10)=53

++++++++++[>,]<<[[<]>>[[.>]<[<]>]]>[>++++++++++++>+<<-]>+[.>.<]
\$\endgroup\$
5
  • \$\begingroup\$ @fry I couldn't get it below 39 that way. I need 10 anyway, so I'm either adding 1 to 120 or subtracting 1 from 11, and it's shorter to do the former. \$\endgroup\$ Commented Dec 17, 2014 at 14:42
  • \$\begingroup\$ Yeah, I noticed after that you reused the 10, sorry :P \$\endgroup\$ Commented Dec 17, 2014 at 14:47
  • \$\begingroup\$ Instead of 10*12+1, why not 11*11? I think that could save you a char. \$\endgroup\$
    – ProgramFOX
    Commented Dec 17, 2014 at 14:52
  • \$\begingroup\$ @pro I couldn't get it below 39 that way. I need 10 anyway, so I'm either adding 1 to 120 or subtracting 1 from 11, and it's shorter to do the former. \$\endgroup\$ Commented Dec 17, 2014 at 14:54
  • \$\begingroup\$ @undergroundmonorail Ah, I see. \$\endgroup\$
    – ProgramFOX
    Commented Dec 17, 2014 at 14:55
21
\$\begingroup\$

Python 3, 27 bytes

Works with at least CPython and Jython.

while 1:print(str(help)[1])

SIGINT stops it.

\$\endgroup\$
6
  • 22
    \$\begingroup\$ Make it python2 and you can shorten it to while 1:print`help`[1]. \$\endgroup\$ Commented Dec 17, 2014 at 14:04
  • 4
    \$\begingroup\$ Haha, nice. I completely forgot that there "used to" be a backtick operator in python :) \$\endgroup\$
    – pgy
    Commented Dec 17, 2014 at 16:30
  • \$\begingroup\$ You could use chr(11**2) to save a few characters as well \$\endgroup\$ Commented Dec 19, 2014 at 22:33
  • 2
    \$\begingroup\$ @RamchandraApte You're not allowed to use 121. \$\endgroup\$ Commented Dec 21, 2014 at 6:24
  • \$\begingroup\$ Why does this output y's? \$\endgroup\$
    – user9207
    Commented Mar 29, 2020 at 10:54
19
\$\begingroup\$

Pyth, 10 9 6 bytes - 10 = 0 -1 -4

#|zePG

I've been trying for ages to get one that I'm satisified with. Basically converts to:

#      = while True
(implied print)
|      = or
z      = (automatically initialized from stdin)
ePG    = second-to-last lowercase letter = 'y'
\$\endgroup\$
4
  • \$\begingroup\$ The "z" variable is initialized from stdin, then the value is simply used after that. Found a short way to get the ascii value without writing it explicitly. \$\endgroup\$
    – swstephe
    Commented Dec 18, 2014 at 16:48
  • \$\begingroup\$ Switched from "^11 2" to "^hT2" to save a character. \$\endgroup\$
    – swstephe
    Commented Dec 18, 2014 at 17:13
  • \$\begingroup\$ Hi swstephe, I'm excited to see another user of the language! A couple of golfs: # has equivalent functionality to W1, and ePG is a much shorter way to get the character y than C^hT2. \$\endgroup\$
    – isaacg
    Commented Dec 20, 2014 at 8:03
  • \$\begingroup\$ Thanks, I'll apply those changes. Still new at this golf thing. I like Pyth, but wish had a few more contextual functions and bit manipulation. \$\endgroup\$
    – swstephe
    Commented Dec 21, 2014 at 3:31
16
\$\begingroup\$

Marbelous 14 bytes

0978
]]/\++
!!

This is pretty straightforward, the '/\' device places two copies on its left and right, the right one is incremented by ++ and then falls off the board and is printed. The ]] device pushes any marble to the right if STDIN is empty but lets the first byte on STDIN fall down if it isn't. This will then trigger the !! device, which exits the board. So this will print y\n until you enter anything on stdin.

This only works in the python interpreter.

\$\endgroup\$
13
\$\begingroup\$

C#, 81 78 76 bytes

Cannot compete with the other languages, but here it is anyway:

class A{static void Main(){for(;;)System.Console.WriteLine((char)('x'+1));}}

Can be killed with SIGINT by pressing Ctrl+C.

No bonus, because it would take more than 10 bytes to get it.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Can't you use while(1)? Saves two characters. \$\endgroup\$
    – Toothbrush
    Commented Dec 17, 2014 at 15:56
  • \$\begingroup\$ @toothbrush I have tried that, but that doesn't work in C#. \$\endgroup\$
    – ProgramFOX
    Commented Dec 17, 2014 at 15:57
  • 2
    \$\begingroup\$ for(;;) should work. \$\endgroup\$
    – core1024
    Commented Dec 17, 2014 at 16:07
  • 2
    \$\begingroup\$ For some reason, this code still has a y in it. Please examine System. \$\endgroup\$ Commented Dec 18, 2014 at 16:04
  • 4
    \$\begingroup\$ @TheBestOne That System cannot be removed. it is the top namespace in the .NET Framework, all classes/other namespaces are in it, so reflection won't help here. But not sure if it's invalid. See Ramon's comment: "nothing that evaluates to y or \n". This does not evaluate to y. I'm leaving a comment on the question to ask Ramon whether this is valid. \$\endgroup\$
    – ProgramFOX
    Commented Dec 18, 2014 at 16:39
12
\$\begingroup\$

Java, 178

class C{public static void main(String[]a)throws Exception{for(char c='x'+1;;)((java.io.PrintStream)Class.forName("java.lang.S"+c+"stem").getField("out").get(null)).println(c);}}

Printing requires System, but the y character is forbidden. Hence, I had to use reflection.

\$\endgroup\$
3
  • \$\begingroup\$ FileDescriptor.out is what I meant. \$\endgroup\$ Commented Dec 18, 2014 at 4:30
  • \$\begingroup\$ You can save a ; by putting char c='x'+1; into the for loop declaration, so for(char c='x'+1;;) since you have an empty semicolon in there anyway \$\endgroup\$
    – corsiKa
    Commented Dec 18, 2014 at 22:58
  • \$\begingroup\$ @corsiKa Good point. \$\endgroup\$
    – Ypnypn
    Commented Dec 19, 2014 at 3:51
9
\$\begingroup\$

Perl: 18 bytes - 10 = 8

The string is from STDIN.

$_=<>;{print;redo}
\$\endgroup\$
5
  • 3
    \$\begingroup\$ Does it print y\n repeatedly if it doesn't receive input from STDIN? If not, then it doesn't properly imitate yes. \$\endgroup\$
    – vurp0
    Commented Dec 17, 2014 at 22:19
  • \$\begingroup\$ @vurp0 yes does not take input from STDIN after all :) \$\endgroup\$
    – core1024
    Commented Dec 18, 2014 at 23:55
  • 1
    \$\begingroup\$ It doesn't, but the code golf question here specified that if it doesn't receive input, it should repeatedly print y\n. \$\endgroup\$
    – vurp0
    Commented Dec 19, 2014 at 0:00
  • 2
    \$\begingroup\$ @vurp0 Where? Any program that reads from a stream will hang without input. \$\endgroup\$
    – core1024
    Commented Dec 19, 2014 at 0:02
  • \$\begingroup\$ @vurp0 See the OP's comment on the question. \$\endgroup\$
    – user344
    Commented Dec 19, 2014 at 12:32
8
\$\begingroup\$

Ruby, 30 23 18 bytes

loop{puts ?x.succ}

Can be killed with SIGINT by pressing Ctrl+C.

Thanks to manatwork for sharing improvements!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ loop{puts [*?x..?z][1]} – 23 chars, loop{puts ?x.succ} – 18 chars \$\endgroup\$
    – manatwork
    Commented Dec 17, 2014 at 14:39
  • \$\begingroup\$ @manatwork Thanks! Updated. \$\endgroup\$
    – ProgramFOX
    Commented Dec 17, 2014 at 14:41
8
\$\begingroup\$

Linux Bash - 19 bytes

This is probably cheating and subject to failure if you don't have /usr/bin/yes or have a /usr/bin/xes or /usr/bin/zes:

/usr/bin/[x-z]es $*

I think it meets the requirements, though maybe it's violating the "nothing that evaluates to y" rule. And perhaps imitating yes by actually running yes is against the rules.

This could be optimized a bit (though less likely to work) to take it down to 11 bytes:

/*/*/?es $*

I couldn't figure out how to get the 10 point bonus by reading a string from stdin without adding more than 10 bytes to the code

\$\endgroup\$
2
  • 2
    \$\begingroup\$ /*/*/?es `line` , or /*/*/?es `head -n1` if you don't have /usr/bin/line. \$\endgroup\$
    – jimmy23013
    Commented Dec 18, 2014 at 16:14
  • 2
    \$\begingroup\$ Or sed q for line. \$\endgroup\$
    – jimmy23013
    Commented Dec 18, 2014 at 16:15
8
\$\begingroup\$

Perl, 26 bytes

{print chr$=*2+1,$/;redo}

Custom input from argument (like yes actually works), 22 bytes-10=12

{print @ARGV,$/;redo}

Custom input from stdin, 22 bytes-10=12

while(<>){print;redo}
\$\endgroup\$
3
  • \$\begingroup\$ @mar Nitz's program is only 14 bytes long and there's a very highly upvoted comment on your link that says it's chill for filenames to matter if you include them in the bytecount. This seems legit to me. \$\endgroup\$ Commented Dec 17, 2014 at 14:00
  • \$\begingroup\$ oh wait, i didn't see the "you can't use \"y\"" part of the question. nevermind this is bad \$\endgroup\$ Commented Dec 17, 2014 at 14:01
  • \$\begingroup\$ Right you are. Fixed it \$\endgroup\$
    – Nitz
    Commented Dec 17, 2014 at 14:23
7
\$\begingroup\$

C, 64 55 53 45 40 - 10 = 30

main(int c,int**a){for(;;)puts(a[c>1]);}

I'm not hugely happy with this, as it requires the program to be named "y", and to be called with `y` only, so it has to be in $PATH, but hey, first codegolf :)

Alternative:

C, 30 (+ 1 filename)

main(){for(;;)puts(__FILE__);}

Using the same technique as my esteemed colleague @Matt Windsor

  • EDIT: turns out getting round the no \n character made it shorter
  • EDIT2: "int" is shorter than "char"
  • EDIT3: didn't need that variable at all
  • EDIT4: a bit of slightly undefined behaviour never hurt anyone
  • EDIT5: add alternative version
\$\endgroup\$
5
\$\begingroup\$

Linux Bash, 33-10 = 23

read a; while :; do echo $a; done

Can be killed with SIGINT by pressing Ctrl+C.

\$\endgroup\$
3
  • \$\begingroup\$ You should read only one line and print the same line repeatedly. Your programs are not yes but cat programs. \$\endgroup\$
    – jimmy23013
    Commented Dec 17, 2014 at 17:35
  • \$\begingroup\$ My bad, I should not have tried it after à day of work. \$\endgroup\$
    – Orace
    Commented Dec 17, 2014 at 17:43
  • \$\begingroup\$ How about read a;for((;;));{ echo $a;} \$\endgroup\$
    – core1024
    Commented Dec 19, 2014 at 22:16
5
\$\begingroup\$

Rust, 52 chars

fn main(){loop{println!("{}",'Y'.to_lowercase())}}

There just isn't seemingly a nice way of computing y without being cheeky in Rust-- they've made too good a job of doing chars safely. I:

  • Can't supply a non-literal string to println!, so no tricks allowed there;
  • Can't add 1 to 'x', because in Rust chars aren't numbers;
  • Can't ROT13 (why doesn't Rust have ROT13 in its standard library!?);
  • Can't easily do anything unsafe like dropping to C strings, converting from numbers to chars, etc without being incredibly verbose and going over 52c.

Nor is going for the code bonus worth it, because reading from stdin would require error handling =3

Much of the code reductions I could find involved doing increasingly rule-flouting things with the compiler environment:

Rust, 44 chars (+ at least 1 char for filename)

fn main(){loop{println!("{:.1}", file!())}}

Obsoleted by below. This one probably doesn't count, as the name of the source file needs to begin with y.

Edit: Rust, 36 chars (35 source, 1 filename)

fn main(){loop{println!(file!())}}

As above, but the file has to be called y (not y.rs, y). Humorously, Rust will overwrite the source with the binary! At least on my machine, the binary does work after that though.

Rust, 37 chars (+ equivalent of env K='y' on your platform)

fn main(){loop{println!(env!("K"))}}

This one is even worse: you need to set the environment variable K to y at compile time.

Edit: if you set K to y\n, you could drop the ln in println!, for a grand total of 35 chars and several facepalms:

fn main(){loop{print!(env!("K"))}}
\$\endgroup\$
3
  • \$\begingroup\$ Our usual policy for requiring certain file names or compiler flags is to simply include those in the byte count. \$\endgroup\$ Commented Dec 18, 2014 at 0:58
  • \$\begingroup\$ @MartinBüttner Fair enough. Oddly enough, it would seem that rust isn't the best language for code golf >:P \$\endgroup\$ Commented Dec 18, 2014 at 1:00
  • \$\begingroup\$ You can add one to x in a fashion, but it's still not short: (b'x' + 1) as char \$\endgroup\$
    – Shepmaster
    Commented Dec 20, 2014 at 16:13
5
\$\begingroup\$

dc, 12

[30986Pdx]dx

Only outputs y\n. Doesn't read from stdin, so no bonus.

30986 is 0x790A (i.e. "y\n"). The P command simply converts the number to base 256, and prints the corresponding character for each base 256 digit.

\$\endgroup\$
2
  • \$\begingroup\$ That's pretty clever, how does 30986 evaluate to y\n? \$\endgroup\$
    – user344
    Commented Dec 19, 2014 at 12:37
  • \$\begingroup\$ I knew about P but didn't know it can do more than one character at a time. \$\endgroup\$
    – user344
    Commented Dec 23, 2014 at 13:52
5
\$\begingroup\$

Common Lisp : (30-10) = 20

(format t"~@{~a~%~:*~}"(read))
  • (read) from input stream
  • print to output stream: (format t ... )
  • iterate over all format arguments (only one here) : ~@{ ... ~}
  • inside the loop, for each argument:

    • print argument ~A followed by a newline ~%
    • rewind current element to the previous one ~:* (infinite loop)

You can break the loop with Ctrl+C, which signals an error with restart options (continue/abort).

\$\endgroup\$
4
\$\begingroup\$

Commodore 64 Basic: 14 13 bytes

1?C|(11↑2):R╭

As usual, I've made substitutions for characters in PETSCII that are not present in Unicode. | is used to represent SHIFT+H, while represents SHIFT+U. Note that this outputs ASCII 'y' (byte value 121) rather than a character that the default Commodore character set displays as 'y'.

BASIC is supposedly an easy-to-learn, English-like programming language. Throw in the typing shortcuts present in many early dialects, and you get something that is shorter and less readable than Perl.

EDIT: In "shifted mode", this gets two bytes shorter, thanks to lowercase "y" being encoded at decimal value 89. Using a non-ASCII character set to get around the "not allowed to use their ASCII values" rule might be cheating, though.

1?cH(89):rU
\$\endgroup\$
4
  • \$\begingroup\$ With all the 💩 that exists in unicode, it seems surprising that the full character set used by the C64 wouldn't be in there somewhere. \$\endgroup\$
    – kasperd
    Commented Dec 19, 2014 at 9:12
  • \$\begingroup\$ @kasperd, Unicode's box-drawing characters come mostly from the IBM "DOS" set, and pass through the center of the character cell. PETSCII has a much larger set, much of which uses the edges of the character cell. U+2502 is probably a decent approximation of the vertical bar produced by SHIFT+H, but the pipe character is easier to type. There's nothing corresponding to the "lines on the top and left edges" produced by `SHIFT+O". \$\endgroup\$
    – Mark
    Commented Dec 19, 2014 at 10:58
  • \$\begingroup\$ Very good, but you could save one byte by replacing "Goto 1" by "Run" : "1?cH(89):rU" \$\endgroup\$
    – LeFauve
    Commented Dec 20, 2014 at 12:07
  • \$\begingroup\$ @LeFauve, Thanks. I've also applied it to the ASCII-emitting version. \$\endgroup\$
    – Mark
    Commented Dec 20, 2014 at 12:29
4
\$\begingroup\$

Fission, 5 bytes

Rx+!N

This is fairly competitive for Fission. :)

Control flow starts with a (1,0) right-going atom at R. x sets the mass to 120, and + increments it to give (121,0). Then ! prints the corresponding character (y) and N prints a newline. The source code wraps around at the edges, so the atom passes R again (which doesn't do anything now), x sets the mass to 120 again, + increments it and so on and so on...

\$\endgroup\$
3
\$\begingroup\$

Haskell, 29 bytes

main=putStrLn[succ 'x']>>main

I believe this is stopped by both SIGINT and SIGPIPE.

\$\endgroup\$
1
  • \$\begingroup\$ suggestion: use '\89' instead of succ 'x' \$\endgroup\$ Commented Dec 21, 2014 at 23:55
3
\$\begingroup\$

Ruby, 27 bytes - 10 = 17

It's just @ProgramFOX's solution with the bonus (it took my 9 bytes to solve the bonus question).

loop{puts ARGV[0]||?x.succ}
\$\endgroup\$
3
\$\begingroup\$

dc, 21 bytes - 10 = 11

C1st?st[ltP[]ps0dx]dx

Note that the input needs to be wrapped in [], e.g. [no], because ? is the only way to take input, which executes it as dc code.

\$\endgroup\$
1
  • \$\begingroup\$ You can use C2 instead of 122. In fact I would argue that 122 1- could be replaced with C1 as C1 is not explicitly banned in the question \$\endgroup\$ Commented Dec 19, 2014 at 16:16
3
\$\begingroup\$

AWK, 38 bytes

BEGIN{for(;;)printf("%c%c",60+61,5+5)}

Variant which will read the string on stdin: 14 bytes-10 = 4

{for(;;)print}

But since it cannot do both (revert to "y" if no stdin is provided), I'm not sure it counts... :o)

Both can be exited with Ctrl+C.

\$\endgroup\$
3
\$\begingroup\$

Perl, 31

Here is a Perl version that actually behaves like GNU yes, as far as I can tell:

{print "@ARGV"||chr 11**2;redo}

This works if it is okay to use perl's command line switches (-l for the newline), otherwise it would become 3 characters longer:

{print "@ARGV"||chr 11**2,$/;redo}
\$\endgroup\$
4
  • \$\begingroup\$ typo: is -l (not -e) the switch for the new line. \$\endgroup\$
    – chris-l
    Commented Dec 21, 2014 at 23:10
  • \$\begingroup\$ Also, the bonus is only if your script can read from the stdin. Yeah, I know that real yes does not read from the stdin, but from an argument, but that is the rule of the OP put; it has to be from stdin to have the bonus. \$\endgroup\$
    – chris-l
    Commented Dec 21, 2014 at 23:12
  • \$\begingroup\$ @chris-l fixed the type, thanks. I also removed the claim regarding the bonus, but I will leave my answer as it is :-P \$\endgroup\$
    – xebtl
    Commented Dec 22, 2014 at 9:09
  • \$\begingroup\$ hehe sure, my own answer is like yours; it uses an argument instead of stdin. IMHO, the op should give the bonus to the ones who actually do what the real yes does. \$\endgroup\$
    – chris-l
    Commented Dec 22, 2014 at 20:31
3
\$\begingroup\$

C, 32 bytes

Requires little endian machine and compilation with -O2 (to avoid stack overflow).

a=11*11;main(){main(puts(&a));}
\$\endgroup\$
3
\$\begingroup\$

Javascript, 39 37 bytes

for(;;)console.log(''+Function()[13])

Shorter alternative that only works in the browser, 36 bytes

for(n=''+crypto;;)console.log(n[10])

Alternative without console.log, only works in NodeJS, 58 57 56 bytes

for(n=''+Function()};;)process.stdout.write(n[13]+n[19])
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Welcome to code golf, and nice answer! \$\endgroup\$
    – rydwolf
    Commented Nov 16, 2021 at 17:53
  • \$\begingroup\$ @RedwolfPrograms Thanks! \$\endgroup\$
    – spidunno
    Commented Nov 16, 2021 at 18:16
  • \$\begingroup\$ Your second answer uses y in crypto! \$\endgroup\$ Commented Apr 21, 2022 at 21:01
  • \$\begingroup\$ @Matthew Jensen Indeed it does! \$\endgroup\$
    – spidunno
    Commented Apr 21, 2022 at 23:47
2
\$\begingroup\$

PowerShell, 27 − 10 = 17

param($s=$Host[1])for(){$s}

Might not work in Pash. A more robust alternative should be

param($s="$(gal gh*)"[2])for(){$s}
\$\endgroup\$
2
\$\begingroup\$

Lua, 42 bytes - 10 = 32

while 1 do print(...or('').char(90+31))end

Lua, 49 bytes - 10 = 39

y=...or(string.char(60+61))while 1 do print(y)end

Both were tested with Lua 5.1.4 and can be killed with SIGINT (Ctrl+C).

\$\endgroup\$
1
  • \$\begingroup\$ Awesome! My mom writes in Lua, I've never seen it in the wild before. (Hey mom! Guess what I saw!) \$\endgroup\$
    – Signal15
    Commented Dec 19, 2014 at 20:26
2
\$\begingroup\$

Fortran, 28

do1;1 print'(A1)',11**2;end

Compile with gfortran -ffree-form.

\$\endgroup\$
2
\$\begingroup\$

APL (Dyalog APL), 5 - 10 = -5 bytes

Warning: relies on an undocumented and unsupported feature/bug.

⎕←⍣≢⍞

Empty STDIN prints empty lines (not "y"), which is allowed and has been suggested.

Try it online!

 STDOUT with trailing newlines,

 gets

 repeatedly until

 it differs from

 STDIN

i.e. never, but uninterruptible by pausing the thread.

\$\endgroup\$
2
  • \$\begingroup\$ Hmm. abusing bugs.. interesting. \$\endgroup\$ Commented Mar 1, 2017 at 15:15
  • \$\begingroup\$ @MatthewRoh Using, not abusing. The "feature" is using the operator on assignment , even though isn't a real function proper, and thus not really eligible to be an operand. Still works through... \$\endgroup\$
    – Adám
    Commented Mar 1, 2017 at 16:15
2
\$\begingroup\$

Ahead, 8 bytes

~W-1z'N~

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ i fixed it :))) \$\endgroup\$
    – snail_
    Commented Mar 29, 2020 at 0:53

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.