6 kyu
Block Letter Printer
355 of 744Galvlbit
Loading description...
Strings
ASCII Art
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Java
My code works in my IDE (IntelliJ), but when I test it here there's a wrong output. The code was definitely same for both, yet produced different outputs.
The word at which problem has occured is "same".
Has anyone got the same problem?
Please try again, I was refactoring the kata in Java some minutes ago. Just to be sure that this didn't cause your problem...
It worked. Thank you
This comment has been hidden.
Python should have an explicit
from preloaded import alpha
in the solution setup.Resolved. Thanx a lot for the Scala translation! I learned a lot from your test code refactoring and adjusted the Python tests to display better debugging information. The only thing I couldn't get right is that I couldn't suppress/replace the standard output of pythons codewars_test suite. It is always appended to my custom error/debugging messages.
I think you can
test.fail
to get only a custom message.Fork which omits the codewars_test message
That's much better! Thanx again! :-)
No worries.
Scala translation
Approved by someone
What does this specific part mean ? There's a preloaded dictionary called alpha which you can use. Keys are lower case letters and the space.
Apologies in advance for this begginer question, but I'm new to codewars, and coding in general, so I'm not sure what this specific part is refering to.
I've tried creating my own dictionary of keys which are the letters, and values that are the coresponding letter from the example on this kata's expected shapes to be printed. However, I'm seeing some very bad outputs, and I'm not sure if the problem lies with my dictionary, and I should have used the one mentioned in this kata, or if the problem is my lack of experience with Python, therefore I wanted to make sure I use the same thing mentioned in this kata to rule out the possibility that the problem is tied to the dictionary I've created.
That section means that you can just use the dictionary called
alpha
. You don't have to populate it by hand, which is tedious.alpha
looks like this:As for why your code doesn't work, debug and find out ;) You can
print
intermediate results to better understand what's wrong.Thank you very much for your answer! You helped me realize that the 'built in dictionary' you are refering to, is included in this kata's test/attempt section (yes, that's how noobish I am)... Apologies again for my silly question, I'm still learning navigation on this site.
Answered by avermakov.
Well done...
It seems that some languages do not have a preloaded map (at least, they are not mentionned in the description):
that's true, and I don't consider it an issue.
I simply wasn't able to add it, so that it'd work in those languages. Feel free to do it yourself
It's an issue because it makes the language versions unequal. Either provide it for none, or all.
here is a fork adding one to Java
and in Ruby you just need to rename the variable.
alpha
is a local variable and is not exported;ALPHA
(a constant) or$alpha
(a global) willOMG. it seems I'm too stupid to merge your improvements to the kata. I approved your Java fork, but it simply doesn't show up in the kata. I still struggle with some aspects of codewars. I'd copypaste your improvements, but fear that acknowledgement of your colaboration would vanish then?
Thank you for your help!
In that case I am not sure what happened. Perhaps you erased the changes if you approved the kata while you had the editor open to modify the Ruby version.
Feel free to copy paste the changes directly into the editor.
Lastly, to use a preloaded variable in Rust you will need to declare it in the initial code:
And also make sure to make
alpha
public (keywordpub
) in Preloaded.I've fixed the Rust version
For future reference:
mod preloaded
belongs in the tests section, not the user solution. Static and constant values should be UPPERCASE (also in Python, but I'm not dealing with that). Non-const values (such as HashMaps, which require allocation) need wrapping in alazy_static
. It's a bit tedious.Note that when I solved this in Python, I didn't even see the mention of the preloaded map, and created my own. Wasn't that much of a hassle, and I preferred a different layout anyway.
Is it really necessary to have a code block in the description for each language just to say 'when passed to {your language's printing function}, the result should look like ... ' ? Why not just say "it should look like the following when printed" ?
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
(Python)
Can I suggest the dictionary in preloaded is mentioned somewhere in the description?
The third sentence in the kata states: "There's a preloaded dictionary called alpha which you can use. Keys are lower case letters and the space."
Sorry, totally didn't see that, even after searching for mention of it (after solving it without).
Perhaps it could be highlighted in some way?
Rust Version
I see someone had a similar trouble in the past. Maybe the last fix didn't work?
Thank you, I think I fixed it now. The random tests import the HashMap themselves.
Thanks! Can confirm it's resolved for me.
<<C++ version>> IMHO a bunch of data massaging (heading and trailing spaces in entry string, end of line management, ...) thus a :-( eval
I wonder whether it is possible to change the kata so that user experience is more positive? It would be easy to strive off the "data massaging", like trimming the output string, be it for spaces or end-of-line chars. I'm not sure about the consequences: wouldn't that render all solutions the users entered until now incorrect? How is this handled on codewars, what does it mean? Should I do it or not?
Frankly don't know. It seems that you do not have a lot of solutions and... C++ was a translation, right ?
It's very personal, but I prefer to separate algorithmic stuff and data massaging.
See CAdams747 comments.
Yes, it's a translation. I get this feedback often for this kata and as I want it to be a pleasent experience, now and then think about simplifying it. I'd change it for all languages, though. Don't know...
Thx for your feedback!
For JS && TS
It's 2023. And the equivalent of
Test.expect
(assert
) is still being used which does not display the corresponding assertions of inputs properly upon failureAlso, a code formatter function should be used to display such assertion messages for better readability (most, if not all lengthy ASCII-ART katas have such functions, refer to myjinxin2015's katas)
I think I fixed it, please check if the updated version makes sense to you?
If not, I'm afraid I am unable to make appropriate changes.
.
I get stressed after such tasks
Hello,
Can the author of this challenge please look to put some way to program the characters into some form of pre-loaded dictionary or array
Having read a lot of comments below, there appears to have been stress caused to a number of other CodeWars users by the structure/spacing of the characters - particularly the character of the space (" ") - which seems to have caused a lot of stress and frustration to a number of people already
For this reason, my very strong considered advice to the author of this challenge is to put some way to program the characters into some form of pre-loaded dictionary or array
Without a pre-loaded dictionary or array for the characters, my considered advice to any CodeWars users would be to avoid this challenge and save yourself a great deal amount of stress and frustration
To the best of my recollection, this is the very first challenge on CodeWars where I have chosen to forfeit the right to earn Kata
Thank you for your 'suggestion' (resolved). I feel sorrowful about this kata causing you so much stress and frustration. You didn't understand what the discussion regarding spaces from the early days of this kata was about.
Hello Galvlbit,
I am generally very wary of leaving any comments out of fear of getting some sort of 'keyboard warrior' hostile style response, and so I would very much like to say big thank you to yourself for taking my comment as constructive feedback which it seems you have taken on board
The comment about the space character (" ") was based on a general overview of the comments that have been left on this challenge already, and perhaps that perception was heightened by the fact that I was able to get the third test to pass ("NOPQRSTUVWXYZ") but none of the others
Based on what I could see when I tried to diagnose why the first test ("HELLO WORLD") was failing, I was of the impression that the obstacle was in the space character as opposed to any of the letters
If you are able to program the characters into some form of pre-loaded dictionary or array and then incorporate this into the challenge then I think this will significantly improve it
In closing, I would just like to say thank you once again for taking my comments in a constructive and appreciative context
you're welcome. which language did you try? I thought it was Python , but am not sure anymore. Python and JavaScript versions have preloaded dict/map. I'm unable to add a working preloaded dict to the Ruby version and have not yet tried on any other.
Hello Galvlbit,
Python was the only language I tried to resolve this challenge in but, if I had resolved in Python, I would have tried to solve the challenge in both JavaScript and Ruby
As I say, from what I have seen of the challenge the major stress is building the dictionary/array as opposed to the building the answer with programming in the relevant programming language
The solutions that I have seen after I forfeited the kata were essentially in line with my own attempts - which only reinforced my belief that a pre-loaded dictionary or array would greatly assist with this challenge
I see. I already added the dictionary.
rust version:
Thank you for reporting the problem. Would you mind trying to reproduce the error? I think I fixed it.
.
.
Hey looking for a bit of help getting my code to pass. I have acheived the expected output, ive checked that my spacing matching the spacing of the expexted string in the samples and everything lines up. however the only test that will pass is the empty string. Im new to this, so any tips on how to debug and problem solve when you cant see the random tests? Any tips or advice would be great
This comment has been hidden.
Well that was fun to debug lmao
This comment has been hidden.
Thank you for reporting the problem! I think I found the mistake. Sorry for the inconvenience!
I created a code golf version of this kata -- you could add a link to it in the description.
Cheers
I didn't even know what code golf is until now. Will link it when it leaves beta, although I deem the idea obscure, not to speak of the resulting code.
Sure, as you prefer. I will comment here when it's approved.
I entered a link to your version. :)
Can someone please approve this kata? Does it always take so long until someone approves new kata?
That's mostly random, but the longer it stays in unapprovable state, the longer it might take (because when it reaches "approvable" state, it's already burried in the kata search page).
Done
Thank you!
I noticed only now that there is no error handling if input contains an unknown character, for example exclamation mark. My function simply crashes with an Error. For the use of the kata in a narrow sense, I think it is neglectable. Is that a problem?
no, it's out of specs. The task is to handle characters and spaces, that's all. It's the responsibility of the user of the function to respect its contract. Passing in anything else just results in an undefined behavior, so it's not a problem.
:)
My submitted solution fails on the empty (or a spaces-only) string, which is sometimes tested in the random tests, with a low probability (it happened on my first try ;-) Either put it as a fixed test (and specify it in the description), or remove the possibility to generate an empty string.
I chose to put fixed test and specify. Thx!
Kata would be much better without the special case for the spaces.
Okay, I'll change that as soon as I get home this evening.
Done :)
Thanks, much better ^^
well, the spec are still incorrect:
spaces in the input string are characters, like any other. So, they should have a size of 5 columns. Then you join the chars in the output with a single column of spaces. That means for 1 space between two words in the input, you end up with 6 empty columns in the ouput, or for 3 consecutive input spaces, you end up with 18 empty columns, ...
back to the drawing board, I'm afraid... ;)
If I get you right, you're saying, the description is not clear enough? What if I declared the space a special character? Like:
I feel like being as precise as is probably needed, the description gets harder to understand and the kata is even less pleasent.... :)
errrr... I actually missed that part. But I'd advise to not go that way. That makes the coding more tedious, not more interesting, imo.
Thought about it and changed the description once more. I hardly dare to say: should be okay now... :)
PS: we must have entered our last messages in the same moment. I'm puzzled what is the better way. Need to get some sleep now. Thanx for your input!
PPS: if you look at discourse history, in an earlier version of my algorithm (which compared to the meanwhile submitted solutions of much better programmers than I am is really odd), I had a logical mistake. Then changed it so it fit my original idea. I'd have to change it back now to something that felt wrong back then. lol, never thought creating a kata I deemed to be simple would get so adventurous.
I still don't like that special requirement about spaces, but you seem somehow fond of the idea, so...
Yeah, creating a good kata is hard. ;)
Hi,
Cheers
Thank you for helping me find mistakes! All mistakes were caused by my limited knowledge. Which is at the same time a chance to learn!
I fixed the kata according to your suggestions: improved the description, fixed the algorithm of reference solution so that one space in input results in exactly 5 spaces in output and that relation is kept if there are more than one space, except for leading and/or trailing spaces. Finally I arranged the tests according to your suggestions.
Will therefore mark the issue as resolved and re-publish the kata. THANK YOU!
A couple of minor issues:
no it's effectively 5 (because "1 left + 5 + 1 right" == 7, or maybe you built your data/reasoning in a weird way that made you think so)
The last two points or not "minor" issues at all, tho. That's specifications that are absent from the description ;)
@Galvlbit: the trailing new line might be acceptale (some languages use it as a norme. It's not the norm for python tho), but the "trailing blank line" doesn't actually make sense, on the other hand (imo...).
Cheers
You're right. I have to think about this.
I made some changes in order to address the raised issues.
Long strings really look ugly, because they are wrapped, extended or condensed beyond recognition. I don't know whether I'm smart enough to alter the kata in order to make it part of the task to make sure the result is readable/recognizable in any case...
Hey @Galvlbit - this looks like a cool kata, I'll attempt it tomorrow, but as I'm the first person to attempt just 2 quick suggestions:
In Python you should use
camel_case
for function names - while there are no solutions published, I recommend you quickly edit so that function isblock_print
. This will avoid compatibility/naming problems later if another user raises this as an issue.Off the top of my head there are a few ambiguous characters -
Q
for example,C
(since yourO
has rounded edges rather than just being a "square"),F
(does the middle bar go all the way to edge?) etc. I'd suggest maybe you have such examples in the description, or in the Sample Tests, so users can clearly see the expected layout for the "tricky" letters.update- you've also got some weird stuff in the Sample Tests:
also, sorry for separate comment, I just clicked "Attempt" and it seems you don't have any random tests - this is something that other users will definitely raise an Issue about and cause your kata to have a negative vote.
I'd suggest you quickly unpublish and take the time to add the random tests - no rush, you can republish when it's done. If you need help with this you can look at any Python kata you've solved and copy the "layout" or ask in the Codewars Discord.
Thx a lot! I changed the kata according to your suggestions. Will improve it further tomorrow, need to go to bed now. Thank you for the input!
@benjaminzwhite If you raise these as issues (since they are) then the kata would be automatically unpublished, allowing the author to fix it. I think often this is better for the author than hoping that they will see your message and unpublish in time.
@Kacarott ah thanks, I see what you mean and now I understand why others do it that way. I noticed the kata being published just as I was logging off so I figured the author would still be online, but I'll do that in future then.
@Galvlbit - no worries, let me know if you need any explanations for the random test stuff!
thx
Should I post the letters the way the kata expects them? Almost any letter can be printed in alternate ways on a 7x5 grid.