Skip to content

Instantly share code, notes, and snippets.

@ellismarte
Created January 6, 2016 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellismarte/5f47f6a859db6a5afd03 to your computer and use it in GitHub Desktop.
Save ellismarte/5f47f6a859db6a5afd03 to your computer and use it in GitHub Desktop.
def calculate(input, output)
array_of_nums = input.split("").map! {|num| num.to_i}
operators = [+, -, *, /]
operators.each do |op|
array_of_nums.each_with_index do |num, index|
p num op array_of_nums[index..array_of_nums.length].join('').to_i
end
end
end
calculate("314159265358", 27182)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment