[Community Puzzle] CGFunge Prime

Yes, offline computation allows to compute for a bit longer but it’s pointless if it takes years to compute.
So having a fast algorithm is what makes the difference anyway.

Hi,

I wonder why (in python)

solution = “”“1
E”""
print(solution)

lead to this error “Program pointer out of code area at (1/0)”
(before the expected error “Output was: ; expected: NOT PRIME”)
while

solution = “”“1
E “””
print(solution)

works fine just with an added space.

Also why sometimes I get a warning that the input was not entirely read ?

Thanks

I got the warning when the number of lines specified did not match

For such puzzle, it would be feasible to have random numbers as validators, wouldn’t it? Or one random numbers per predefined range.

1 Like

In hindsight I could have made a single validator testing every number within the range (and show the first replay where your solution failed).
But too late to change now, it would break the entire leaderboard.

I don’t mind about breaking the leaderboard of one puzzle that started recently. And that would be fair in this case.

One could still create a new puzzle for checking that a number is within a given list.

Here is a live interpreter I made for CG Funge. Make it easier to see what happens as you change the code.
http://johann-elsass.net/cgfungelive.php

2 Likes

Thanks for sharing.
There’s also this one from Marchete: Coding Games and Programming Challenges to Code Better.
I’m a bit scared to add a link to the statement at this point. I have some history of clearing the entire leaderboard with such small changes.

1 Like

It would be nice to add the link indeed. Thanks for thinking about that. I understand you have some responsibility here about clearing the leaderboard. I wonder if people would loose their submissions, their code. That would be bad because people may not have saved them locally.

Not losing the code. But there’s a risk of removing every player from the leaderboard. If this happens, some scores would be gone forever (inactive users who don’t resubmit).
I think it won’t happen, as CG addressed the issue. At the same time there is a limit for the amount of validators that’s lower now than it was back when I created the puzzle. I really don’t want to risk breaking anything.

Thanks for this puzzle, I had so much fun solving it.
Now, I think I would like to try to climb the leaderboard, but only if I know that there are no cheaters in there… Really, is there no solution to have some randomly selected validators to make certain to get-rid of the hard-coders ?
Having the possibility to play for real would be amazing !

Technically it would even be possible to test every number from 1 to 10000. You just have to test multiple numbers in a single validator. In hindsight that’s what I should have done.

But I’m very hesitant to change anything now, some users have put in a lot of time to optimize. It doesn’t have much to do with prime numbers at the top anymore, it’s more about finding an efficient way of building a binary tree. While it’s not what I had in mind, I wouldn’t call it cheating. It’s still an achievement to compress the tree and wiping out the entire leaderboard (that’s what will happen when I change any testcase/validator) would not be fair to either of those who solved it in the intended way nor those who hard-coded.

Despite being a different problem, it can still be a fun challenge.

The best way to address this would probably be a fork: create a new optimization problem - if that’s a valid concern for multiple users and justifies a new problem. You have my blessing in doing so and using my code.

3 Likes

I get your point.
Well, maybe creating another kind of problem, with the very same langage… I’ll think about this. Thanks for your answer :wink:

1 Like

I’m afraid that not enough people have really tried doing this puzzle, it’s actually a great puzzle (even addictive to some extent), in any of the ways you choose to do it :smile:.

Anyway, I made yet another batch runner/editor this week:

This is a visual one, I’m still improving it, but I already feel that I write and debug in CGFunge quite faster (and more easily) than I did with the previous batch runners + excel template setup (thanks Marchete and circular17, they are still much better than plain text, as I did in my first version). I hope this will allow more people to try it, and I hope in the future there can be more puzzles with this same topic

Thanks for competiting us, have to improve now ^^

1 Like

Is there a trick ?
It’s been a very hard job to reach my current score. You defeted me, ok, but now the gap is much too big! It’s irrealistic.

There are 53 prime numbers and 47 non-prime, so you need 13x53 + 21x47 = 1685 steps, only for writting "EMIRP"CCCCCE or "EMIRP NOT"CCCCCCCCCE.
That means you used 3533-1685 = 1848 step to find if the numbers are prime or not, so only 18.5 per number. It’s shorter than "EMIRP NOT"CCCCCCCCCE ! :exploding_head:

There are several tricks, which involve luck (even for <4400) that can also be optimized.
To be fair, if you need reference my best 100% table is 4622, solving that optimally is step 1 of the optimization, the rest is thinking out of the box (I guess)… involving odds (efficiently) to the solution is step 2, and the 3rd step is something harder to do which I’ll keep a secret for now at least :wink:

For disclaimer, none of the tricks involves “hacking” or bugs in the puzzle implementation (I hoped I could find a way to do “EMIRP TON"CCCCCCCCCE in less steps but I don’t think is possible). And there is only one “complex math” stuff that can improve your solution, and which can only be used in just one place (as far as I know, aside D"X”-: comparisons)

1 Like

Thanks for your answer. I already use one “complex math” stuff aside comparisons :wink:
I’ll meditate about the “involving odds (efficiently)” idea.

1 Like