Challenge 2 - Hidden numbers
The Nazi air force is trying to transmit numbers (maybe representing army units or available stock) over the radio and the Enigma code has just been broken, so they try to find out a pen and paper solution to send those numbers in a sort of secret manner. They decide to encode them on an arbitrary base using arbitrary symbols to represent the number. The good thing is that we only care about the order of magnitude of such numbers and their minimum and maximum possible values.
You're given a string with characters a-z representing a number. You don't know for sure what base it's in and what digit on that base each character represents. But you know, however, that all digits in the base are present just one time in the input string.You have to calculate the difference between the minimum and maximum possible values. Bear in mind that the numbers never have leading zeroes.
InputThe first line has one integer, T, which is the number of test cases. For each case, there is a line with a string of lowercase characters, S.
OutputFor each line, output “Case #x: ” followed by the difference between the minimum and maximum possible values, as a decimal value.
Limits2 ≤ length(S) ≤ 26
3 bfd xwyz qwerty
Case #1: 10 Case #2: 153 Case #3: 36445In the first case (bfd), these are all the possibilities and their values. Each character from bfd represents a digit in base 3, so the possible digits are 0, 1 and 2. Now we substitute each of the letters by a digit (for example, b->1, d->2, f->0 gives you 102). To convert 102 from base 3 to base 10, the calculation is 1*3*3 + 0*3 + 2 = 11. Following the same logic, we can create a table with all the values.
Test your code
You can test your program against both the input provided in the test phase and the input provided in the submit phase. A nice output will tell you if your program got the right solution or not. You can try as many times as you want to. Be careful with extra whitespaces, the output should be exactly as described.
Test your program against the input provided in the test phase
Test your program against the input provided in the submit phase
During the submit phase, in some problems, we might give your program harder inputs. As with the test token, a nice output will tell you if your program got the right solution or not. You can try as many times as you need.
In the actual contest you first need to solve the test phase before submitting the code, you must provide the source code used to solve the challenge and you can only submit once (once your solution is submitted you won't be able to amend it to fix issues or make it faster).
If you have any doubts, please check the info section.
min: 0:01:32 h
10th percentile: 0:33:39 h
90th percentile: 26:33:43 h
max: 145:14:41 h
|Test phase time:||
10th percentile: 0:32:32 h
90th percentile: 26:24:11 h
|Submit phase time:||
10th percentile: 0:00:49 h
90th percentile: 0:12:58 h
|# of completions:||436|