MIME Type puzzle discussion

Using Python, correct extension cropping keeps failing. It fails on ‘.mp3’, where ‘audio/mpeg’ is returned. If I hard code this scenario to return ‘UNKNOWN’, the test passes. However, the hard-coded value fails during the next test case. Is this a bug?

I’m failing the Correct Division of Extension test but can’t figure out why. I fail on the a.wav filename. My output is “audio/x-wav” but the error says it’s expecting “U”, so UNKNOWN. I’ve re-read the rules and I don’t see any reason I should be discarding a.wav. Anyone know why this isn’t a valid filename?

x-wav != x.wav ?

[Ruby] [Case]
The tests cases are expecting me to provide MIME sometimes in uppercase, sometimes in lowercase.
example:
1./ Extension detection test wants me to output ‘image/TIFF’, all other MIME types being lowercase
2./ Last test wants me to output ‘image/tiff’ for the same extension in input file!!!
Is that a bug or am I missing something?

Language: Python

So… I have a very simple code structure so far:

  1. Create mime_type dictionary with ‘ext’ and ‘mt’ as mime_type[ext]=mt
  2. For each fname isolate ‘extension’ using .split() and .lower()
  3. Then loop over key, value in mime_type.items():
  • if key == extension --> print value
  • else: print UNKNOWN

I tested that calling extension, mime_type, etc prints out the expected outputs to the console, however running the full code returns “UNKONWN” for the test.

Could anyone give me a hint of what would be the next steps please?

I got 100% for this problem, but didn’t get the achievements… Is this a known issue? How do I fix it?

Same issues here , its weird

Can someone tell my, why this code don’t pass 3 case Correct division of the extension?

[full code removed]

You can see the test cases with their expected outputs by clicking on the upper right corner of the “Test cases” frame.
That being said, you can check if your code properly handles file names without extension (without dot).

Thx. Problem Solved.

Hello everybody,
I am failing in the Correct division of the extension and Consideration of case (Upper or Lower) . I tried using the function toLowerCase() to convert everything into lowercase but that did not help. For the first case of extension, I am failing in the filename without extension.

        int ext = FNAME.lastIndexOf(".");
        String extension="";
        String extension1="";
        if(ext==FNAME.length()){
        	extension = null; 
        	System.out.println("UNKNOWN");
        }
        else if(ext<0){
        	System.out.println("UNKNOWN");
        }
        else{
        	extension = FNAME.substring(ext+1);
        }

(I use Javascript) Sorry for that newbie question but im stuck:
My code works fine but for whatever reason the the puzzle doesnt detect my "UNKNOWN "output.

For testing i printed (“UNKNOWn”) and it said:

found: UNKNOWn
Expected: UNKNOWN

if i print exactly that it says

found: Nothing
expected: UNKNOWN

help? Is this my fault or some error in the puzzle for not detecting the correct output?

Try using a counter to print debug messages in a range. You can use a binary search to narrow down the range where the failure occurs. Unfortunately, the error stream is not normally interleaved with the stdout stream. (I haven’t tried any tricks to fix this.)

I had exactly same results on java.Cant figure out why

@Archia @Proxycon I have something like this in Java:

if (output == null) {
       output= "UNKNOWN";
 }
 System.out.println(output);

You can PM me with your code if you want.

Ok, I got the solution. I wrote it in java
You need to make a Map<String,String>, and store the extentions both in LowerCase, and Uppercase.

1 Like

You can PM me with your code if you want.

feeling kind of dump now but i couln’t figure out how to PM…
short instruction?

click on my username, then message

Same issue, did you ever figure it out? I use one loop to make a hash set and then another loop to process the extensions, so it should have pretty good performance with no nested loops but nope, still fails.

@SalmanLashkarara No need to double the size of the map - if you only store one case (upper or lower, it doesn’t matter) and convert the extension of the filenames to that same case before comparison, you avoid storing duplicate data in the map