Помогите с python - Общение Python мододелов

Вопрос Помогите с python

Регистрация
18 Дек 2013
Сообщения
99
Репутация
0
Спасибо
0
Монет
0
316465362_058c3dae9c433024dbaaf13ef0613870_800.png

Помогите с python пожалуйста, нужно сделать код для этой задачи, нейросети не помогают
 
Регистрация
18 Дек 2013
Сообщения
78
Репутация
0
Спасибо
1
Монет
0
def solve_chips(N):
operations = []

def move(n):
if n == 1:
operations.append(1)
else:
move(n - 1)
operations.append(n)
move(n - 1)

move(N)
return operations

N = int(input())
operations = solve_chips(N)
print(' '.join(map(str, operations)))
 
Регистрация
8 Авг 2013
Сообщения
76
Репутация
0
Спасибо
0
Монет
0
Ща проверь:

319456089_6b97162baa5749fc1949546a7d853b99_800.png

def solve():
n = int(input())
cells = [0] * n
actions = []

def print_state():
print(f"Cells: {cells}")
print(f"Actions: {actions}")

def place_chip(cell_index):
cells[cell_index] = 1
actions.append(cell_index + 1)


def remove_chip(cell_index):
cells[cell_index] = 0
actions.append(-(cell_index + 1))


def find_leftmost_chip_index():
for i in range(n):
if cells == 1:
return i
return -1

if n == 1:
place_chip(0)
elif n == 2:
place_chip(0)
place_chip(1)
elif n == 3:
place_chip(0)
place_chip(1)
remove_chip(0)
place_chip(2)
place_chip(0)
elif n == 4:
place_chip(0)
place_chip(1)
remove_chip(0)
place_chip(2)
place_chip(0)
place_chip(3)
remove_chip(2)
else:

print("За отведенное количество ходов решение не найдено")
return


if all(cells):
print(*actions)
else:
print("За отведенное количество ходов решение не найдено")

solve()
 
Сверху Снизу