Ad
  • Custom User Avatar

    I like the simplicity of the solution. It's a rare case where using "magic numbers" and manually writing out each of the possibilities (instead of a loop) is actually okay and still quite readable.

    One small suggestion: consider using bitwise | instead of +=. I think the result would be just as readable.

  • Custom User Avatar

    I like the use of the xrange loop to quickly get the "ret" at the right place. I would suggest to have more descriptive "raise" messages but otherwise this solution reads quite well.