Temperature Code Golf puzzle discussion


#1

Feel free to send your feedback or ask some help here!

https://www.codingame.com/games/optim/73


#2

I just don't understand why tests in IDE are differents from submit validators. Since the validators are not hidden, we all know that the only way to be the shortest is to hardcode, so the IDE tests are just useless.


#3

Contrary to power of thor, there are 8 test cases used for the validation. Is it still shorter to hardcode than just give a correct solution?


#4

Yes this is shorter when you understand you can just read the first character to anwser to 4 validators. For 4 others, you need one more character.

If you want to do a generic solution, you have to deal with the "in case of equality, take the positive value", far too much characters to handle that.


#5

Well then, why not put a LOT of validators? They don't have to be smartly different or large, just enough for hard-coding not to work.

Btw, do you agree that white-spaces shouldn't be counted in the code size, it's not a smart improvement of the code, you just put everything in one line and make it harder to read?


#6

Definitely not the best, but I have a 52 char solution, and nothing is hard coded. I'd definitely prefer to keep things not hardcoded, but I'm pretty sure I can hardcode validators to improve the size of my code.

I've always assume that the difference between tests and validators was made to prevent hardcoded solution. So if hardcoding cannot lead to better result than non hardcoding solution, why not having the same tests and validators, hence removing frustration from CGamers failing a validator but validating all IDE tests?


#7

Now the tests are the same as before but hidden? It can only benefit those who already hardcode, because they will still keep their top score code, and those who try the legit way won't be able to beat them because there isn't enough tests.

I suggest you do one of the two for golfing puzzle:

  • Either you use the same tests in IDE and validator, so that hardcode isn't as tiresome as it is now
  • Either you create random validators so that hardcoding would be impossible and your solution will need to cover every case

I'll like the second option better, but since it's a lot of work to implement, I suggest you do the first to begin with. In a way or another, top scorer are going to hardcode to get top score (at least until you implement second solution), so why not allow everyone to hardcode by making it easier for everyone? Now it's just giving unfair advantage to those who memorized the tests (myself included)

What do you think @MaximeC ?


#8

We'll discuss this issue tomorrow and we will keep you informed. Due to technical considerations, it's not easy to change the test cases that's why it has to wait tomorrow.

Meanwhile, I've hidden the validators because I don't want people to be tempted to hardcode the solution. If we decide to add new validators, I don't want people wasting their time hardcoding a solution.


#9

Great.
Please, add more validators to avoid hardcoded solutions ...


#10

By the way, this problem is not only on Temperature, but on thor and android too.


#11

I don't mind if the is one or two optimizations with hardcoded.
I just want that all problems don't required hardcoded solutions. This one is new, so let's go for a generic for this one ...


#12

It's not THAT important for solo puzzle, but for multiplayer puzzle like this one, I think it could be better if all golfing puzzle could be improved that way at the same time, if possible.

It will allow to do real golfing: solving a problem in the minimum character count, not solving the tests cases in the minimum character count


#13

There are now 12 test cases and all the submissions have been recomputed :wink:.


#14

The 12th test case always fails for me... are you sure its correct?


#15

We would receive a lot of complains if the last test case were incorrect.


#16

ok so I'm enjoying those codegolf challenges a lot so far, but I feel that there must be some environment-specific hacks that you have to know in order to reduce more.
I mean, I'm at 87 in js, and 70 in ruby, and I feel quite good about it, but at this point most of my code is input handling and output. the best JS is at 67 char I think, and my "non-operative" code ( like the all-dreaded, 21char-long readline().split(' ') ... brrrr) is almost that long in itself...
I guess what I mean is, without giving solutions to the puzzles, are there "hacks", like, say, aliases to readline and print, or ways to gulp multiple lines in a statement, or maybe alternatives to split(' ')...

Maybe we should have a forum post with those for each language, so we're all on the same footing?


#17

Feel free to create a new thread for each language and share your tricks! I think people would be very interested.


#18

I was wondering what were the functions for input that cg implemented to see if there was anything shorter too.

Actually, it exists already for a few language, you just need to create your own for Javascript, you can copy those to make your own. Here is the C++ one and that is the Haskell one


#19

thanks! I was just reading the C++ one and mustering my best tricks. Hopefully someone will have what we're looking for :slightly_smiling:


#20

I don't know if there're any built-in aliases but I did 69 characters in JS using print, readline and split(' '). Sometimes, I create my own aliases to functions (like readline) when I need to use it >2 times.