Ad
  • Default User Avatar

    This solution is so clever and instructive at the same time. It taught so many of the python capabilities like the ones that you do in simple mathematical operations with slicing and especially the way you handle division!! I dont undertand a few things:

    1. in !. not stack[-1] will push True or False in stack. So, if we hade to face a dot wouldn't it raise an error? same for `

    2. How did you pass the Quine test? '>:# 0# # g# ,# 1# +# :# 5# 9# *# -# _@ Quine'. Lets see what I understand that happens step by step. Start--> :, stack[0] --> 0: stack[0,0] --> g: stack[62] --> ,: stack = [] output ='<' --> 1: stack[1] output='<' --> NOW THE PROBLEM +: stack OUT OF RANGE!
      Do I miss something? Alhtough, I can imagine many ways to fix this but the one I see would have to change all the slicing thing that you do in mathematical operations. I would recommend changing + like this stack.append(stack.pop() + stack.pop())

    3. the way that you implement moving, in the last for loop. Do we have to face the occasion where we get out of row or column limits like 'pacman'? To start from the beginnig of the row/col?

  • Custom User Avatar

    Found one! It's pretty easy really. I just haven't used Python much lately...

  • Custom User Avatar

    Oh, you're right! Python 3 lambdas don't deconstruct tuple arguments anymore. That's a bummer. I played around with the program a bit, but I didn't find a way to make the code as nice and compact as it was... :-(

  • Custom User Avatar

    Very nice solution.

    Note: It needs to be tuned a little to work with the current version a Python.

  • Default User Avatar

    I've re-read the details of the Loop-switch Sequence -- I was mistaken. It's only an AntiPattern when used to model a known series of steps, and for an interpreter the steps are (by defition) not known beforehand. My bad.

  • Default User Avatar

    No, you're not missing anything - I'm just wondering why people are marking this as Best Practice rather than Clever - I like your solution tbh.

  • Default User Avatar

    Well, I'm not sure to see any difference with your approach, I have to say. Putting the commands in function calls doesn't change the fact that they are all executed from the inside of a loop... Am I missing something?

  • Default User Avatar

    I love the compact nature of this solution. But I can't understand why it's being voted as Best Practices - it's Clever, but it is a Loop Switch Antipattern.

  • Default User Avatar

    The answer to this kata is visible in the 'sample test' window.

  • Default User Avatar

    Fixed. See other posts.

  • Default User Avatar

    Fixed. See posts below.

  • Default User Avatar

    Fixed. See posts below.

  • Default User Avatar

    Fixed. See other posts.

  • Default User Avatar

    Fixed. See other posts.

  • Default User Avatar

    Added constraints to input.

  • Loading more items...