Skip to content

Instantly share code, notes, and snippets.

@botandrose
Forked from radarek/README.md
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save botandrose/41d754637dd29e5330c7 to your computer and use it in GitHub Desktop.
Save botandrose/41d754637dd29e5330c7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
probability = ENV.fetch("D", 10).to_i
ARGF.readlines.each do |line|
original = line.chomp
backspaces = "#" + ("\x08" * line.length)
diluted = line.chomp.chars.map { |c| rand(100) <= probability ? " " : c }.join
puts original + backspaces + diluted + " "
end
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end
p fib(34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment