MIME Type puzzle discussion

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

1 Like

Im curious about the “Consideration of the case (upper or lower)” validation test case, because my solution passes the IDE test case with the same name, but the validation test fails for reasons unknown to me…


What does “Limit size in extensions” exactly mean? My program fails on this test and I have no idea why.
N.B. It passes the “Large dataset” test.


The specification states the maximum length of the extension.
That test probably has a longer than specified extension in it, you should truncate the length of the extension when parsing the MIME types!

What do you mean with “Duplicated MIME types” ? I don’t get it.


For the large dataset test, you’ll need an efficient algorithm to search for the proper MIME type for a large number of files. If you’re using arrays, you aren’t using the best container for efficiently searching for MIME types.

If you’re using C++ (my programming language of choice), I suggest that you use a map instead of an array. A map in C++ may be called an associative array, hash table, or dictionary in other languages.


Big thanks :slight_smile:

A map is an easy and efficient solution, which requires less work than yours ^_^. Moreover, what you’re proposing is actually a kind of tree map, thus a map :wink:

What do you mean with “limit size in filenames”?  I don’t need to use the filenames at all.
All 5 Test Case pass ok, but the final score is 95%


you should use a map, as described above :wink:
I think that the problem is that your program is too long to give an answer. But we can’t be sure as we don’t have the data set for the test.

Anyway, That was my problem too, and using a map resolved it :wink:

sure? If I make a pause of 400ms [ usleep(400) in PHP ] the test goes right, but if I pause for 500ms the test fails in  “Large dataset (300 pts)”. So I assume this is the checking for slow program.
“limit size in filenames” have no sense about program velocity check.

Please, any ideas on the “limit size in filenames” check?

The problem was the original input line suggested by the platform:
$FNAME = stream_get_line(STDIN, 256, “\n”);

the problem disappeared using this one:
$FNAME = stream_get_line(STDIN, 2560, “\n”);

1 Like

Hi! I am confused by Large dataset test. My script’s (I used bash) output is fully identical to given out.txt, but test fails. I can imagine only one problem - performance. Script executes more than 70 seconds…

UPD: Fixed it by the hash-tables solution.

Hi in javascript is something wrong with “Large dataset” test, I got fail without any error, on Console output after line 70 strangely appear this:




If the line with “…” is bothering you, as I said in another topic:

It also applies to the output stream so you can’t see the whole response with large dataset tests.

1 Like

I think that there is an issue in the test data set. For example, I see it fail on this last entry:


My code properly handles the fact there is a period with no extension following and it reports UNKOWN yet the test harness reports this is not correct. Makes no sense to me. Is it possible an issue in the Groovy/Java tests?

1 Like

The test report doesn’t tell you where the fail is exactly. Your last line is correct but one or several of other lines might be wrong.


Guys, make sure you make everything correct:

  • have a proper map of mime types (key / value, hash set, or both)
  • have a proper method of extracting extension from file. I forgot about digits and all mp3-s missed.
  • make sure performance is good (which is if you use hashset / generic dictionary)
1 Like

I presume your program fails on file extensions that have a length of 10 characters.

File extensions are composed of a maximum of 10 alphanumerical ASCII characters.
MIME types are composed of a maximum 50 alphanumerical and punctuation ASCII characters.
File names are composed of a maximum of 256 alphanumerical ASCII characters and dots (full stops).

If you are using a language that requires a 0 character to end a string, you must add that to the maximum length when reserving space.

There may be more than one extension that resolves to the same MIME type.

hi! how you did it?
i’m use BASH too
i can’t pass 2 puzzle with BIG DATA (MIME Type & Horse-racing Duals)
tried to use arr[key]=value and arr[]=key:value, but didn’t work
i get different steps_count every time in cycle