Create a gist now

Instantly share code, notes, and snippets.

@radarek /README.md
Last active Jan 2, 2016

What would you like to do?
#!/usr/bin/env ruby
probability = $stdout.tty? ? (ENV["D"] || 10).to_i : 0
puts ARGF.read.chars.map { |c| rand(100) + 1 <= probability && c !~ /\s/ ? " " : c }.join
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end
p fib(34)

ankurp commented Dec 19, 2014

How does this work. Seems like this line is the reason why it works. I noticed that it outputs to console with whitespace but when it writes to a file it will write without whitespace character probability = $stdout.tty? ? (ENV["D"] || 10).to_i : 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment