Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 508 Bytes

computational-thinking.md

File metadata and controls

24 lines (18 loc) · 508 Bytes

Computational Thinking

Divide and conquer

Recursion implementation

students = list(range(21))
cases = list(range(5))
print('students:', students)
print('cases:', cases)

def distribute(s, c):
    if len(c) == 1:
        print('Case:', c[0], 'Students:', s)
    else:
        p = len(s) // len(c)
        print('Case:', c[0], 'Students:', s[: p])
        distribute(s[p: ], c[1: ])

distribute(students, cases)

Try out other number of students and cases to see if this still works.