#!/usr/bin/env python

from nodes import Node
import math

class FloorDiv(Node):
    char = "f"
    args = 2
    results = 1
    
    @Node.test_func([3,2], [1])
    @Node.test_func([6,-3], [-2])
    def func(self, a:Node.number,b:Node.number):
        """a/b. Rounds down, returns an int."""
        return a//b
    
    @Node.test_func(["test", "e"], [["t", "e", "st"]])
    def partition(self, string:str, sep:str):
        """Split the string at the first occurrence of sep,
return a 3-list containing the part before the separator,
the separator itself, and the part after the separator.
If the separator is not found,
return a 3-list containing the string itself,
followed by two empty strings."""
        return [list(string.partition(sep))]
    
    @Node.test_func(["134", 1], [["134"]])
    @Node.test_func(["1234", 2], [["12", "34"]])
    @Node.test_func(["1234", 3], [["1", "2", "34"]])
    @Node.test_func([[4,8,15,16,23,42], 5], [[[4],[8],[15],[16],[23,42]]])
    @Node.test_func(["123456789", 5], [['1', '2', '3', '4', '56789']])
    def chunk(self, inp:Node.indexable, num:int):
        """Return inp seperated into num groups"""
        rtn = []
        size = len(inp)//num
        for i in range(0, num*size, size):
            rtn.append(inp[i:i+size])
        if len(rtn) != num:
            rtn.append(inp[i+size:])
        else:
            rtn[-1] += inp[i+size:]
        return [rtn]
@@ -1034,24 +1034,109 @@
  '56789'%5D%5D)%0A
+    @Node.test_func(%5B%5B4,8,15,16,23,42%5D, 7%5D, %5B%5B%5B%5D,%5B%5D,%5B%5D,%5B%5D,%5B%5D,%5B%5D,%5B4,8,15,16,23,42%5D%5D%5D)%0A
     def chun
@@ -1270,16 +1270,33 @@
 p)//num%0A
+        try:%0A    
         
@@ -1334,32 +1334,36 @@
 e):%0A            
+    
 rtn.append(inp%5Bi
@@ -1372,16 +1372,109 @@
 +size%5D)%0A
+        except ValueError:%0A            for i in range(num): rtn.append(%5B%5D)%0A            i = 0%0A
         

Fix bug where chunk would break if num was bigger than len(inp)