Ad
  • Custom User Avatar

    No, it's honestly fine I think. All the test cases are associative towards the right anyway, i.e. a*b*c is treated as a*(b*c). Same for plus.

  • Custom User Avatar

    after taking a break from codewars for a few months, it feels great to solve a difficult question in only a few hours. So, it's either I've gotten way better or this kata was a little bit easy for 1kyu. It's probably the latter, realistically speaking though- lol.

    Anyway, this was a great kata- I've never written a compiler before, and this kata really helped me understand how they work. Some suggestions:

    1. The pass2 constraints are very lenient. As mentioned also by someone else in the comments, pass2 should also remove unnecessary +0s, *1s, etc. (i.e. pass2({'op': '+', 'a': {'op': 'arg', 'n': 0}, 'b': 0} should return {'op': 'arg', 'n': 0})

    2. Some "different" solutions are the same, algebraically, because operations like adding and multiplying are associative. The test suite should let these solutions pass too. I know, an infinite number of solutions now are possible, but it would be nice to have some leeway.

    -goldenratio161

  • Custom User Avatar

    you know, when I figured out the solution, I went, "ohhh, so that's why it has to be prime!"

    nice kata.

  • Custom User Avatar

    approved by someone

  • Custom User Avatar

    Python:

    passing all fixed test cases but no random test cases. Although it is probably because of my terribly-written, bug-riddled code, the random tests are impossible to debug. The strings are way too long, and it would be really helpful if there were some shorter random strings.

  • Custom User Avatar

    ah, that's annoying; must be an off-by-one error i guess.

  • Custom User Avatar

    haha lol, its just that when seeing "There is no solution to show" pop up, I thought you had already given up on this kata.

  • Custom User Avatar

    two years late, but you and I had the exact same issue. there is a way to solve it though; think of how you would solve this on a square grid, and notice what the algorithm behind it actually does to each individual piece.

  • Custom User Avatar

    my first 1kyu kata solved! this was an amazing kata, spent damn near 2 weeks on this, but it was really worth it. thank you, jaybruce, for making this; that's 83 people very satisfied with this kata now :)

  • Custom User Avatar

    oh wait, I've figured it out!

  • Custom User Avatar

    the test cases sort a list of PokerHand classes, and you need to sort them based on the hand value.

    ah crap, I actually don't understand it too; I pass example test cases but the random test cases just say "failed at test n".

    I'm confused, what?

    failed at test 0: [JH AH TH KH QH, JH 9H TH KH QH, 5C 6C 3C 7C 4C, 2D 6D 3D 4D 5D, 2C 3C AC 4C 5C, AS AC AH KS AS, JC 7H JS JD JH, JC 6H JS JD JH,
    KH KC 3S 3H 3D, 2H 2C 3S 3H 3D, 3D 2H 3H 2C 2D, JH 8H AH KH QH, 3S 8S 9S 5S KS, 4C 5C 9C 8C KC, 8C 9C 5C 3C TC, QC KH TS JS AH, JS QS 9H TS KH, 
    6S 8S 7S 5H 9H, 3C 5C 4C 2C 6H, 2C 3H AS 4S 5H, AC KH QH AH AS, 7C 7S KH 2H 7H, 7C 7S 3S 7H 5S, 6C 6S 3S 6H 5S, 3C KH 5D 5S KC, 5S 5D 2C KH KC, 
    3H 4C 4H 3S 2H, AH 8S AH KC JH, KD 4S KD 3H 8S, KC 4H KS 2H 8D, QH 8H KD JH 8S, 8C 4S KH JS 4D, KS 8D 4D 9S 4S, KD 6S 9D TH AD, TS KS 5S 9S AC, 
    JH 8S TH AH QH, TC 8C 2S JH 6C, 2D 6D 9D TH 7D, 9D 8H 2C 6S 7H, 4S 3H 2C 7S 5H] 
    
    should equal [JH AH TH KH QH, JH 9H TH KH QH, 5C 6C 3C 7C 4C, 2D 6D 3D 4D 5D, 2C 3C AC 4C 5C, AS AC AH KS AS, JC 7H JS JD JH, JC 6H JS JD JH, 
    KH KC 3S 3H 3D, 2H 2C 3S 3H 3D, 3D 2H 3H 2C 2D, JH 8H AH KH QH, 4C 5C 9C 8C KC, 3S 8S 9S 5S KS, 8C 9C 5C 3C TC, QC KH TS JS AH, JS QS 9H TS KH, 
    6S 8S 7S 5H 9H, 3C 5C 4C 2C 6H, 2C 3H AS 4S 5H, AC KH QH AH AS, 7C 7S KH 2H 7H, 7C 7S 3S 7H 5S, 6C 6S 3S 6H 5S, 3C KH 5D 5S KC, 5S 5D 2C KH KC, 
    3H 4C 4H 3S 2H, AH 8S AH KC JH, KD 4S KD 3H 8S, KC 4H KS 2H 8D, QH 8H KD JH 8S, 8C 4S KH JS 4D, KS 8D 4D 9S 4S, KD 6S 9D TH AD, TS KS 5S 9S AC, 
    JH 8S TH AH QH, TC 8C 2S JH 6C, 2D 6D 9D TH 7D, 9D 8H 2C 6S 7H, 4S 3H 2C 7S 5H]
    
  • Custom User Avatar

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

  • Custom User Avatar

    oh shit, my bad, I forgot to add it

  • Custom User Avatar

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

  • Custom User Avatar

    I must say, that was quite a bit harder than i expected it to be. Really fun to solve though!

  • Loading more items...