MIME Type puzzle discussion


#282

I wonder the same. Did you find a solution?


#283

So i did a hash table now. Since there was the tag “Hash Table” i figured it is in fact the way to go. I have now a problem with “Limite size in filenames” i dont even know what that means. Do they mean to check if the filename is to long? And what should i do if it is to long?


#284

Try to test your code with a filename of maximum allowed size.
This might lead to some problems with the end-of-string handling in C.


#285

Hi, I was puzzled over “Process has timed out” error in large dataset test case, and then noticed that I included list library that I don`t need. When I excluded extra library from my program, large dataset suddenly become passed. Can somebody explain why program was failed before, and then become passed after excluding unused library?


#286

I am stuck with this puzzle in the last test but not because of a timeout problem. It looks like the tests expect an extension when it should not. Here is the output I have generated to explain my problem:

filename : anotherfiletest.zip
	ext: zip
	mimetype: application/zip
application/zip
filename : thisisanotherfilename.longextens
	ext: longextens
	mimetype: UNKNOWN
UNKNOWN
filename : iLowerCaseAndUpperCaseLetters.
	ext: 
	mimetype: UNKNOWN
UNKNOWN
Failure
Found: UNKNOWN
Expected: image/jpeg

As you can see in the last iteration, the filename do not have any extension so the mimetype is ‘UNKNOWN’ but the test expect ‘image/jpeg’.

I can not see where I am wrong given that I pass all the other tests.


#287

I can’t find your data in the test.
The three filenames you provide appear in this order at the very end and the expected result is zip unknown unknown as your program returns.


#288

This puzzle is cool!


#289

Hi everyone
My algorithm passed test 1, 2 and 4
What’s asked in test 3 ?
What’s “correct division of the extension” ?

Thanks for your help


#290

it means that every one of the following should be identified as ext:
.ext
xxx.ext
xxx…ext
xxx…ext


#291

ok thanks, now i’have understood.


#292

My code fails only at “Correct division of the extension” with this message:

Found: applicat…
Expected: UNKNOWN

I do not get why it fails because my last print is “UNKNOWN”. From debugging with stderr I also do not why it should fail. Can somebody help me please?


#293

Maybe the error is before your last UNKNOWN.


#294

"Limite size in filenames "Problem
anyone can help?


#295

Hi,
so i’m back here after what…4 years? and decided to finish this puzzle.
It works pretty well, except for the last test with big dataset. I got a “segmentation fault” arror at the line fgets(FNAME, 501, stdin); // One file name per line.
But this line is an automatical one. It’s the one supposed to get the text out of the file and give it to me; i shouldn’t have to touch it. My code is below that. I don’t think i should correct this “default code”, i mean it’s supposed to work since it’s given to us. Or am i wrong?


#296

Welcome back on CodinGame!

I’m not very familiar with C but after some tests, I understood that the issue in your code comes from this line:

char ExtFound[Q][501];

where Q = 9999

That’s too big. This could help: https://stackoverflow.com/questions/12552968/is-there-any-limitation-on-the-maximum-size-of-array-in-c

I’ll investigate why the console doesn’t show the correct line.

Good luck!


#297

Ok thanks. That’s probably why my teacher always tell me to use malloc XD
Meanwhile i’ve changed the fgets for a scanf, so i get rid of the last \n in the file name.

now, i just have to make it faster. It did past one time, but most of the time it stops after ~7000 mime types because it’s too long.
but something is weird here: When i’m doing the filename treatment to get back the extension and then look for this extension in the mimetype table, it takes longer than when i get every file extension, store them in an array, and then start another loop to compare with the mime types. I thought it should be faster with only one loop and not two. How can it not be?

EDIT: i got a 100% even if it doesn’t pass the large data set test; on the validation test, it works o_O


#298

“You are provided with a table which associates MIME types to file extensions.”

“If the extension for a given file can be found in the association table…”

I’m afraid I’m not seeing this table, what did I overlook?


#299

the association table is given to you as the input of the puzzle


#300

If that’s the case why does it expect “image/gif” as one of the outputs when that is not one of the MIME types mentioned in the input?


#301

Nevermind, I was looking at the example for the list for some reason.

I could just get it to read me the types that each test case has.

My oversight, thanks for the help.