25 lines
418 B
Ruby
25 lines
418 B
Ruby
###
|
|
# Part 1
|
|
###
|
|
|
|
|
|
a = 325489
|
|
b = a
|
|
while Math.sqrt(b) % 2 != 1 do
|
|
b += 1
|
|
end
|
|
puts "Total: " + b.to_s
|
|
side_length = Math.sqrt(b).ceil
|
|
puts "Side length: " + side_length.to_s
|
|
diff = b - a
|
|
puts "Diff: " + diff.to_s
|
|
|
|
steps_req = diff % (side_length - 1)
|
|
to_center = (side_length-1) / 2
|
|
to_mid_of_row = ((side_length / 2) - steps_req).abs
|
|
solution = to_center + to_mid_of_row
|
|
puts "Pls correct yes: " + solution.to_s
|
|
|
|
|
|
|