Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input = ARGV[0]
- module Fib
- @@memo = {0 => 0, 1 => 1, 2 => 1}
- def self.calc(value)
- return @@memo[value] if @@memo[value]
- @@memo[value] = self.calc(value - 1) + self.calc(value - 2)
- @@memo[value]
- end
- end
- anchor = 0
- combos = 1
- while anchor < input.length
- anchor += 1
- runner = anchor
- runner += 1 while input[runner]&.match? /[0-9]/
- combos *= Fib.calc runner - anchor
- anchor = runner
- end
- puts combos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement