Ad
  • Custom User Avatar

    I don't think this is 6kyu.

  • Default User Avatar

    Kind of. You're expanding the content of the variable, but if that has spaces then you've passed multiple arguments instead of a single argument:

    txt="a  b c"
    # echo $txt
    echo a  b c
    # echo's arguments (which includes its own name): ["echo", "a", "b", "c"]
    # note no spaces at all. the reason a space is there in the output is that
    # echo is putting a space between each arg when it prints them back out
    
    # echo "$txt"
    echo "a  b c"
    # echo's arguments: ["echo", "a  b c"]
    
  • Default User Avatar

    It wouldn't, but you need to make sure you're not splitting up the text into arguments anywhere, because then you've lost the delimiters.

  • Default User Avatar

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

  • Default User Avatar

    I don't see this behaviour in the tests. It's probably your code that is removing spaces, which is a very easy mistake to make in shell.

    Something is printing to stdout, not sure what (because I'm unfamiliar with cw's sh environment), but I noticed that two spaces look a lot like one space, it doesn't even add a single pixel for the second space. It's there if copied though. Kind of unfortunate font behaviour..

  • Default User Avatar

    The random tests for the Shell implementation appears to occasionally add extra spaces to the output.
    Encoded message: tvg3swhprr hj,

    Test Failed
    expected: "tvg3swhprr  hj,"
         got: "tvg3swhprr hj,"
    
  • Default User Avatar

    My bash script works, but it is not efficient enough to finish within 12000 ms. I made my best attempt at translating my completed Python solution to bash, but unfortunately, the bash version is too slow. Any suggestions for improving efficiency in bash? I am using associative arrays to convert between letters and their decimal equivalent. Is there a better/faster way to do that in bash? Also I am using bc to handle most mathematical calculations.

  • Default User Avatar

    Thank your for the assistance. I was able to complete this kata. I believe my original issue was caused my use of addition echo commands (used for testing/debugging) prior to the final echo output. Once these commands were commented out, the logging recieved the correct values.

  • Default User Avatar

    i tried to improve the assertion messages, and added some input validation. if you want to train on this improved version, save your code somewhere, click the RESET button, and paste back your code.

  • Default User Avatar

    the logging for Shell in this kata is not ideal, but pasting your code and running the sample tests, i do see:

    testing: 835871232077058, 1
    expected: 30
    Shell Stdout
    29
    Test Failed
    expected: 30
         got: 29
    

    "shell stdout" means your answer here, while "expected" is the correct answer and 835871232077058, 1 the input

  • Default User Avatar

    Is echo the proper way to return an output of a function in Bash? In my Bash script, I am storing the number of iterations as counter. My script finishes with echo $counter and the value printed to the console matches the expected output, but the the testing script says that it got 0.

  • Default User Avatar

    Wow that is embarassing. Thank you for pointing out my error. I was certain that I had counted all 15 requests in my solution. I am ashamed of myself.

  • Default User Avatar

    That is only 14 requests. I figured you'd be too focused on checking that they didn't overlap to notice that one was missing, but by distributing them manually you wouldn't lose one of them due to some oversight or bug in the code that you wouldn't manually reproduce since you'd be aware of every step carried out.

  • Default User Avatar

    I appreciate your patience with my ignorance. I solved the above example by hand and came out with the exact same taxis as above:

    taxi 1: (3, 10), (14, 22), (26, 30)
    taxi 2: (8, 10), (16, 26), (27, 29)
    taxi 3: (9, 18), (19, 20), (21, 30)
    taxi 4: (16, 26), (29, 30)
    taxi 5: (17, 25), (29, 30)
    taxi 6: (19, 28)
    

    How are these not "distributed" correctly?

  • Default User Avatar

    Yes, but you didn't distribute the requests between the taxis. Yes, check it by hand. Better yet, solve it by hand so that you are actually checking that it's solvable rather than looking at the solution and failing to find a problem (which doesn't mean there isn't one)

  • Loading more items...