MIME Type puzzle discussion

A test case ending with a point is missing

no not missing … in test 5 :

b..
b.
a.
info..

and many others

Are those before the point valid extensions?

this is the 3rd test case:
image
“.mp3” is not given in input, “.mp3.” is

@Raphiros I’m sure this thread is full of useful advice.

1 Like

I see, I was splitting the inputs on the ’ . ’ character, and my usage of the .split("\.") (Java) function trimmed the last point. Using .split("\.", -1) solved the problem.

Thank you very much! :heart:

1 Like

This * MIME type * is generally deduced from the extension of the file to be transferred.

NO !!!

You must use the first bunch of bytes of the file to detect the MIME type.

1 Like

Continuing the discussion from MIME Type puzzle discussion:

Hello, I have an issue in this puzzle in Rust. With the large dataset, I failed but cannot understand why. It seems that I missed the txt in my hastable. But when I search for the given example I cannot found them in the dataset so how would I know if the txt extension is in it?


Thanks

Ok found, I passed some extension in uppercase, solved :wink:

Hi,
Are there any restrictions with dynamic allocations or can I do as I wish ?
I have some errors but before fixing them I would like to know if these allocations are supported.
thx…

Hey,
I’m facing some issues with my C code. It works perfectly fine on my own computer, but on the codingames site it doesn’t. The problem appears to be a “Process has timed out. This may mean that your solution is not optimized enough to handle some cases.”-error. However, if I copy the same code to the objective-C section (on the website) it is much slower, but it doesn’t time-out and I get 100%.

Can anyone explain to me how they calculate the time-out? Or do they change the time-out time depending on the language and therefore objective-C is allowed to consume more time than C?

Another issue I faced was the “Limit size in filenames”, but I somehow fixed it by allocating a larger array for the filenames. I don’t think, that it was the intended way, but it works.

EDITED:

There’s some issue with C++ and C making the prints last longer than they should. However, some players manage to pass the tests. With a few performance improvements, you should be able to pass all of them too.

Meanwhile, we’ll look into the abnormally long prints.

1 Like

This puzzle seems to be broken now, solutions which worked 4 years ago now no longer pass test 4 - the large one, claiming a timeout

Not sure that the age of the solution is in cause. I rewritten a cleaner solution 2 months ago (My first one is 5 years old), and testing it after reading your post, I got a timeout too. But comparing my output to the waited one, I seen they were the sames… And when I relaunched the test, it passed…

I had the same “problem” as fly (cf this post) : all 5 test case OK, but 95% to validators because of failure to validator 09 “limit size in filenames” (“09 Taille limite dans les noms de fichiers” in french version).
fly gives the solution in this post : increasing the size from 256 to 2560 make all validators OK.
Such an increasing is unecessary.
In C language, 258 is enough.
In statements, one said that length of filenames is 256 or less, so in C, 257 should be enough (with terminal null byte).
But, every filename end with a newline characters \n, so 258 is necessary (and sufficient):
— 256 byte to store the filename,
— 1 byte to store the ending \n,
— 1 byte to store the terminal null byte.
A correction should be done to the statement: if you follow the statement, there is no problem for language as Python, but in C, where you need to allocate memory, if you allocate exactly what is needed (257 bytes), validator 9 does not pass.

Hello,
I did this using dictionaries in Python and was kind of straight-forward.
Then I tried it in C++. I thought that like with the other puzzles that I’m doing in both languages, “translating” the same algorithm but using the language tools, it’ll be quick. My mistake.
It took longer than I though, because even if using the libraries with the information of how to split a string, or use a dictionary (map), that I never used before, applying the concepts was not easy, but it worked… for the first 4th tests (with some little modifications).
I got stuck with the 5th test (Large dataset), so I tried to make the program more efficient, reducing not necessary operations (like keeping the name of the file, etc.) but anyway I was receiving the message of " Failure: Process has timed out. This may mean that your solution is not optimized enough to handle some cases.".
Surprisingly, after a lot of tries, and frustration, I took a pause. I came at the discussion forum, read some posts and then I came back to the puzzle page.
I swear I did nothing to the code, I just clicked the 5th test again… and it passed!
I submitted my code and received 100% score, then I clicked again, and I received the Failure error…

Hello,
I am coding in Javascript

My code passes all the solutions but the “limit size in extension” validator. Anyone would know what it is about ? I read all of the solution in this thread but could not find anything that worked for me…
My code checks for filenames that end with “.” and filnames with just the extensions (example : “.html”). as well as filnames without any dots present.
It looks at a filname and reads the characters following the last “.” to extract the file extension.
I tried checking for length of the file extension but it did not change anything.
I don’t get what I am missing here, can anyone help me ?
thank you

The different “limit” validators are more for languages like C that have character strings of fixed sizes. You don’t have to handle the size limits cause no out of limit extension will be sent to your code.
So you probably have a specific case not handled by your code and which only appears in this validator, but unconnected to its title.

1 Like

Oh I see, thank you for your answer !

So there is a specific case in this validator that fails my code but there is no way for me to know which one it is right ? that’s a bit annoying…

If anyone knows what I am missing here is what my code does:

Take the file extensions and the associated MIME type and put them in separated arrays.
Find the last dot in the FileName (returns UNKNOWN if there is no dots)
take all the characters (the extension) after the last dots and put them in a variable (returns UNKNOWN if there are no characters after the dot)
Turn the variable with the extension into a regular expression that is not case sensitive
Check if the Regexp has a match in the array with the file extensions (returns UNKNOWN if no match is found)
return the index of that match
return the content of the array with MIME types at the same index

and repeat for all the filenames

Thank you all

I’m not sure that regex is the simplest way to solve this puzzle, but why not. ^^
Are you sure of your regex generation ?

This puzzle is definetly inconsistent with it’s Time outs. I wanted to implement a hash map on my own and I was stuck on this puzzle for three days because of the last test. I had multiple instances when the Large Dataset passed and then without any changes it failed immediatly after. One time it failed on a “clean” solution and then passed when I uncommented some helper debugging functions that iterated thru the whole data structure and printed a lot of stuff, definetly slowing the program down.
In the end I found a slight workaround for C++: instead of using cout to output line by line while the program runs you can store all of the output messages into a stringstream and then at the end of the program use cout just once to print it all. This saves enough time to get pass the Large Dataset, maybe someone struggling finds this usefull.