Skip to content

Commit e3df3fa

Browse files
committed
Added "for_games/solutions of games/SpongeBob SquarePants Battle for Bikini Bottom - Rehydrated. 8 cylinder puzzle/"
1 parent fa2044d commit e3df3fa

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Solution puzzle from game SpongeBob SquarePants: Battle for Bikini Bottom - Rehydrated
2+
===========
3+
4+
![](screenshot.jpg)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
import copy
8+
9+
10+
def activate(cylinders: list[bool], index: int):
11+
left_index = (index - 1) % len(cylinders)
12+
right_index = (index + 1) % len(cylinders)
13+
14+
cylinders[left_index] = not cylinders[left_index]
15+
cylinders[index] = not cylinders[index]
16+
cylinders[right_index] = not cylinders[right_index]
17+
18+
19+
def is_win(cylinders: list[bool]) -> bool:
20+
return all(cylinders)
21+
22+
23+
def run(init_cylinders: list[bool]):
24+
for start_index in range(len(init_cylinders)):
25+
seq = [start_index]
26+
27+
cylinders = copy.deepcopy(init_cylinders)
28+
activate(cylinders, start_index)
29+
30+
for i in range(len(cylinders)):
31+
if i == start_index:
32+
continue
33+
34+
seq.append(i)
35+
activate(cylinders, i)
36+
37+
if is_win(cylinders):
38+
print(seq)
39+
return
40+
41+
42+
CYLINDERS: list[bool] = [False] * 8
43+
44+
45+
if __name__ == "__main__":
46+
run(CYLINDERS)
47+
# [0, 1, 2, 3, 4, 5, 6, 7]

0 commit comments

Comments
 (0)