Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @Grarzyna,validated by @Adnane_Arharbi,@ishibashijun and @FredericLocquet.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @Grarzyna,validated by @Adnane_Arharbi,@ishibashijun and @FredericLocquet.
If you have any issues, feel free to ping them.
Hello, I have a problem with last testcase in C language. This testcase contains ābulletā (unicode character U+2022) as a frame so Iām using wide characters in all strings and functions. But I think there is some general problem with wide characters in CG IDE. To investigate this, Iāve tried this simple ārepeaterā:
int main(){
wchar_t text[100];
wscanf(L"%ls", text);
wprintf(L"%ls", text);
}
When I send in some ordinary string (e.g. āHelloā), it works correctly. But when I try this ābulletā character from the last testcase, it returns nothing. Can anyone help?
Itās a utf8 character, it ought to be fixed.
Problem solved: I have to call
setlocale(LC_ALL, āC.UTF-8ā);
at the beginning of my code. Iām new to wide chars. Thanks for quick answer.
Iād almost like to leave it as is, I learned a lot trying to solve it in C++.
I tried solving it in Ruby. The framed picture is frist created as an array of strings, then put out like this:
for i in 0..fh do
puts pic[i]
end
Weirdly, while this wasnāt a problem in other puzzles I solved in Ruby here, this time my console output shows the framed picture as it ought to look like, but then fails with:
Found:
#####End of line (\n)
Expected:
Nothing
I havenāt seen this kind of output before, and since it isnāt a Ruby error message, I wasnāt able to find anything useful using online search. Then I tried out appending .rstrip
to get rid of any superfluous \ns and the test succeeds even though the console now claims āundefined method `rstripā for nil:NilClass (NoMethodError)ā. Does anyone have any idea what is going on here?
EDIT: Okay, it works without error messages if I make the output with
for i in 0...(fh - 1) do
puts pic[i]
end
print pic[fh - 1]
but surely that canāt be the intended solution?
Your first loop is 0 to fh inclusive (2 dots) and prints pic[fh] which is past the end of your array and returns a nil (this is why you get the rstrip error as rstrip on the nil is undefined). puts with a nil just prints a blank line (which is the extra \n the server complains about).
Your second loop has 3 dots so doesnāt include the upper bound and works properly.
Oh wow, now I feel really stupid making such an obvious error. Thanks for your answer! Curious that the Ruby interpreter doesnāt throw an error when itās told to access something outside an arrayās boundsā¦
Nice exercise! Simple at the first steps, then quickly interesting and more complex, while solving a real problem, congratulations
Nice puzzle!
I get problems with the length of the image when I run the following code in java I get:
String line = in.nextLine(); // the ASCII art picture line by line
System.err.printf("%s -length: %d%n", line, line.length());
the result of the print is (Test 5)
ā¦@@ -length: 8
.@* ā¦@* -length: 10
ā¦@* .@* -length: 11
.@* ā¦@* -length: 10
.@@ā¦ -length: 17
the blanks are cut off at the end. or they donāt exist.
result for test 4 is correct:
o -length: 7
< _ -length: 7
()>() -length: 7
Thank you for reporting the issue. I have just fixed test 5.
Not so simple as it should be at the first read.
Nice one !!
Not easy as it looks. Cool puzzle