diff --git a/spirallingdistance.rb b/spirallingdistance.rb new file mode 100644 index 0000000..d198059 --- /dev/null +++ b/spirallingdistance.rb @@ -0,0 +1,24 @@ +### +# 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 + + +