[ prog / sol / mona ]

sol


Code

1 2022-05-09 04:44

from collections import deque

def minimum_turns(snakes, ladders): # Create a board with the given snakes and ladders.

board = {square: square for square in range(1, 101)}

for start, end in snakes.items():

board[start] = end

for start, end in ladders.items():

board[start] = end

# Perform BFS to reach the last square as quickly as possible.

start, end = 0, 100

turns = 0

path = deque([(start, turns)])

visited = set()

while path:

square, turns = path.popleft()

for move in range(square + 1, square + 7):

if move >= end:

return turns + 1

if move not in visited:

visited.add(move)

path.append((board[move], turns + 1))

2 2022-05-09 08:14

>>1
What does this code do? Please indent properly.

3 2022-08-03 04:41

Print "hello world"

4 2022-08-03 11:01

a line of code was written today

5 2022-08-03 15:06

lol this
>>3

6 2022-08-03 22:20

lolololol lmao haha very fune fren

7 2022-08-03 22:21 *

Fuck I forgot to VIP so here's my VIP not that it counts or anything the damage is already done.
Poll: do you like guavas?

8 2022-08-03 22:55 *

i no liek

9


VIP:

do not edit these