2000 Canadian Computing Competition, Stage 1
Problem J2: 9966
The digits 0, 1, and 8 look much the same if rotated 180 degrees on the page (turned upside down). Also, the digit 6 looks much like a 9, and vice versa, when rotated 180 degrees on the page. A multi-digit number may also look like itself when rotated on the page; for example 9966 and 10801 do, but 999 and 1234 do not.
You are to write a program to count how many numbers from a given interval look like themselves when rotated 180 degrees on the page. For example, in the interval [1..100] there are six : 1, 8, 11, 69, 88, and 96.
Your program should take as input two integers, m and n, which define the interval to be checked, 1 ≤ m ≤ n ≤ 32000. The output from your program is the number of rotatable numbers in the interval.
You may assume that all input is valid.
Sample Input
1 100
Sample Output
6
All Submissions
Best Solutions
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 01, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
would the number 80 be classified as rotatable? you could represent it as 080?
Thanks again for your help :).
Simply [redacted]. That specifically is probably the hardest part, but there are many ways you can do it.