Trains the technique from
LeetCode 190Reverse BitsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A jacquard loom is driven by cards carrying a row of exactly 32 punch positions, numbered 0 through 31. A card is handed to you as the integer card: position i is punched precisely when bit i of card is 1, with position 0 the least significant bit. Positions above the highest punched one are simply unpunched, and they are still part of the row.
An operator threads one card in end for end. Return the integer that encodes the row of 32 positions turned around, so that position i of the answer is punched precisely when position 31 - i of card is punched.
Position 0 of card is always unpunched, so position 31 of the answer is always unpunched too and the answer fits in a signed 32-bit integer.
Example 1
Positions 1 and 2 are punched and the other 30 are not. Turning the row around moves them to positions 30 and 29, and 2^30 + 2^29 is 1610612736.
Example 2
Positions 1 through 30 are punched while positions 0 and 31 are not. Turning the row around sends position 1 to position 30 and position 30 to position 1, so the same positions end up punched and the integer is unchanged.
Example 3
Only position 2 is punched, and turning the row around sends it to position 29, giving 2^29.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def reversed_punch_card(card: int) -> int:public int reversedPunchCard(int card)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.