6 kyu

Block Letter Printer

355 of 744Galvlbit
Description
Loading description...
Strings
ASCII Art
Algorithms
  • Please sign in or sign up to leave a comment.
  • ghorguss Avatar

    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?

  • Kjones99 Avatar

    This comment has been hidden.

  • KayleighWasTaken Avatar

    Python should have an explicit from preloaded import alpha in the solution setup.

  • KayleighWasTaken Avatar
  • LDanAlex Avatar

    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.

  • ahmet_popaj Avatar

    Well done...

  • trashy_incel Avatar

    It seems that some languages do not have a preloaded map (at least, they are not mentionned in the description):

    • Java
    • Ruby
    • Rust
  • trashy_incel Avatar

    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" ?

  • bansonV1 Avatar

    This comment has been hidden.

  • catechni Avatar

    (Python)

    Can I suggest the dictionary in preloaded is mentioned somewhere in the description?

  • pearcebasmanm Avatar

    Rust Version

    I see someone had a similar trouble in the past. Maybe the last fix didn't work?

    error[E0412]: cannot find type `HashMap` in this scope
       --> src/lib.rs:310:12
        |
    310 |     alpha: HashMap<String, Vec<&'static str>>,
        |            ^^^^^^^ not found in this scope
        |
    help: consider importing one of these items
        |
    271 | use im::HashMap;
        |
    271 | use std::collections::HashMap;
        |
    
    error[E0433]: failed to resolve: use of undeclared type `HashMap`
       --> src/lib.rs:315:25
        |
    315 |         let mut alpha = HashMap::new();
        |                         ^^^^^^^ not found in this scope
        |
    help: consider importing one of these items
        |
    271 | use im::HashMap;
        |
    271 | use std::collections::HashMap;
        |
    
    Some errors have detailed explanations: E0412, E0433.
    For more information about an error, try `rustc --explain E0412`.
    error: could not compile `challenge` due to 2 previous errors
    
    
    NOTE: Line numbers in error messages can be incorrect due to concatenation.
    
  • eurydice5717 Avatar

    <<C++ version>> IMHO a bunch of data massaging (heading and trailing spaces in entry string, end of line management, ...) thus a :-( eval

  • ejini战神 Avatar

    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 failure

    • Also, 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)

  • LetMeeDie Avatar

    I get stressed after such tasks

  • CAdams747 Avatar

    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

  • Fbasham Avatar

    rust version:

    error[E0412]: cannot find type `HashMap` in this scope
      --> src/lib.rs:44:12
    
  • DevMedic11 Avatar

    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

  • Eatkin Avatar

    Well that was fun to debug lmao

  • unstablecookie Avatar

    This comment has been hidden.

  • anter69 Avatar

    I created a code golf version of this kata -- you could add a link to it in the description.

    Cheers

  • Galvlbit Avatar

    Can someone please approve this kata? Does it always take so long until someone approves new kata?

  • Galvlbit Avatar

    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?

  • anter69 Avatar

    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.

    Testing for ' '
    '\n\n\n\n\n\n' should equal ''
    
  • Mercy Madmask Avatar

    Kata would be much better without the special case for the spaces.

  • Blind4Basics Avatar

    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... ;)

  • Blind4Basics Avatar

    Hi,

    The rows that compose the letters or words do not have to be of equal length - for example: if the last letter is a D, the first row should be shorter than the following one.

    • The above is an improper way to just say that the trailing spaces must be removed.
    • The behavior about spaces inside the input isn't given: currently a whitespace is narrower than a letter, that's totally unexpected (it's 3 characters wide instead of 5 for all other letters)
    • the random tests may generate consecutive spaces and the reference solution is ignoring them. This is neither specified nor tested (and imo, this is the wrong behavior to use: 2 consecutive spaces in the input should result in 2 consecutive spaces in the output)
    • missing example and/or fixed tests:
      • trailing and/or leading spaces
      • several consevutive spaces in between words
    • note that every example test should be present as fixed test in the full test suite as well. The full test suite may contain more fixed tests, but it should never contain less.

    Cheers

  • dfhwze Avatar

    A couple of minor issues:

    • 5 spaces between words -> actually 6, because you add another space between letters, even for whitespace, but the spec is really fuzzy about that
    • we have to end the string with a newline -> usually, intercalating functions don't add another delimiter at the end
    • we also require an additional white space before the last new line, this also seems incorrect, as this is not in between letters
  • benjaminzwhite Avatar

    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:

    1. In Python you should use camel_case for function names - while there are no solutions published, I recommend you quickly edit so that function is block_print. This will avoid compatibility/naming problems later if another user raises this as an issue.

    2. Off the top of my head there are a few ambiguous characters - Q for example, C (since your O 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:

    test.assert_equals(blockPrint('ÄÖÜäöü'), Traceback) # <- this raises an error
    #test.assert_equals(summation(22), 253)
    
  • Galvlbit Avatar

    Should I post the letters the way the kata expects them? Almost any letter can be printed in alternate ways on a 7x5 grid.