Problem with task 391 (Scout proficiency badges)

Back to General discussions forum

qwerty     2024-01-06 16:12:55

Hi, friends.

I'm trying to solve problem #391 - Scout Proficiency Badges.

sorry, code removed according to colleague's suggestions - please, upload it as a solution (even not passing the check) so those who solved the problem could see it)

...and unfortunately, my program crashes.

What is worse, I don't see any major flaws which could lead to crash... Can anyone help me to find errors in my code?

CSFPython     2024-01-06 16:27:22

qwerty, hi.

The first comment that I would make is that it is not really appropriate to be discussing a method of solution in this much detail in an open forum, especially when the problem has not been in place for very long.

The example given in the problem is deliberately very simple and is provided in considerable detail. This should enable you to test all aspects of your code. Rather than testing the entire program it might be better to test individual parts of it. You should be able to narrow down the parts which are causing the problem.

When your program works correctly with the example given, I suggest that you devise some other examples of your own (keep them fairly simple) to test the program. If the program works with these you might consider creating a fairly naive (brute force) program to generate other sets of test data which you can be confident are correct.

The full problem is fairly demanding. You will have achieved a worthy completion when you have solved it.

gardengnome     2024-01-06 17:08:04
User avatar

Hi,

First of all, I fully agree with CSFPython - this level of detail should not be discussed in an open thread. Rodion, I suggest to hide large parts of qwerty's post for this reason.

Secondly, I once more fully agree with CSFPython - the example is very detailed and should allow you to work through your code to find the issue. Your general idea is sound.

Thirdly - and that is a matter of personal preference - your code might be too complex. Something like "GSBM".index(award) allows yo to define an order much more easily.

And finally, although the problem is indeed demanding - my initial solution was way too complex - once you think about it it is actually a very standard application of a well-known technique.

qwerty     2024-01-06 17:20:40

CSFPython, gardengnome, thank you much for responses.

I found what the issue is. The code I posted above works very well with example, giving 5 as expected. But I somehow didn't notice in time that scary value that is an answer for test data (12009599006321327), just copied it mindlessly from site to my test suite.

Man, if I noticed that value immediately, I would not even tried to solve this task. It is beyond my comprehension how it is possible to calculate number so big.

I probably should abandon this task for now. Too much above my level, unfortunately.

I'm sorry for discussing the problem in such detail without permission, will try to avoid this mistake in future.

Rodion (admin)     2024-01-06 17:27:21
User avatar

Too much above my level, unfortunately.

Hm-m-m :) I tried thinking of the problem too for some time, but now seeing you found it bit too hard, no wonder I haven't yet glimpsed the idea :)

I'm generally quite ok with leaving problems until I become more clever, even though sometimes I think it won't happen until retirement :)

gardengnome     2024-01-06 17:49:04
User avatar

Hi qwerty, please don't give up just yet, your thinking was on the right track. Also note that log2(12009599006321327) = 53.4. Plus there are no more than 62 scouts, and 2^62 fits perfectly in a 64-bit integer (or you don't care in python).

Once you have solved it you might wonder why you ever thought it was so difficult. :)

qwerty     2024-01-06 18:09:16

gardengnome, thanks for the tip!

I'm not giving up, just abandoning the task for some time, to return back with fresh view.

Will try to make an investigation based on your tip.

Rodion (admin)     2024-01-06 19:03:14
User avatar

good plan :)

as a diversification / divertisement here is a new task to test #392 - probably, trivial, just I have difficulty to testing various cases. thanks in advance.

qwerty     2024-01-07 13:18:07

probably, trivial

Definitely not :)

Please login and solve 5 problems to be able to post at forum