CCC '00 J2 - 9966
View as PDFCanadian Computing Competition: 2000 Stage 1, Junior #2
The digits ,
, and
look much the same if rotated
degrees on the page (turned upside down). Also, the digit
looks much like a
, and vice versa, when rotated
degrees on the page. A multi-digit number may also look like itself when rotated on the page; for example
and
do, but
and
do not.
You are to write a program to count how many numbers from a given interval look like themselves when rotated degrees on the page. For example, in the interval
there are six:
,
,
,
,
, and
.
Your program should take as input two integers, and
, which define the interval to be checked,
. 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
Comments
Here are all of the number between 1 and 32,000:
numbers = [1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 986, 1001, 1111, 1691, 1881, 1961, 6009, 6119, 6699, 6889, 6969, 8008, 8118, 8698, 8888, 8968, 9006, 9116, 9696, 9886, 9966, 10001, 10101, 10801, 11011, 11111, 11811, 16091, 16191, 16891, 18081, 18181, 18881, 19061, 19161, 19861]
for this its a good idea to use min and max to convert your 2 varibles like this for example
your varible name here = min(n, m)
your other varible name here = max(n, m)
thanks
Sequence for this problem https://oeis.org/A000787