Problem context and objectives
Mission briefing
Puzzle systems engineer · A game mechanic is behaving incorrectly
Separate partial sum from carry: The Carry Forge.
Brute force may pass the demo but fail when the world fills with players.
How you win
- 1Recognize when Add without plus matches the clues
- 2Keep this true after every move: sum plus carry equals the original mathematical total in 32-bit arithmetic
- 3Reach the result within O(32) time and O(1) space
Rules and pressure
- Target cost: O(32) time and O(1) space
- State rule: sum plus carry equals the original mathematical total in 32-bit arithmetic
Lesson 1 of 3
Live algorithm trace
Add without plus
Complete execution1 of 4
Begin adding 1 and 2 as fixed-width bit patterns.
1
while carry operand is not zero2
partial = a XOR b3
carry = (a AND b) << 14
a = partial; b = carry5
return aa = 001b = 010
Truth to preserve / Cost target
Truth to preserve
sum plus carry equals the original mathematical total in 32-bit arithmetic
Cost target
O(32) time and O(1) space
XOR adds bits without carrying. AND identifies positions that generate a carry, which shifts left and repeats until no carry remains.
Your call · What should guide every step of this algorithm?