Skip to content

Instantly share code, notes, and snippets.

@joerixaop
Forked from botandrose/README.md
Last active August 29, 2015 14:10
Show Gist options
  • Save joerixaop/efa82223127f8f55dd4c to your computer and use it in GitHub Desktop.
Save joerixaop/efa82223127f8f55dd4c 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
original =~ /([^\r]*)$/
original = $1
cr = "#\r"
diluted = original.chars.map { |c| rand(100) <= probability ? " " : c }.join
puts original + cr + 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