Skip to content

Instantly share code, notes, and snippets.

@radarek radarek/
Last active Aug 29, 2017

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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.