MIME Type puzzle discussion

Those kind of puzzle require more than just the basic algorithm, “gotta go fast!” is the key point. I’m not fluent in shell scripting so I can only give you a general advices:

  • Break a for or while loop whenever you can. Those can really slow down your processing time
  • Try to limit action that takes a lot of time on large list: for and while but also sorting can be really long
  • Turn around your code completly once in a while to test different method. Sometimes you can find really improved way of doing things.

That’s all for my basic advices. Honestly MIME Type didn’t put me in a lot of trouble but horse racing dual did, don’t hesitate to go to the topic that speak about it: Horse racing dual topic

1 Like

Hi !
I’m passing everything except “Correct extension cropping” ! what does that mean ?!

Haven’t tried, but 257 also would work.

that’s right!!! 257 is enough to complete “Limite size in filenames (50 pts)”

Hi ! I have a problem with this puzzle. When my output is good, it write “Found: Nothing”, but if it something else, it write it. For example, for the first test, if I write “image/gif” It say “Found: Nothing”, and if I write “imgae/gif” it say “Found: im”. It does it even if I print it directly, without doing anything else.

What is your programming language? I don’t have any problem for that puzzle, and i just recheck my solution.

I’m programming in c

I did it also in C, please provide how did you print it

printf(“image/gif\n”);

I got it :smiley:

The expected output is:

image/gif
image/png
text/html

When you output “imgea/gif” it print that it waited for “ima” and you give it “img”.

BUT!

When you output “image/gif”, the program is waiting for the next line “image/png” so it said “Expected ‘i’ Got Nothing”

1 Like

Oh… Right… Thanks !!! :smiley:

I think validation is broken for this puzzle, just like for the ASCII Art puzzle.

3 Likes

You’re right, we are investigating the problem.

I think you should build a hash-table (during reading data) using file extensions as keys. THerefore selecting right mime-type will be quite fast.

Hello guys,

Just a hint for people using Python(2/3).
I just created a hash that associates extension to mime type. Despite that, i failed the large dataset test and file extension test. But thanks to the post of nickmaovich i realised that the problem came from the way i obtained the extension.
As i am a bit lazzy i used os.path.splitext method to get the file extension. This is a very convenient way but it takes time.
After coding my own way to get the extension i got a 100% score.
So be careful to python modules

Bye

Hi,
I make this game in PHP, and I can’t have the points for “Limite size in filenames”, but I don’t understand why.
I make the test of length, and if it’s too long, I answer “UNKNOW”.
Can you help me?
Thanks,

Romain

Do not use 257, u can use 258(as it works & clear all tests) as 257 is not working.

1 Like

Thanks! :slight_smile:

Hi i just spend few hours to figure out that my program made mistakes with files named like:
.txt
I took me so long because such files are only in this large test. So my question is to put one of those in shorter tests. Or implement something what would say where the mistake is, as I did :wink:

It’s great but how the hell I can do this in PHP? There are no restriction on variable I create, it does not have type and length, so I define array and populate it with values, it’s not like in Java, where I MUST say this variable will be String and length max of 10 characters. How to solve it in PHP?