Program
Write a program to convert a cryptocurrency code back to a secret passcode. The cryptocurrency code was generated using CryptoCurrency Code Algorithm that involves dollars, quarters, dimes, nickels, and pennies.
Input
- The input crypto current code.
Output
- The un-encrypted secret passcode.
Algorithm
- Parse an extract the amounts of currency denominations (dollars, quarters, dimes, nickels, and pennies).
- For each denomination where the amount was > 0, a two letter prefix was used to encrypt that currency denomination.
- Convert the amounts for each denomination into cents to get back the secret passcode.
Dollar do Quater qu Dime di Nickel ni Penny pe
Test cases
No | Input (CryptoCurrency Code) | Intermediate Calculation | Output (Secret Passcode) |
---|---|---|---|
1 | 2do1qu2di3pe | 2 dollars, 1 quarter, 2 dimes, 3 pennies | 248 |
2 | 2do1qu2di | 2 dollars, 1 quarter, 2 dimes | 245 |
3 | 2do2qu1ni2pe | 2 dollars, 2 quarters, 1 nickel, 2 pennies | 257 |
4 | 2qu1pe | 2 quarters, 1 penny | 51 |
5 | 1ni1pe | 1 nickel, 1 penny | 6 |
6 | 1ni | 1 nickel | 5 |
7 | 1do | 1 dollar | 100 |
Instructions
- Accept the input number cryptocurrency code via the command line.
- Write the logic to compute a number of currency denominations (dollars, quarters, dimes, nickels, and pennies) and convert each to a cents value and add up.
- Display the resulting secret passcode.