Chuck Norris puzzle discussion


#65

chuck norrix


#66

Y wonder the same >=/, damn headache


#67

If you are using C++, bitset might help you.


#68

The validator stops at the first character that isn’t as expected and only shows the output so far. It’s not a “final space”, there is additional output after the space.


#69

OH my god! Thank you so much. Took me half a second to complete 100% after reading this! Thank you!


#70

I am not certain the expected output for Test No. 3 (the %) is correct.
According to the output, it expects a 1011010 to be NorrisEncoded, but the binary representation of % is 0100101. If I put it this way, it will look different

1011010
0100101

Rest of the tests pass, so I assume, that the expected result for % test is buggy.


#71

My code passes the 1st and 3rd tests, but 2 and 4 I get:
Process has timed out. This may mean that your solution is not optimized enough to handle some cases.

I didn’t think my code was that long, it just converts the ASCII text into their respective character code, then concatenates all of them into a binary string. I parse the binary string using a series of if-else statements to convert it to Chuck’s code. I’m guessing there’s a more efficient way to do this. Can somebody tell me what algorithm they used that worked?


#72

Can anyone please take a look at my code? It passes the first three tests, but the fourth test doesn’t work.

[EDIT: NO FULL CODE]


#73

There’s something weird with my code. First, i wrote it on codeblock (i’m working in C); works well. But when i copy it on CodinGame, it gave me 2 extra ‘0’ et the end -_-
I’ve managed to make it work, but i don’t understand: why? The code is the same! Where does thoses 00 comes from?

Still, the first step is done. For the second one, thought, i’m stuck with a segmentation fault. Since i’m not so good with sizes and segmentation, i’ll love to have you get a look at this, cause i really don’t see the problem:

    TUnaire[k+1]='\0';        //that was to kill the extra 0
    TailleTotale+=(k+1)*sizeof(char);  //TailleTotale=0 at the beginning of my code
    if(l==0){                             //it is the case 
        Total=malloc(TailleTotale);
        strncpy(Total, TUnaire, k); //SEGMENTATION FAULT! WHY?
    }
    else{  //i don't enter this case for now, but i guess it'll have the same problem
         Total=realloc(Total,TailleTotale);
         strcat(Total, TUnaire);
    }
    l++;
}
printf("%s\n", Total);

I really don’t get it. TUnaire is a char* which contain k+1 char, Total is an empty char* and i alloc it (k+1)*sizeof(char) space…Why the first one can’t copy in the second? I’ve even tried to copy only the first k characters of TUnaire, but that still don’t work.
Please help (


#75

It’s hard to say without seeing the full code, but:

Does k have a sensible value? Moreover, if TUnaire can contain k+1 chars as you wrote it, TUnaire[k+1] is one past the end of TUnaire[] (and it’s an error).

Check the return value of malloc (Total != NULL).

Either Total or TUnaire are not valid pointers, or k is negative or too large, or there is bug elsewhere in your code.


#76

why string.Length is not working in the IDE but is working in monodevelop IDE, I mean, I wrote the same code as did in monodevelop but in codingame IDE does not work, example :

  • monodevelop:

         while(index != binary.Length - 1 ){
    
      	index++;
      	n = binary.ElementAt (index);
      	if(n.Equals('1'))
      		Console.Write (binary.ElementAt (index));
    
      } 
    

it works, but it’s not in codingame IDE.


#77

i have a probel with the last test and i don’t know what’s wrong -___-
chuck norris’s msg is sooo strong xDD


#78

i have the same problem xD
i don’t know what’s wrong!! but when it came to “space” it give me a problem!
like 000 and expected 00 0


#79

i corrected my problem xD
thx me :v


#80

I got the same problem… How did you fix it?


#81

Pls help! :’(

My program gives what the site wait in the C test: 0 0 00 0000 0 00

But the program says:
Failure
Found:
Expected: Nothing

Why??? I do not add a space to the end of the result string. What did i do wrong? Pls help! :’(


#82

Maybe you are printing some extra char. Certify that you print only the answer and you can print a new line (\n) at end.


#83

No, i’m not. I asked for help in the chat, but we couldn’t figure it out. I sent them my code, one guy told me, it’s working, but in an other guy computer my code made the same error.

I tried solve the first one this way: echo(“0 0 00 0000 0 00\n”);
But it writes the same error:

Failure
Found: " "
Expected: Nothing


#84

This echo worked for me. If you want send me your code to test here.


#85
echo("0 0 00 0000 0 00\n");

This code works for me.

Check you php code, it has be exactly this:

<?php echo("0 0 00 0000 0 00\n");

No new line before the <?php, and don,'t use the ?>. This way you’ll be sure there’s no extra characters in the ouput.