MIME Type puzzle discussion


The stub now uses 256 instead of 50 to match the dataset


The test is not correct in the sense that filename “.pdf” has no extension at all - in Unix-like OSes it is a dot file, a hidden one. So in the D programming language its standard library function “extension” returns that “.pdf” file has no extension but this test expected it has “.pdf” extension. It would be better if you fix this I guess.


Although in real situation you are right the statement is clear

The extension of a file is defined as the substring which follows the last occurrence, if any, of the dot character within the file name

So the test case is respecting the rules.


Well, that’s true too


Same issue with C++


outputs an empty string.

I understand it doesn’t align with the test/game requirements, but they really shouldn’t be punishing best practice…


best practice does not matter here. it is a puzzle.

i may be wrong, i should be right but …
you have to code your own solution. the objective in not to find the already existing function to solve it.

i screamed enough against levenshtein puzzle because it is solvable in one line in some languages when the challenge/objective should be the same for all.


5 тест валится через раз.
решение стандартное на мапе.

Так что, если у вас завалится на пятом, то пробуйте ещё и ещё…


According to Google traduction:

5 test falls through time.
The solution is standard on the map.

So if you fall on the fifth, then try again and again …


Feedback: It would be nice if it was mentioned somewhere that ALL the output will be written, and not (like in other puzzles?) be stopped at a failing line.



at abort.c. function __GI_abort () on line 79

at Answer.cpp. function main () on line 81

Here is my Code

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
int total=0;

struct mime 
    string key,value;
    int hashkey;

struct mime *item;
struct mime *hasharray[10000];

void insert(string key, string value)
    struct mime *item=(struct mime *)malloc(sizeof(struct mime));
   // cout << hasharray[total]->key << " " << hasharray[total]->value << endl;
void search(string str)
    int num=0,flag=0;
    string ans;

int main()
    int N; // Number of elements which make up the association table.
    cin >> N; cin.ignore();
    int Q; // Number Q of file names to be analyzed.
    cin >> Q; cin.ignore();
    for (int i = 0; i < N; i++) {
        string EXT; // file extension
        string MT; // MIME type.
        cin >> EXT >> MT; cin.ignore();
    string str;
    for (int i = 0; i < Q; i++) {
        string FNAME;
        getline(cin, FNAME); // One file name per line.
        int k=0;
                                                                         //LINE 79
        str=FNAME.substr(k,FNAME.length());   //LINE 81


Please explain what’s wrong and what can be done


Can anyone show me how to optimize this c#? I pass every case besides large data set. Is it possible to show all my code?

// loop through file names
            // files dictionary consists of Key = filename, value = List [0] = boolean
            // if checked already and [1] MIME Type
            // dict consists of key = extension and value = mime type
            foreach(KeyValuePair<string,List<object>> entry in files) {
                // loop through MIME types
                string ext = Path.GetExtension(entry.Key);
                ext = ext.ToLower();
                foreach(var key in dict.Keys)
                    // do something with key
                    if(key.ToLower() == ext) {
                        entry.Value[0] = true;
                        entry.Value[1] = dict[key]; 
                // loop through MIME types
                if((bool)entry.Value[0] == true) {
                } else {


I’ve just noticed: this puzzle’s example doesn’t match the first test case. This is rather confusing, as all non-legacy I/O puzzles (who are now a majority) do match. Could this be fixed by some [CG]Rando with appropriate access rights?



Just for this reference, i put 5 stars ! :rofl:


Continuing the discussion from MIME Type puzzle discussion:

PHP Auto generated code is wrong for this. It puts a limit of 50 characters for the test cases. It was quite annoying going through and debugging something that should work out of the box.