Temperature Code Golf puzzle discussion

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

1 Like

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.

5 Likes

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?

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.

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?

14 Likes

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?

1 Like

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 ?

4 Likes

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.

2 Likes

Great.
Please, add more validators to avoid hardcoded solutions ā€¦

2 Likes

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

1 Like

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 ā€¦

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

1 Like

There are now 12 test cases and all the submissions have been recomputed ;).

4 Likes

The 12th test case always fails for meā€¦ are you sure its correct?

1 Like

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

2 Likes

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?

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

1 Like

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

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

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.

2 Likes