Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
5-liner: easy and finally correct - thanks to Stefan solution in Clear category for The Centrifuge Problem by przemyslaw.daniel
def balanced_centrifuge(n: int, k: int) -> bool:
valid = {x for x in range(2, n) if not n % x} | {0, n}
for _ in range(n.bit_length()):
valid |= {x + y for x in valid for y in valid if x + y < n}
return k in valid and n - k in valid
March 24, 2024