Unary - puzzle discussion

I have a problem with last test statement: Message from Chuck Norris.
This is my output and expected output:
Your output: 0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00 000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 00000 0 0 00 00 0 000 00 0 0 00 00 0 0 0000000 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 00 00 0 0 0 00 00 0 0000 00 00 0 00 00 0 0 0 00 00 0 000 00 0 0 0 00 00000 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 00000 00 00 0 000 00 000 0 0 00 0 0 00 00 0 0 000000 00 0000 0 0000 00 00 0 0 00 0 0 00 00 00 0 0 00 000 0 0 00 00000 0 00 00 0 0 0 00 000 0 00 00 0000 0 0000 00 00 0 00 00 0 0 0 00 000000 0 00 00 00 0 0 00 00 0 0 00 00000 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 00000 00 00 0 0000 00 00 0 00 00 0 0 000 00 0 0 0 00 00 0 0 00 000000 0 00 00 00000 0 0 00 00000 0 00 00 0000 0 000 00 0 0 000 00 0 0 00 00 00 0 0 00 000 0 0 00 00000 0 000 00 0 0 00000 00 0 0 0 00 000 0 00 00 0 0 0 00 00 0 0000 00 0 0 0 00 00 0 00 00 00 0 0 00 0 0 0 00 0 0 0 00 00000 0 000 00 00 0 00000 00 0000 0 00 00 0000 0 000 00 000 0 0000 00 00 0 0 00 0 0 0 00 0 0 0 00 0 0 000 00 0
Expected : 0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00 000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 0000 00 0 0 0 00 00 0 000 00 0 0 00 00 0 0 0000 0 000 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 00 00 0 0 0 00 00 0 0000 00 00 0 00 00 0 0 0 00 00 0 000 00 0 0 0 00 0000 00 0 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 0000 0 0 00 00 0 000 00 000 0 0 00 0 0 00 00 0 0 0000 0 00 00 0000 0 0000 00 00 0 0 00 0 0 00 00 00 0 0 00 000 0 0 00 0000 00 0 0 00 00 0 0 0 00 000 0 00 00 0000 0 0000 00 00 0 00 00 0 0 0 00 0000 00 00 0 00 00 00 0 0 00 00 0 0 00 0000 00 0 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 0000 0 0 00 00 0 0000 00 00 0 00 00 0 0 000 00 0 0 0 00 00 0 0 00 0000 00 00 0 00 00 0000 00 0 0 0 00 0000 00 0 0 00 00 0000 0 000 00 0 0 000 00 0 0 00 00 00 0 0 00 000 0 0 00 0000 00 0 0 000 00 0 0 0000 0 0 00 0 0 0 00 000 0 00 00 0 0 0 00 00 0 0000 00 0 0 0 00 00 0 00 00 00 0 0 00 0 0 0 00 0 0 0 00 0000 00 0 0 000 00 00 0 0000 0 0 00 0000 0 00 00 0000 0 000 00 000 0 0000 00 00 0 0 00 0 0 0 00 0 0 0 00 0 0 000 00 0

But in console the following is printed:

Failure
Found:
"0 0 00 0000 0 0000 00 0 0 0 00 ā€¦0 00 0 0 000 00000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 0000 "
Expected:
ā€œ0 0 00 0000 0 0000 00 0 0 0 00 ā€¦0 00 0 0 000 00000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 00000ā€

As seen the sequence in console ā€œExpectedā€ is different than actual expected sequence as there appears 3 zeros and 5 zeros and that makes no sense.

My source code is this:

[ NO FULL SOURCE PLEASE ]

I know that the source has some problems that need to be resolved, but the console output is having problems.

Huh. I donā€™t get the same thing:

Not that this is particularly helpful, but itā€™s at least not blatantly wrong, like the example you posted.

  • danBhentschel

The checker tests your output one character at a time and stops once it finds something wrong. What youā€™re seeing is the expected value, truncated at the point where the mistake occurred. Thatā€™s why it doesnā€™t match the actual expected value shown.

Just wanted to let you know what kept me stumbling around.

  • random outputs in the console, even with result success
  • an impossible expected output like 0 0 00 000 0000

it was, because i didnā€™t fill up the space left of chars, that are only 6bit in binary.
First I asked myself, why would I have to put something there, it makes the output incorrect, because I just decided to fill it up with a value - but it makes sense, because you need to know how many bits on char is, when you want to be able to decode it again.

