MIME Type puzzle discussion


In the PHP version, the auto generated input-parser skeleton code is wrong.
$FNAME = stream_get_line(STDIN, 55 + 1, “\n”); // One file name per line.
It should have 256 instead of 55. The large dataset validator fails with 55.

It cost me lots of extra time to find this bug - I thought my code was buggy while it was fine and the provided code was the faulty…


Thank you man !
I’m new to c# and coudn’t find a solution to beat that final test !
Dictionnary saved the day.


I passed all test cases in C but I do not understand what is needed to validate limit sizes in extensions and filenames. I validated limit size in MIME types but I did not do something in particular.


Hi everyone !

I’m trying to do this challenge but there is a problem with my output stream… When I write “UNKNOWN” in the output stream, the only answer that the challenge find from me is “Nothing” although the output stream show me there is indeed a “UNKNOWN” printed… Has anybody already met this issue ?
(I use Python3.)

Thanks for you reply !


Are you sure the UNKNOWN is on the output stream? Did you maybe print it on the error stream instead while debugging?


@DanielLeidenheimer if you are failing “upper to lower” and nothing else, you’re almost there of course. just make sure your dictionary and file_extension are BOTH in the same case.


</Bash coding/>
I’m really stuck on “large dataset” test :frowning_face:

i use associated Map with EXT : EXT_MIME[${EXT}]=$MT
(EXT in lowercase if i found upper case : [[ “$EXT” == [[:upper:]] ]])

when reading the entry files (For Loop) i try to minimize all commands…as explained by some fellows in this thread.

i use “continue” when needed
“When used in a for loop, the controlling variable takes on the value of the next element in the list.”

check dot on filenames : Dot=expr index $FNAME "."
if [ Dot -eq 0 ] so UNKNOWN ; continue
retrieve the file extension : FNAME_EXT=""${FNAME##*.}""
check if the EXTension is Empty : [ -z ${FNAME_EXT} ]
(if FANME_EXT in lowercase if i found upper case : [[ “$FNAME_EXT” == [[:upper:]] ]])
if the case so UNKNOWN ; continue
check if the MAP retrieve a MIME Type : [ -z “${EXT_MIME[${FNAME_EXT}]}”
if not the case so UNKNOWN ; continue
retrieve the right MIME Type

i have only 47 lines of code.


j’ai un petit problème sur le puzzle MIME type au niveau facile.
Lors du 5eme test (grand volume de données), sur le deuxième fichier (‘marcelpatulaccibrigadierchefmaisgardiendelapaixavan’), je renvoie ‘UNKNOWN’ et le validator attendait ‘image/jpeg’. Il n’y a pas d’extension …
je ne comprends pas.
Par avance merci pour votre aide
bien cordialement


finalement j’ai trouvé en regardant dans le forum. Mon code n’était pas faux, c’était juste le ‘stream_get_line’ en PHP qui était mal configuré et qui ne prenait que 55 caractères au lieu de 256. Donc le $FNAME du skeleton était tronqué…


Hi everybody, I’m new in the CodinGame community. I am trying to solve the MIME puzzle, and I was able to get a success using simple arrays, except for the “Large data” challenge which I cannot succeed…
I have tried to use hashtable or dictionnary to speed up the process, but everytime I try to create such table, I get the following error message “error VBNC30451: ‘Dictionary’ is not declared. It may be inaccessible due to its protection level.”.

Would anyone know how to solve this issue ? I am using VB.NET FYI


It seems there are missing “Imports System.Collections.Generic”


Great that worked ! Thanks a lot man, I struggled for several hours today trying to understand why I could not declare a dictionary ! I’ll remember that


Same problem… I am trying to optimize the search, everything else seems to work…


I’m stuck on this large dataset with bash:

  • I’m stocking $MT value in files named mime_$EXT
  • Im getting the extension with a echo $FNAME | awk
  • then if statement on existing or not the corresponding mime_$EXT and do a cat on it or echo ‘UNKNOWN’

How can I speed up this ? Without using files ?


I did 8/10 and can’t solve
Detection of same prefix extensions
Duplicated MIME types
How to solve it?


That was my problem exactly the error was like 6 lines back on fname=‘pdf’. Sure makes debugging super unintuitive.


increase array size limit to limit sizes +2( as per the rules ). Should need only +1 but it only worked with +2


Hello, i have passed all the tests, except one “Limite size in filenames”. I don’t really get it, since the “Limit size in extensions” and “Limit size in MIME types” passed with no problem, i didn’t change what is given in the program (e.g., 51). Also, in the Constraints, the is this “File names are composed of a maximum of 256 alphanumerical ASCII characters and dots (full stops).”, but in the program, i only see 51. Any help please.


i checked the puzzle and there’s a problem with the stub generator…

constraint says 256 but the starting code tells
$FNAME = stream_get_line(STDIN, 50 + 1, "\n"); // One file name per line.
instead of
$FNAME = stream_get_line(STDIN, 256 + 1, "\n"); // One file name per line.

I don’t know in which language you are coding but you just have to adjust to read the right number of character.

Strange that i didn’t notice that 5 years ago when i solved it :slight_smile:


Thank you, it’s done, but still got the same problem. Do i need to check if a file name is less or more than 256 ? if it’s more, it considered UNKNOWN ?