Skip to content

Instantly share code, notes, and snippets.

@ahaxu
Created January 6, 2023 05:07
Show Gist options
  • Save ahaxu/7369bce0fc0027b601ba8c3d54be782d to your computer and use it in GitHub Desktop.
Save ahaxu/7369bce0fc0027b601ba8c3d54be782d to your computer and use it in GitHub Desktop.
3d-triathlon-tet-2023.py
def calculate_set3(rs, acts):
if len(acts) == 0:
return rs
brick = [acts[0]]
for i in range(len(acts)):
if i == 0:
continue
if acts[i] - brick[-1] <= 1:
if len(brick) < 3:
brick.append(acts[i])
if len(brick) == 3:
rs += [brick]
return calculate_set3(rs, acts[i+1:])
continue
else:
return calculate_set3(rs, acts[i:])
return rs
if __name__ == "__main__":
activities = [
1, 2, 3,
5, 6,
8,
11, 12, 13,
18
]
# activities = [1, 3,4,5 ,6,7,8 ,9,10, 15,16,17]
rs = calculate_set3([], activities)
print(rs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment