[Community Puzzle] Stunning numbers

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @VilBoub,validated by @Antsurf,@jddingemanse and @FredericLocquet.
If you have any issues, feel free to ping them.

Doing this in C.

I had execution time problems on tests 8 and 10 in my first approach, which just tried every single number starting from n+1 until finding the next “stunning” one.

I redid it in a much more efficient way after realizing a clever trick (not spoiling it) and now I pass all tests but Validator 3 doesn’t validate, and I don’t know why…

Since my first method did pass Validator 3, I could do some horrible stuff like this (value of 8 could change):

if strlen(n) < 8

but that’s disgusting and awful.

It’s 3am, so I’m leaving it at 90% for now.
But I’d appreciate some feedback, if other people have had any trouble with this validator or not.

1 Like

The only difference between Test 3 and Validator 3 is the number length parity.

Fun puzzle.
Maybe i took the puzzle in the wrong way but for me it wasn’t so simple…
For me it’s not an “easy puzzle” anyway !

1 Like

That was interesting, thank you. At first it seemed too easy for me until I got to the seventh test :). And here I had to think a little.

At first I thought I had found the solution, by simply iterating, but like other people it blocked when the numbers got too long. I’ve been thinking about it for days when the other “simple” problems didn’t take me that long. It’s both very interesting to think about and come up with ideas for resolution, and also very frustrating to fail on a supposedly simple problem. Could those who have succeeded confirm that this problem does not require an IQ of 140, which obviously I do not have :slight_smile:

Thanks in advance

1 Like

The basic concept is easy but I would say passing all the tests was not. None of the published solutions seem simple/easy to me. For myself, I finally was able to put it all together when I realized I needed to work from the middle outwards (but it looks like there are other ways to solve it, too).

1 Like

You don’t need high IQ. My tip is to try everything with paper and pen, it helps a lot !

1 Like

Hey, Fellow C Developer.
To solve this puzzle you need to know two tricks.
You was to tired to see what is going on.

Try second time after rest.
I had similar problem. My code was OK in IDE but failed on my PC. Validator 3 was a pain in the neck until I got a break :sunglasses:

I finally solved this puzzle. While I want to say it was good, I have to slam it because it is decidedly NOT EASY. This problem has many edge cases that are not obvious. The good news is that the test cases catch them. The bad news is that finding a solution that successfully passes every case took me many hours over multiple days.

If this can be bumped up to Medium (or maybe even Hard), I will be happy to improve my rating.

I agree that it is a difficult Easy puzzle. However, the easy aspect of this puzzle for me was that during solving, errors were very clear, because you get the correct answer in the output. While I regularly needed to change my code along with the cases, it was each time very clear what I was doing wrong.

And, once I switched from finding the next stunning number to predicting it, the task became quite doable. Not easy Easy, but also not more difficult than some of the difficult Easy contributions.

I have an issue with the validator 5, the test 5 has never been a problem during my coding debug.
the optimisation went quite simple but this issue is bloking my validation… no clue about the issue.
Does anyone have some possible reason of validator specificity in front to equivalent test ?

thanks you !

Validator 5 is very similar to Test 5: only one digit in the input has been changed.

In case other people have an issue with Validator 5, here are two custom cases for you to help with debugging:









You might want to add a note about leading 0’s; e.g., is 080 a stunning number?