cheers

1 Like

Yo, how do make the message to work

Hello !

I have a problem in the ā€œCCā€ part.
I succeed creating the code, I have the good result but the console donā€™t validate my answer.

u.U thatā€™s very unfair !


Sortie standard :

0 0 00 0000 0 000 00 0000 0 00
0 0 00 0000 0 000 00 0000 0 00

CC vaut donc : 0 0 00 0000 0 000 00 0000 0 00

trailing space at the end?

Hi _CG_Thibaud

It seems that there is no space at the end.There is no space in my appends (excepting enter two zero) and I just did a join with space.

(I did the first question with the same method)

Same here.

It saying itā€™s found ā€˜Nothingā€™ when Iā€™m outputting it using System.out.print (In Java). I get the correct output as well.
Standard Output Stream:
0 0 00 0000 0
Failure
Found: Nothing
Expected: 0 0 00 0000 0 0

Iā€™m new to this site so probably missing something obviousā€¦

Please check that you are not printing an empty string before printing your final print.
In python I reproduce your error by adding a line with print() before printing my answer, or by printing a single ā€˜\nā€™ before my answer.

Good idea but I donā€™t seem to be. Here is my full code:
[No full code please]
(Yeah itā€™s probably not a great solution :P)

I got the problem too.

36 bits in on chuckā€™s message itā€™s interpreting 3 1ā€™s as only 2. My program is correct but the test is wrong. Anyone experienced this? Canā€™t complete the puzzle.

Failure
Found:  0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00000 0 0000 00 0 0 0 00 
0 0 000
Expected:  0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00000 0 0000 00 0 0 0 
00 0 0 00 

The raw input for his code (up until this point) is:

100001111010001110101110001111010111

My issue is at the end:

111 == 0 000
111 != 0 00

Not really sure what to do anymore considering Iā€™ve manually written out the solution for this portion and my program is correct from what I can calculate. I must be missing something.

1 Like

The error is not at the end of your string, itā€™s in the middle.

Keep in mind that the referee does not show you the entire output string. It looks through your answer character-by-character until it finds a mistake, at which point it stops and shows you the output you had up until that point. The expected answer is much longer.

You can view the expected output by selecting Expert mode in settings and clicking on the 3 horizontal lines icon.

2 Likes

Hi, thanks for the reply.

Yes I understand that this is only a portion of the expected output. Iā€™m just not sure why at this point itā€™s incorrect. The last three characters ā€˜111ā€™ are equal to 0 000, not 0 00.

1 Like

Your output looks incorrect to me. Hereā€™s my interpretation of it:

0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00000 0 0000 00 0 0 0 00 0 0 000
  1    0000   1111    0   1    000   111    0   1    0   111 ?????   1111    0   1    0   111
  • danBhentschel

can someone help me the console output keep saying i output nth in the % test case and the message from chuck that one but the previous is success

I suspect that was an mistake in the cut-and paste, since the referee was also looking for those numbersā€¦ should have been 00 000, according to the test casesā€¦

Squidward, I ran my old code in C#, javascript, and C and got the same as the referee wanted. Youā€™ve got a logic error somewhere.

Hello there,
Can someone help with the last test?.. everything worked fine but the message from chuck always show me that there is a mistakeā€¦
but i canā€™t find the problemā€¦(i use java)

    String answer = "";
    String output = "";
    
    char[] messChar = MESSAGE.toCharArray();
    
    for(int i = 0; i<messChar.length; i++){
        if(messChar[i]==' ')
            answer +=" ";
        else
            answer +=Integer.toBinaryString(messChar[i]);
        
        if(answer.length()!=7){
        int missing = 7-answer.length();
        for(int j = 0; j<missing; j++){
            answer = "0" + answer;
        }
        }
    }
    
    char[] answerChar = answer.toCharArray();
    int zero = 2;
    for(int i = 0;i<answerChar.length;i++){
        
        if(answerChar[i] =='0'){
            if(zero!=0){
                if(i>0)
                    output += " ";
                output += "00 ";
            }
            output += "0";
            zero = 0;
        }
        else if(answerChar[i] =='1'){
            if(zero!=1){
                if(i>0)
                    output += " ";
                output +="0 ";
                
            }
            output += "0";    
            zero = 1;
        }
        else
            output+= " ";
        
            
        
    }
    // Write an action using System.out.println()
    // To debug: System.err.println("Debug messages...");

    System.out.println(output);