Ad
  • Default User Avatar

    Like a few other kata I've seen, this is as much a math problem as a coding one. Unlike those, the math problem here is complicated and hard - the square pizza algorithm requires factoring n, which gets much harder as n increases. In combination with the large test numbers and the runtime limit, it becomes a "how many optimization tricks do you know" problem more than a math problem.

    As-is, this is more difficult than I think it really needs to be. Depending on the difficulty level you're aiming for, I would recommend either:

    • Lower the maximum n for test cases to something slightly less absurd, so that less optimized solutions can get past the runtime limit (low difficulty - ~7 kyu).
    • Keep the high n (higher difficulty - ~5 kyu): You may want to reflavor it as a non-pizza-related geometry problem, so us geometry nerds notice it (and to avoid the issue of crusts on square pizzas).

    Additonal suggestions:

    • Instead of having a fixed scenario of 1 circular & 1 square pizza, consider adding an input variable to indicate what kind of pizzas are involved (could be a string "circle" or "square", a list or other type encoding multiple pizzas, etc.). This would require the same algorithms to solve (we would still need to figure out how to evenly divide circular / square pizzas), but would be more flexible and therefore interesting.