Community Puzzle - Gravity Centrifuge Tuning

Gravity Centrifuge Tuning is very instructive. I suggest everyone to read the titles of the tests to get a clue.

There is one test that is at odds with the puzzle description though. The “Constraints” section states that “N > 0”, but the “Wait, what?” test sets N to 0. It’s probably easier to amend the constraint. If you solve it before the text is changed… be aware of that.


I have just updated the constraints section.
Thanks for your carefulness.


Beautiful puzzle. I enjoyed it a lot :slight_smile:

Zeckendorf can indeed be proud

Kudos to the puzzle writer. Very very elegant.


Hi, I’m trying to solve this puzzle with javascript,
Any clue how to manage the integer overflow?

Seems there is no BigInt() library (on spidermonkey compiler), how I’m supposed to save N (number of tumbles) like on the last test:
"Zeckendorf would be proud of you"?

Even if somehow I managed to work on it’s string representation, and find the binary bitstream (as string), how I can convert the bitstream to octal without overflow?

You are correct that this is much harder in some languages due to the lack of bignum support . For the conversion at the end you can work a single character at a time - every 3 binary bits is one octal character.

Well ok it’s harder (and honestly, why would you use such languages when there are alternatives available? I digress), but I take offense at the “much harder” distinction: if your algorithm is sound, you don’t need any of the “hard” operations, and you can trivially implement them all on a string or bitfield or whatever.

That’s supposed to be way easier than the initial conversion from decimal to your internal representation, whatever it is.

You don’t think it’s a bug that I can’t use BigInt()? (there is BigInt() in node but not in spidermonkey).

How is it possible to find the N tumbles if I can’t reach the number due the overflow?

You can see that the puzzle starts with var N = BigInt(readline()); example:

But you get

ReferenceError: BigInt is not defined
at Answer.js.null on line 6

I’ll try explain the problem:

The way I’m trying to solve is building N, from then is just binary to octal.
but I can’t get to N (in node.js I can) due the overflow.

I see three ways do solve that:

  • Find a smarter solution that doesn’t rely on big integers (for this problem I don’t think there is one)
  • Write your own BigInteger functions
  • Use another language that supports it (C# and Java have BigInteger libraries for example, Python supports them natively)