# yes is 91 lines long

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)

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).
• "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"? – apsillers Dec 17 '14 at 14:28
• On a related note, GNU true.c is 80 lines long. – Paused until further notice. Dec 17 '14 at 22:32
• @DennisWilliamson On a similarly related note, false.c is 2 lines long.... ;_; – LordAro Dec 18 '14 at 2:30
• the coreutils yes takes an optional argument on the command line, not stdin. – Brian Minton Dec 18 '14 at 20:05
• @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. – marcus erronius Dec 20 '14 at 16:57

# ><>, 5 bytes - 10 = -5

a{:o!


Try it online!

Takes input via the -s flag and repeats it forever until the program is interrupted.

• To qualify for the bonus, I think this should print y if no input is given. – Kritixi Lithos Apr 15 '18 at 12:42
• @Cowsquack Nope, it's optional – Jo King Apr 15 '18 at 13:13

# MathGolf, 8 bytes -10 = -2

╜É'x)Äo∟


Try it online!

## Explanation

╜É         else without if (executes block of 3 chars if input is empty)
'x)      increment "x" to get "y"
Ä     start block of length 1
o    print TOS without popping
∟   do while true without popping


Quite straightforward, but gets the job done.

• You don't need to print y if there's no input – Jo King Sep 20 '19 at 22:12
• maxb bug report for MathGolf: string input which contains spaces are automatically transformed to lists (even if they are already inside lists). I noticed this, because it screwed up the length builtins £ and h: Try it online. – Kevin Cruijssen Oct 8 '19 at 12:10
• @KevinCruijssen I think I overcomplicated the implementation of implicit input, which causes these errors. I'll see if I can switch to a pure ast.literal_eval statement for the input, which should solve a lot of issues. – maxb Oct 10 '19 at 10:35

# Python 3, 25 bytes

while 1:print(chr(11*11))


Try it online!

# Microscript, 19-10=9

If['w2s]1{CaI#!Zx}h

Besides the initial input, takes an extra input after each iteration and halts when and if any of the additional inputs is non-empty (the specs for the question said to provide a way to make it halt).

## Ws, 9-10 = -1 bytes

ib12 1C|E


## Explanation

Flag: s % We have to read from STDIN :(
i   E   % Foreach from 1 to infinity:
b      % Take the value of the second operand
% (the first operand is the infinity-count value)
% AND print this value with a newline
12 1| % Just uses a space to do the constant-avoiding job.


# W, 7 bytes

i12 1CE


## Explanation

i     E % Foreach from 1 to positive infinity:
% (Implicit print a newline on each iteration)
12 1    % Space does nothing. Basically just pushes 121.
C  % Convert to a character, rendering 'y'


Python 3, 26-10=16 bytes

x=input()
while 1:print(x)


Seems too easy. Never posted here before so probably done something dumb. What did I miss?

UPDATE I don't think this is cheating (35-10=25):

exec("x=input()\nwhile 1:print(x)")

• Welcome to the site! I think this question doesn't allow newlines so you should use ; instead. The question is a little confusing IMO and I've been here a while. – Post Rock Garf Hunter Dec 23 '19 at 16:57
• Does it satisfy constraint about closing program? – Qwertiy Dec 23 '19 at 16:59
• @WheatWizard, python doesn't support semicolons. – Qwertiy Dec 23 '19 at 17:00
• Oh right. So I'm not even allowed newlines in my source. Got it! :laugh: – Andrew Parker Dec 23 '19 at 17:08
• Best I can get with the bonus is 27, and I need the walrus to do that: x,*_=iter(lambda:print(z),z:=input()) – Andrew Parker Dec 23 '19 at 18:10

## Mumps (M), 12 bytes - 10 = 2 bytes

Quite simple in Mumps (M), as the language allows single character commands and a newline is denoted by '!'...

R I F  W I,!


Breakdown:

Read STDIN into I, For (with two spaces) = infinite loop, Write contents of I, then newline (!)

Works on both InterSystems & YottaDB (GT.M).