You can still do manual checks with strlen
before adding a value to your array. And same applies about type, with the is_string
function if you really need it.
make sure you use toLowerCase(), and store them in the beginning as toLowerCase, as if you do it in the for loop, youâre going to slow the program down, i.e fail.
Where can I see the test for checking Limit size in extensions? I print âUNKNOWNâ if length ext file > 10, but this not work. Test fail. All other test good.
Thank you so much! This sent me searching down the right path.
efficient algorythm? i was solving this puzzle in pascal, so i used ExtractFileExt(FNAME) from sysutils and AnsiIndexText(FNAME, EXT) from strutils
last procedure searches in array of strings, and my solution passed 100% of tests instantly
i didnât even bother myself with additional validation tests on submit, except those that are available in online ide window
I think this puzzle couldnât be solved in Matlab (no hash tableâŚ). I like the reference to âLes inconnusâ in the last test , I first though CodinGame was American.
Hi,I have questions :
1- in C , is it better to use linked list with hash table or arrays in this exercise ?Because i have issues with the last test
2-I donât understand why my code doesnât pass âLimit size in extensionsâ
Hi @Corneille_K,
Iâm using a map for the mime types and a list of strings to check if a map key exists.
@ronlobo , is it possible to do it in C ? iâm beginning the C++ and iâve vaguely heard about map , iâm not accustomed to that
@Corneille_K, pretty sure you can solve it in all available languages, my C time is a while ago, but an enum might come in handy to map the mime types.
I wrote my code in Java and used a HashMap for the key/value pair, but the last test fails LargeDataset containing about 9999 records or more fails at some point and I just cant figure out where is there anyway this can be debugged, please render your suggestions
I did my 100% in C++ with plain old std::map And with manual but correct back-dot-find in filenames.
I have made my solution in C++, it passes all the test cases successfully, but when I submit my solution, I got 90% with Consideration of the case (upper or lower) (100 pts) not being validated.
How could I know where I misdid in my solution ? itâs weird that the test cases donât coverage all the test conditions but the validation test do.
I had the same. I didnât see any problem with logic. The failed output this:
Fail
Found: âUâ
Expected: âiâ
Then by dividing number of files in half every time and replacing Q in the for cycle, got problematic entry: â.icoâ at i=20. And it was problem with the code borrowed from web as I had:
int dotPosition= FNAME.lastIndexOf(â.â);
if (dotPosition >0 ) {
but what needed to be there is:
if (dotPosition != -1 ) {
I had noticed that the MIME types should be left alone, i.e do not reset them all to lower or upper case.
ThanksâŚ
This solved it for me!!! Thanks Heaps.
Also solved âlimit size in extensionsâ at the same time! Kept thinking it was because extension was too long, but actually it was too short!
- javascript
My language is C#. Indeed (and obviously) using a Dictionary (map) instead of Lists will get you to pass the 5th test case (the large dataset). Also you might want to add the extensions (not needed for MIME types) in UPPER or lower in the dictionary so that you can use the ContainsKey(key) method later, when youâre searching for your file extension, where key would be your string file extension which you will use as the method parameter as ext.ToUpper() or .ToLower (in case your file has an extension) and not worry about UPPER or lower case letters at all.
Thanks to all for the tip on using the dictionary datatype. That was all I needed to finish this bad boy up. Thanks!
It is possible to pass all the tests with C, without using a map.
Someone else suggested that you should break out of the for loop that searches the array of extensions. This helps a lot.
Also, it is worth converting all the given extensions to lower case while reading them in.