• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 24th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import itertools
2. import sys
3.
4.
5. PEOPLE = ['Pieter', 'Maaike', 'Kim', 'Tim', 'Patrieck']
6.
7. AGES = ['Bever', 'Welp', 'Scout', 'Explorer', 'Rover']
8.
9. BADGES = ['Das', 'Knopen', 'EHBO', 'Boomhut', 'Vissen']
10.
11.
13.     # Exchange to make the table non-circular
14.     # for i in range(len(group) - 1):
15.     for i in range(len(group)):
16.         if group[i] in args and \
17.                 group[(i + 1) % len(group)] in args:
18.             return True
19.
20.     return False
21.
22.
23. def index_of(group, k):
24.     for i, v in enumerate(group):
25.         if v == k:
26.             return i
27.
28.     sys.exit('Did not find ' + k + ' in ' + str(group))
29.
30.
31. for order in itertools.permutations(PEOPLE):
32.     if order[1] != 'Tim':
33.         continue
34.
35.     if order[0] in ['Pieter', 'Patrieck']:
36.         continue
37.
38.     # check if together
39.     if not adjacent(order, 'Pieter', 'Maaike'):
40.         continue
41.
44.             continue
45.
47.         if order[boom_index][0] == 'P':
48.             continue
49.
50.         for ages in itertools.permutations(AGES):
51.             welp_index = index_of(ages, 'Welp')
52.             if order[welp_index][0] == 'P':
53.                 continue
54.
55.             rover_index = index_of(ages, 'Rover')