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"))}}
y
or\n
inside of a string literal"? \$\endgroup\$true.c
is 80 lines long. \$\endgroup\$yes
takes an optional argument on the command line, notstdin
. \$\endgroup\$y
s yourself. \$\endgroup\$