An ancient reliquary assigns every stored relic a positive whole-number catalog code. When a relic is sealed away, the vault's engraving press first converts the catalog code to hexadecimal (uppercase, no leading zeros). The press then stamps that hexadecimal string onto the vault door using a special typeface that only has letter molds: the ten letters A through F, plus two digit look-alikes, since the press stamps the digit 0 as the letter O and the digit 1 as the letter I. The press has no mold whatsoever for any other digit (2 through 9).
Given a relic's catalog code, determine what gets stamped on the door. If every character of the hexadecimal representation is one of 0, 1, or A-F, print the resulting inscription, with every 0 replaced by O and every 1 replaced by I. Otherwise, the press cannot produce a legal seal at all, so print ERROR instead.
A single line containing one integer n, the relic's catalog code.
Print one line: either the stamped inscription (uppercase letters only), or the literal text ERROR if the hexadecimal representation of n contains any of the digits 2-9.
Example 1
Input
3735928559
Expected
DEADBEEF
Explanation
3735928559 in hexadecimal is DEADBEEF, which is made up entirely of letters A-F, so no substitution is even needed and the seal is exactly DEADBEEF.
Example 2
Input
32
Expected
ERROR
Explanation
32 in hexadecimal is 20. The digit '2' has no letter mold (only 0, 1, and A-F do), so the press cannot stamp a legal seal and the output is ERROR.
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 →