It doesn't apply in this case, because you're only using divmod on positive 
numbers, but at the risk of confusion I want to point out that python 
divmod,div, and mod behave differently from Nim for negative numbers, so that 
can be a gotcha when porting python.

If negative numbers are involved you need to use `floorDiv` and `floorMod` from 
`math`. So a python-compatible divmod would be:
    
    
    from math import floorMod,floorDiv
    proc divmod(a, b: int): (int, int) =
      let
        res = a.floorDiv b  # integer division
        rem = a.floorMod b  # integer modulo operation
      
      (res, rem)
    
    
    Run

Reply via email to