I was playing around with some challenges at codeeval.com and I get stuck when it comes to submitting my code. There is this weird bunch of code and I just don't understand, where to put my code :) Here is what I see:
=begin
Sample code to read in test cases:
File.open(ARGV[0]).each_line do |line|
#Do something with line, ignore empty lines
#...
end
=end
The task is: Given numbers x and n, where n is a power of 2, print out the smallest multiple of n which is greater than or equal to x. Do not use division or modulo operator.
INPUT SAMPLE:
The first argument will be a path to a filename containing a comma separated list of two integers, one list per line. E.g.
13,8
17,16
OUTPUT SAMPLE:
Print to stdout, the smallest multiple of n which is greater than or equal to x, one per line. E.g.
16
32
My code works, when I run it through the terminal. It looks like this:
def multiples(x, n)
while n < x
n *= 2
end
puts n
end
Thank you for your attention! :)