Problem Statement
Hexadecimal numbers are integers written in base 16. The letters 'A' through 'F' represent the digits with values 10 through 15. For example, the integer 202 written in hexadecimal is "CA". This is because 202 = 12*16 + 10, and the digits 12 and 10 are written as 'C' and 'A', respectively.
In this problem we will use eight different letters: in addition to the letters 'A' through 'F' we will also interpret the digit 0 as the letter 'O' and the digit 1 as the letter 'I'. Hence, any word that only consists of the letters ABCDEFIO can be interpreted as a hexadecimal number. Such words are called valid hexspeak words.
Fox Ciel has a
Definition
- Class:
- Hexspeak
- Method:
- decode
- Parameters:
- long
- Returns:
- String
- Method signature:
- String decode(long ciphertext)
- (be sure your method is public)
Notes
- The correct hexadecimal representation of ciphertext does not contain any leading zeros.
- The return value is case-sensitive.
Constraints
- ciphertext will be between 1 and 1,000,000,000,000,000,000, inclusive.
Examples
257
Returns: "IOI"
The number 257 in decimal is written as 101 in hexadecimal. The digits 1 and 0 represent the characters 'I' and 'O', thus we should return "IOI".
258
Returns: "Error!"
The number 258 in decimal is written as 102 in hexadecimal. The digit 2 does not represent a letter, so we return "Error!".
3405691582
Returns: "CAFEBABE"
2882400001
Returns: "ABCDEFOI"
999994830345994239
Returns: "DEOBIFFFFFFFFFF"
1000000000000000000
Returns: "Error!"
1
Returns: "I"
6264353636
Returns: "Error!"
666060670776067
Returns: "Error!"
563452344324234
Returns: "Error!"
1
Returns: "I"
2
Returns: "Error!"
11
Returns: "B"
10
Returns: "A"
9
Returns: "Error!"
4234197547616960
Returns: "FOAFAFOBCOACO"
4207849484
Returns: "FACEBOOC"
48358647426436591
Returns: "ABCDEFOIABCDEF"
3022415463623629
Returns: "Error!"
262
Returns: "Error!"