[Community Puzzle] Snake encoding

The time lost is the time spent to search why the validators don’t pass, not to code multibyte support. Btw, I deal with UTF-8 file names on a daily basis, and never had to use wchar_c for this :slight_smile:

UTF-8 is designed to be mostly transparent in most reasonable text processing. This isn’t the case here, where it’s used as a fixed-width presentation format where individual glyph’s bytecount actually matters.

This is a rather severe shortcoming in the problem statement (that doesn’t even specify UTF8 is the encoding used), but it’s probably an honest one where the submitter didn’t realize he was using out-of-ASCII characters.

This should be a mathematical problem, not a text I/O one. Please replace the unicode with ascii and introduce a test case where N is crazy vastly superior to X^2 instead.

There are languages besides English. This puzzle stumped me until I found this discussion. This article helped me: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) – Joel on Software

We can change test cases if needed, do not hesitate to make us suggestions. We don’t want because to get stuck because their programming language doesn’t handle non-ASCII characters.

It is dissapointing that this puzzle got approved whilst it has the line:

The input text is composed of ASCII characters

when this is clearly not the case. (I also pass all tests except the last ‘mix’ one)

I’m trying to solve this in javascript but failing so far. The javascript issues with UTF-16 are clear from: JavaScript has a Unicode problem · Mathias Bynens

I have tried reading in the input as an array using […readline()], and only manipulating the array until printing out using .join(‘’), which I thought should work (it works fine with ‘standard’ characters).

If anyone completes this puzzle with javascript then some advice is needed!

(and please change the wording on the puzzle to save people time if they do not want to comit to a lengthy puzzle)

1 Like

See the function fromUTF8() there.

It worked! You are a gentleman sir!

I just did the Snake Encoding community puzzle and with the exact same code, I’m getting 75% at validation with Python and 100% with Python3.

I suspect the fourth validator might be including non-ascii chars, which some languages may not handle correctly out of the box. As a result one can have a correct algorithm, pass all IDE tests and fail one validator for a reason he will not easily be able to determine.

Would it be possible to fix this?

You suspect right : lots of people have been “complaining” on the chat about this problem and have been solving it by switching to UTF-8.

If not changing the validator, at least it would be a good thing to put the relevant test in the IDE and specify in the puzzle description that it is necessary to switch to UTF-8.

1 Like

Can you try again?

Works fine with Python now :+1:

Ok, following what you said, I think it would be reasonable removing the sentence: “The input text is composed of ASCII characters”.

Another problem is the sample code in C:

char LINE[21];
fgets(LINE, 21, stdin);
// this line will not read all characters if the problem uses 20 characters and the characters use more than 1 byte each one.

And, beyond that, setting a testcase with non-ASCII characters would be good, not only in the validation.

As the problem is presented now, the major puzzle is to discover that only in the validation there is a problem that does not follow the constraints.

It’s July and the puzzle still states “The input text is composed of ASCII characters” while it’s true for all test cases and seemingly not for the last validator. Is there any reason why this hasn’t been changed?

I think I’ve changed it a while ago, I don’t remember exactly what I’ve changed but when I read the validator, I don’t see non-ASCII characters. I can read the input with scanf(“%s”, LINE) without trouble.

Maybe some who solved it can try without fromUTF8 to confirm?

I confirm that an old version which only had 75% due to ASCII issues now passes 100% :slight_smile:

Many thanks for your replies!

Finally, my problem wasn’t with ASCII, indeed.

I did just undersize the fgets:
fgets(map[i], 22, stdin); //Works
fgets(map[i], 21, stdin); //Doesn’t

Hi, using Javascript I’m having difficulty getting 100% in the validator for this one and just wanting to know:

  • are all the input characters correct and printing them as is should give 100% (i.e. the issue is how I’m arranging them)
  • or are the input characters incorrect and need to be converted/encoded to something else

Thanks,

At this time, all the input characters are correct.

  • danBhentschel

Thanks, I just got 100%… I was using RegExp to join my array and replace “,” with nothing to print the answer and this was the issue doh

My Test Cases finish with 100% success rate, but once I submit, none of the post submit validations are successful. Are there any other C# coders that managed to get a success on a submit validator? I tried setting the encoding to UTF-8, but then nothing works… Any ideas?