*le wild flashback appears
Remember this? Today we shall discover the intricate story of how Xorin managed to get hold of Xoranna's phone number.
It all started when the two incidentally chose the same vending machine in their university campus. Unluckily, Xorin was all out of money, due to his previous night out. Right when he was ready to disheartenedly head back to class, Xoranna came out of nowhere and handed him the 2 RON he required for his hot chocolate.
Xorin was delighted. They only thought he could think of was along the lines of "hmm... she's alright...". So he instinctively asked her for her number, which she immediately agreed to. It was only the next day when he noticed he had missed one digit...
"Wait!", Xorin thought to himself. "There can't possibly be that many combinations...". The real number's format was 07######## (10 digits - the fixed 07, followed by 8 custom digits). The number Xorin saved only has the fixed 07 and 7 custom digits. Your task is to find out how many unique and valid 10-digit numbers Xorin's number could have originated from.
The only line of input contains the 9-digit number that Xorin wrote down.
You should output one integer - the number of unique numbers that Xorin has to try.
Keitai can be solved by generating all possible solutions and then counting them. Basically, we need to add exactly one digit to any valid position in the original number. This method grants one possible number at a time, not necessarily unique. After having generated all numbers, the duplicates can be easily erased, using a specialized data structure (C++'s set or Python's set).
1 def solve(s): 2 possible =  3 4 for pos in range(2, 10): 5 for digit in range(0, 10): 6 new = s[:pos] + str(digit) + s[pos:] 7 possible.append(new) 8 9 return len(set(possible)) 10 11 print solve(raw_input())
At a closer look, we start to notice that the code above outputs 73 for any given input. This is due to the fact that Keitai is not an input-dependant problem. In order to see why, try to simulate (on a piece of paper) the process described, for a shorter input number.
For all the tractor fans:
1 print 73