Power of Thor - Codesize - Puzzle discussion

Hello,

I’ve saw a strange thing recently, my code C# code was approved and 100% successful.

I logged in and I was looking to improve my code golf projects and I saw that I was very far in the rankings. My score is suddenly 75%, my code failed on Optimal Angle.

Did validations changed? Thanks a lot for your help :slight_smile:

Yes, they did changed.

Indeed, 45 was not out of question :slight_smile:

I ended with 108 in python 3, most of the code is taken by
the input line

x,y,X,Y=map(int,input().split())

That’s all you need.

You can ignore the input given each turn, you don’t need it to keep track of your coordinates.
It will display a warning message but it’s fine.

1 Like

I don’t get the point. The validators have changed but without correcting the previous flaw. It is still possible to hardcode the solution and it still lacks a direction …
This rewards once again the people who are ready to reverse the validators and takes us further away from the real interest of the problem, the code golf …

2 Likes

Actually, for this specific puzzle, setting up a good hardcoding solution is a way more interesting challenge than solving the real problem.
You could sure add a dozen of validators to make it check all 16 kind of angles and make it impossible to hardcode but if you do so, I predict a LOT of tied first place solutions.
Cause there is not much to golf in the initial problem so everyone will figure out the optimal solution fast enough.

3 Likes

I agree 100%. Solving validators is much more challenging task then solving the problem itself.

Yup, new re-run resulted in 25% and I’m not brute-forcing again :slight_smile:

Hello, it seems CodinGame does not support last C# version. In the last version it is possible to create a program without declaring a class containing a “Main” method. It is possible to just write code and the compiler will automatically generate a “Program” class containing a “Main” method executing the code you wrote. With this feature, everyone could decrease its code by about 30 characters.

Please, in C++, how can you make less code than this ?

Code deleted by a moderator. //This is a competitive mode, please don't share code.

It takes 186 characters, but a lot of people are using less.

3 Likes

Ok, sorry, i won’t do this anymore.

3 Likes

I have found that cutting things that are necessary for proper programming helps. Start by cutting the includes if you keep using them. Try running the code and see if it “works” . Of course, doing it in a normal program could cause it to explode or something, but doing it here might work.

Thank you, but already done, except i can’t remove include iostream in c++ (in C i removed all includes).
I removed the using namespace, I optimized conditions in for loop, I named datas with only 1 letter, … i can’t see what i can do. But i’m very far from the others.
I don’t want the ultimate solution, but i want to understand what i can do to divide by 2 or 3 my code.
Now my code’s length is 169 in C++ (best : 67) and 173 in C (best : 47).

Is there something shorter than cin>>/cout<< or scanf/printf ? Is there something you can use without including iostream ?

3 Likes

you who enter here, abandon all hope

2 Likes

What a mess in the leaderboard… I didn’t think there were so many hard coded solutions ! It was just all top leaderboard !
Too bad it wasn’t some newly added test cases and that they are already broken.
Now i’m curious to know 2 things :

  • What are the real score of top player
  • What will be the don’t panic leaderboard if tests change :stuck_out_tongue:

Yes they need to fix this, I can’t even know if I’m missing something or if the other solutions are just hard coded.

Never would have found the ternary operator in python if it was not for this exercise.

try playing with the following:

lx = 3
tx = 5
direction=‘NS’[tx<lx] ## as compact as tx<lx?‘S’:‘N’ in C

But even with that, the most compressed in python is 152 (while keeping all direction considered)

You can definitely get to 120 in Python while still keeping all directions :slight_smile: I am obsessed with this puzzle seeing somebody got 54 characters.

You can get to 81 chars in Python if you want a fully deterministic script that would pass any set of validators, would actually check all directions etc.
(Note: I never really tried to improve my “clean” 81 chars solution so there might even be a few chars to shave.)

And if you want to get really lower, you must go dirty ^^