Ad
  • Default User Avatar

    I'm trying to solve kata in Haskell. According to output from random tests my code fail on strings like "\na", "a\n", "a\t". if i understood everything correctly, this strings should be returned as is or i'm wrong? Tests do not show expected results. I tested code on local mashine and it works fine on those input.

  • Default User Avatar

    thanks so much!, embarassing mistake

  • Custom User Avatar

    It looks like you're not returning any value. Printing is for your own debugging.

  • Default User Avatar

    Hi there!, can someone share some light on this:

    Test Results:
    Fixed Tests
    Basic Test Cases
    Log
    'ehT kciuq nworb xof spmuj revo eht yzal .god'
    None should equal 'ehT kciuq nworb xof spmuj revo eht yzal .god'
    Log
    'elppa'
    None should equal 'elppa'
    Log
    'a b c d'
    None should equal 'a b c d'
    Log
    'elbuod decaps sdrow'
    None should equal 'elbuod decaps sdrow'

    I'm wondering what I'm doing wrong, they are strings, i get the correct output respecting the spaces....hmmm

  • Default User Avatar

    They are there. I checked.

  • Default User Avatar

    in python when i reset to restart coding there is no sample tests.

  • Custom User Avatar

    Your solution ends with a space. There shouldn't be a space at the end.

    Not a kata issue.

  • Custom User Avatar

    Why?

    Test Example

    should work for sample test cases

    Expected

    <string>: ehT kciuq nworb xof spmuj revo eht yzal .god 
    

    to equal

    <string>: ehT kciuq nworb xof spmuj revo eht yzal .god
    

    Completed in 0.6589ms

  • Custom User Avatar

    I am curious as to what language you attempted this in. I did it in C++ and it only took about 25 minutes to figure out, and the only edge case I had to deal with was a string that was all spaces.

    I would also argue that dealing with edge cases is teaching how to write code, as dealing with edge cases is a major part of programming.

  • Custom User Avatar

    @andreyvdl please mind that the fact that someone points out to you that you used the ISSUE label incorrectly is not abuse, and reporting such behavior as abusive is not right.

    Having sauid that, Nuno is right: your solution has a bug, performs out-of-bounds access, and triggers undefined behavior. Your code does not handle leading spaces correctly, and it crashes for cases like " " or " test", with a space at the beginning. You need to fix your code.

  • Custom User Avatar

    Your code very likely contains undefined behavior. Also, "works on my local machine" is not a valid kata issue report. See https://docs.codewars.com/training/troubleshooting#post-discourse.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    OP solved it, closing

  • Default User Avatar

    You are absolutely right! Thanks to both of you!

  • Default User Avatar
    int len = strlen(text);
    char* reversedString = malloc(len);
    

    As hobovsky guessed, where is the nul terminator going to be stored ? ;-)

  • Loading more items...