The “expected” result has an extra space at the end, but the sample result out.txt file doesn’t. Is this a problem with the auto-grader, or am I doing something silly here?
I have a problem. I convert the letter “h”, which is 104 in decimal, so 1101000 in binary and i did that with the “biset” function. So from my string “1101000”, i try to take every character and convert it to integer and build an array. The problem is that when i do that, the row from array is always 1101001, so it changes my last bit from 0 to 1. If i try to change manually the bit back to 0, it changes the first bit of the next letter, “u”. What should i do?
This is what i am doing, like this:
x=104
for (j = 0;j<7;j++)
a[i][j] = x%2;
x=x/2;
And it sets the row from array a as 1101000, so a[i][6] = 0. But after i complete array a with all the rows, a[i][6] becomes 1, so the row is 1101001.
function binstr(val : longint; cnt : byte) : shortstring;
var
i : longint;
begin
binstr[0] := char(cnt);
for i := cnt downto 1 do
begin
binstr[i] := char(48 + val and 1);
val := val shr 1;
end;
end;
Hi guys, I’m doing this puzzle in C# and so far 3/4 test pass, the only failing test is the last one: Found: "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 000" 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 "
Here is the binary value I translate: 100001111010001110101110001111010111000001001110110111111100101110010110100111100111001111000001101011110010111110011100010110111111000011110010110010010000011010001100001111001110000011001010000011010111100101111100111100111110101000001100001000001100001110111011001001000001110111110100011010011110100110010110000011100111110000110000111000111100101101110
This was the actual issue: I added “0” at the beginning of the whole string if string % 7 != 0. To pass the test I actually had to do it on each char (which makes more sense), so thank you!
Hey guys. I have a question. Is there a possibility that there is something wrong with this C++ compiler?
I’ve resolved it in VisualStudio, and i got the exactly same results as needed. But when I used the exactly same code here, there is an error.
Make sure you are adding leading zeros to ALL bytes that are less than 7 bits. In Java, I made strings out of each byte and then added leading zeros to the string while length % 7 != 0.