A retro game console's hardware debugger prints the contents of any 32-bit signed register exactly the way the hardware actually stores it: as a hexadecimal dump using the register's two's complement bit pattern for negative values -- never a minus sign. Given one signed 32-bit register value, print the hexadecimal dump the debugger would show: lowercase hex digits, no "0x" prefix, and no leading zero digits (except that a register holding exactly zero is printed as the single character "0").
A single line containing one integer num.
A single line containing the lowercase hexadecimal representation described above.
Example 1
Input
26
Expected
1a
Explanation
26 in binary is 11010, which groups into hex nibbles as 1 (0001) and a (1010), giving "1a". Since 26 is non-negative and its top nibble is not zero, no leading zeros need to be stripped, so the output is exactly "1a".
Example 2
Input
-1
Expected
ffffffff
Explanation
As a 32-bit two's complement value, -1 is represented by all 32 bits set to 1. Every 4-bit group of all-1s is the hex digit f, and there are eight such groups, giving "ffffffff" with no leading zeros to strip.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →