7 kyu

Moves in squared strings (I)

365 of 13,969g964
Description
Loading description...
Fundamentals
Algorithms
Strings
  • Please sign in or sign up to leave a comment.
  • 4500zenja1 Avatar

    Nim: even if the assertion is wrong, the tests will be marked as completed due to console output inside of the dotest function; although the assertions are processed correctly by giving the error at the end. UPD: apparently this happens because of helper function dotest()...

  • 4500zenja1 Avatar

    Scala fork to resolve the suggestion by me below

  • 4500zenja1 Avatar

    Scala has an outdated version 2.1.3; it's recommended to upgrade it to 3.0, as well as testing framework.

  • 4500zenja1 Avatar

    No random tests for Rust (probably for other languages too).

  • misterbinny Avatar

    This comment has been hidden.

  • YurDavid Avatar

    wasted more time because of that bash note i took as the actual things to do please don't make the same mistake i did

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • srpanall Avatar

    Based on one of the top solutions in Python, there should be test cases for the "lower order functions" to ensure they work correctly. The specific solution I'm referencing sends lists to the lower functions which is against the scope of the functions.

  • schellingerhout Avatar

    This comment has been hidden.

  • Abukar-1000 Avatar

    This kata is just poorly phrased, which is unfortunate because its pretty easy. Kinda hard to code something you dont know.

  • Vishnevskiyoleg Avatar

    It was amazing Kata. I tryied to solve it about 4 hours. I wrote 40 lines of Kotlin code, and I did it !!! Then I had find solution for a 3 lines ))

  • JD136 Avatar

    Just finished in C#. Be wary: in my local environment, I had used two escape characters '\\n' to denote '\n' in a string - and that was perfect. But in the Codewars tool, it only wanted '\n' for some reason...

  • yashver96 Avatar

    This comment has been hidden.

  • Anton1mus Avatar

    how to pass a vert/hor method as a parameter?

  • Joostheimer Avatar

    Advice for author, you make the description way more difficult than it needs to be on all your katas. thanks

  • orussmann Avatar

    This comment has been hidden.

  • laurelis24 Avatar

    This looks like a monster before realising it's not that hard.

  • navin1510 Avatar

    stuck at oper function any hints guys I dont know how to handle static function passing in methods

  • PoberzhetsAndriy Avatar

    im unable to solve it using dart because (return r"") or (return"\") returns me ("\") why?

  • romaxa11 Avatar

    This comment has been hidden.

  • Orfey Avatar

    Func <string, string> f1 it doesn't work. How can I do it in C#?

  • discombobulateme Avatar

    This comment has been hidden.

  • qrt88 Avatar

    Loved this one. Learned something new :)

  • Antyrion Avatar

    vert_mirror(s) => "dcba\nhgfe\nlkji\nponm"

    should be... \ponm

    This is really hard to undarstand this kind of spaghetti instructions and functions names

  • pentiux Avatar

    This comment has been hidden.

  • roshan-ican Avatar

    i am really not understanding it from last night i have been trying to understand but it's hard! Is there any hints or reference i should go through... please ?

  • UlrichBerntien Avatar

    In languages (like Go) with UTF-8 strings (variable number of byte per character):

    Add a test case with 2 byte characters (like ±):

    dotestHor("FY±i\ndZQn\nuGef\nQoSy", "QoSy\nuGef\ndZQn\nFY±i")
    

    Solutions with byte access despite the structure of UTF-8 strings will fail the test.

  • robertDinca2003 Avatar

    This comment has been hidden.

  • robertDinca2003 Avatar

    static std::string oper(...,const std::string &s) When I press test, I get an error about this 3 dots (...).

  • MarmotFriend  Avatar

    The instructions example:

    s = "abcd\nefgh\nijkl\nmnop"

    has 'n' and 'm' mixed, it seems to me

  • TYZILLA Avatar

    STDERR Traceback (most recent call last): File "main.py", line 8, in testing(oper(vert_mirror, "hSgdHQ\nHnDMao\nClNNxX\niRvxxH\nbqTVvA\nwvSyRu"), "QHdgSh\noaMDnH\nXxNNlC\nHxxvRi\nAvVTqb\nuRySvw") NameError: name 'oper' is not defined

    Getting this error for python. I tried running the test without any code. I just put pass under the first function and i still received this error.

  • yar83 Avatar

    Hi all! Doing Shell. Please, point me to the right direction. I'm getting this error every check: Test Failed expected: "QHdgSh\roaMDnH\rXxNNlC\rHxxvRi\rAvVTqb\ruRySvw" got: "QHdgSh\\roaMDnH\\rXxNNlC\\rHxxvRi\\rAvVTqb\\ruRySvw" And I can't solve the problem with ecaped \r. Maybe i didn't understand a task?

  • ampersandio Avatar

    Really enjoyed this kata, but I don't think it's 7 Kyu. It was more like 6 imho.

  • sitetester Avatar

    def horMirror(strng: String): String = { // your code }

    1. strng should be replaced with s or str
    2. Same goes for function naming. vertMirror or horMirror is not proper name. Please avoid such shortcuts.
  • B1ts Avatar

    Prolog translation kumited. Review carefully o_O

  • jasonbrice Avatar

    This comment has been hidden.

  • user8071091 Avatar

    Vertical is horiztonal and horizontal is vertical.

    In practically all graphics editing software, which presumably many more people have experience with already, the vertical flip is not the one that spins the surface 180° around the vertical axis, it is the one that swaps the pixels according to their Y positions and preserves their X positions (i.e., spins around / mirrors across the horizontal axis). Yes, there is a horizontal aspect to every vertical flip, and vice versa, and it can't be helped.

    For comparison, the complex conjugate of a point is mirrored across the real axis, while the component that actually changed is the imaginary. We don't actually, but if we did, would we call it a real flip, or an imaginary flip? It's a matter of convention, tradition, notation, etc. And here, author takes the the uncommon one.

    I'm just sayin', for everyone else who comes after and likewise feels a bit disoriented. Don't worry about it, just follow the examples using the terms in the description until the tests pass ;)

  • user8436785 Avatar

    Dart and Elixir translations

  • 108806 Avatar

    How the fucc Im supposed to split non-raw strings at escape-char in a goddamn python? This challange is a bad joke.

  • Chrono79 Avatar

    I raised this issue to see if I can edit Swift version from kata editor directly.

  • quzle Avatar

    n is always even right? There's no mention of this in the instructions but it seems to be the case. even number of rows and columns

  • deuce Avatar

    in C, I get this error:

    Test Crashed Exit code: 0 Signal code: 6

    on IDE, everything works fine.

  • yaoxp Avatar

    So much kata don't support Swift 4

  • yaoxp Avatar

    So much kata don't support Swift 4

  • mukul09 Avatar

    I am getting the erroe " None should equal 'QHdgSh\noaMDnH\nXxNNlC\nHxxvRi\nAvVTqb\nuRySvw' ". but when I am running my code on my ide, I get perfect results.

  • moliver816 Avatar

    This comment has been hidden.

  • moliver816 Avatar

    Hi Folks, I'm new to Code Wars and trying to use it to practice some Swift. This feels like a great question so far! I'm having what feels like a basic issue where when I run my tests, I'm getting errors like "value of type 'String' has no member 'split'". I will admit to using a playground in Xcode to test my code. This seemed like a good idea... is it not? Is there some difference between the classes / packages available in a playground and the ones available in Code Wars? Is this all documented somewhere that someone can point me to? Sorry for the n00b questions!

  • Tadar2001 Avatar

    Ty for the kata. Was rly fun .

  • yagodorea Avatar

    There's some kind of memory issue when running in C, i get this STDERR message quite randomly. I really don't think I'm the one responsible, because the sole memory handling operation I do is a simple malloc ("out = (char*) malloc(len*sizeof(char)+1);")

    STDERR: *** Error in `/home/codewarrior/solution': free(): invalid next size (fast): 0x0000000000f7e850 ***

    My code passed the sample tests but won't go through the actual attempt. It says "Time: 17ms Passed: 4 Failed: 1 Errors: 1".

  • NathanWeinstein Avatar

    My C solution passes all the first 60 tests, after the 61st I get the following message: *** Error in `/home/codewarrior/solution': free(): invalid next size (fast): 0x00000000023bc960 ***

  • Raaven Avatar

    Hi, I just want to say thank you for this kata! It was very enlighting to learn how to pass higher order functions in Java.

  • donaldsebleung Avatar

    Objective-C Translation Kumited - please carefully review and approve :D

  • blackink000 Avatar

    Great Kata! Do you think it'd be possible to group your authored kata into collections of topics? I really like the idea of katas such as this one based on themes of increasing difficulty and it'd be nice to have them in a collection rather than scrolling through all of your authored katas each time.

    Thanks!

  • Late347 Avatar

    This comment has been hidden.

  • Late347 Avatar

    ok I think theres something wrong in my code about the string sizes in the one function... debugging now! :D

  • Late347 Avatar

    This comment has been hidden.

  • Late347 Avatar

    Im fairly sure I have a working solution for both simple functions for the mirror-functions. But I have absolutely no idea what exactly are higher order functions in C language?! Where should I go about learning more from higher order functions in C languge?

    I was not taught about higher order functions in C in my basic C-programming course in university. Sorry for being a little bit shit, but this is really hard exercise for beginner level! :(

  • Late347 Avatar

    im doing this in C, but I would like to ask about a couple of things 1.) is it guaranteed that there will be no entersigns '\n' except in the limit between two substrings? 2.) what is the minimum inputstring letteramount that is going to be expected? 3.) I assume that the minimum allowed inputstring will be char string[3]="a\n"; where the letteramount==1 correct or false?

  • Late347 Avatar

    I think this is quite hard exercise for beginner's level (7kyu)! I only did the verticalmirror function but I have no idea how to proceed

  • sf8193 Avatar

    not sure if something has changed in the test code but I am printing out my answer to sample code, it matches the solution, but is still not passing the test.

    This is the output.

    Expected: equal to yeCt CSbg JVhv lVHt Actual: yeCt CSbg JVhv lVHt

  • bestwebua Avatar

    Hi, @g964! Tnx for the nice kata. Cheers!

  • chestee Avatar

    FYI: There is an issue with tests. Method names vertMirror and horMirror are mixed.

  • kohn1001 Avatar

    I have implemented in C++, the code compiles, runs and the output is exactly the same... but the test and the submission fails... help?

  • Conner Avatar

    are you guys able to do this without any prior knowledge of coding? if you are, how did you go about this? i'm at a total loss and could use some pointers.

  • mohamed hmini Avatar

    what is that mean : generic_func_t f . why the f in the end of the parameter . i built the programe but i can't run it here cause of this issue.

  • leonardogama Avatar

    Im getting this error:

    Error in `/home/codewarrior/solution': munmap_chunk(): invalid pointer: 0x00007ffd60cf3820

    I think there is some error in the tests! (maybe a free in a invalid position)

  • Hiro3212 Avatar

    [C# Code] I don't know how to use this fct in Oper:

    In the test cases it just says "testing(Opstrings.Oper(Opstrings.HorMirror, "lVHt\nJVhv\nCSbg\nyeCt"), "yeCt\nCSbg\nJVhv\nlVHt");"

    What parameter do I have to use for ... fct?

    EDIT: I now just completed it. For you who have the same problem: just google "(language) function as parameter"

  • becomingbetter Avatar

    [C++ newbie] I have problem with:

    [ // your high order function oper //... oper(...); static string oper(..., const string &s); ]

    I have no idea what it's for or what it is. Can someone please explain it to me or give me hints/sources about it. Thank you very much.

  • Joz Avatar

    upd. sorry, it was codewars lag=) everything is ok now. thnx for kata!

  • blackhole12 Avatar

    This question does not understand what a horizontal or vertical mirror is. To demonstrate, open any picture in paint, click on "Rotate" and select "Flip Vertical". The image will now be upside down. That's what a vertical mirror is. This question's example of a vertical mirror, on the other hand, flips the text horizontally. Flipping "asdf" to "fdsa" is a horizontal mirror. A horizontal mirror flips over the y-axis, because it's inverting the x coordinates. A vertical mirror would be flipping over the x-axis, or doing what this question thinks is a horizontal mirror.

  • Krzysiek014 Avatar

    [JAVA] I have problem with(dots)

    public static String oper(... operator, String s)
    

    Can someone give me a hint or show me site where I can learn something about this?

  • Hoff Starr Avatar

    using typescript return reference error - reference tags should be self closing

  • robertfoleyjr Avatar

    Maybe i've been staring at this for too long, but for some reason the order of the elements keeps getting shifted. I've tried krsort() ksort() in an attempt to change the array row order prior to implode(). But nothing I do appears to change it.

  • sharifahmad Avatar

    I'm using c++ for this kata and it works on my system as well as passes the sample tests here but during testing with random tests gives some output that is not expectecd. When I tested my code with one of the random tests on my system it resulted in expected output. but here it codewars it has some extra string before it .I don't know where they come from.

  • HerrWert Avatar

    This is a great little kata for learning about helper functions, string and array manipulation!

  • PhO3n1x Avatar

    Sorry for the stupid question, but I can't figure out what kind of syntax/call method(:vert_mirror) in the test cases is. I started Ruby some time ago, but I have not yet seen this kind of magic. -.-

    I tried puts fct, but the only output I get is # and I don't know what to make from that. :/ I can't wrap my head around it, so a little hint would be really appreciated.

  • Unnamed Avatar

    The initial Clojure solution doesn't contain namespace definition.

  • ZozoFouchtra Avatar

    This comment has been hidden.