Submit solution
Points:
3
Time limit:
1.0s
Memory limit:
16M
C#
32M
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Canadian 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
for my first j2, i find this question pretty easy...
What were the inputs for the 2nd, 3rd & 4th test cases? My code seems to work with the numbers I put into it, but are wrong when I submit them.
Tazk said down below: try 8008 8008 output should be 1
My solution worked but it's way above the memory limit... How would one approach to reduce memory?
In Java, the memory displayed is the total memory used by Java itself and your program. However, the memory limit is calculated internally based on what your program actually uses. Java itself takes around 24 megabytes for just "Hello, World!" If you had actually went over the memory limit, you would receive an MLE verdict.
This comment is hidden due to too much negative feedback. Click here to view it.
What are the second, third and fourth test conditions? My code seems to work fine for any number I put in.
Try the following test case:
The expected output is:
1
ty very much! I forgot 0 turned upside down is also a 0 smh...
Right now, your for loop condition (the string length) changes every iteration, when you really want it to be static. You can have a temporary variable to store the condition so it doesn't change @yahashim_coding. P.S. can mods move this comment down to Re:
I'm getting WA for the third and fourth test cases. Are there any conditions (my if/else statements) I missed (or applied to the wrong things)?
So am I, im not sure why though.
At this for loop:
for (int i = 0; i < aString.length()/2; i++){
, the condition checks for the length of the string after every iteration, even if its size is changed.Oh, I see. Is it possible to make it so that the for loop's condition is dynamic (changes each time)? As you can see in my code, it depends on the string shrinking and it's similar to recursion (although I think it's more simple). Is the only other way I can do it with this approach be using a recursive method?
This comment is hidden due to too much negative feedback. Click here to view it.
Your solution looks quite a bit over complicated my friend. Try to break it down into simpler conditions and test for each one.
Any tips for how to solve this question?
This comment is hidden due to too much negative feedback. Click here to view it.
This was taken entirely out of context.