@anonymous/

StainedMonthlyOutput

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.20206782215717478","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"anVtcHMgPSB7MjogMjEsIDQ6OSwgMTA6MjAsIDE3OjIzLCAyMTowLCAxOTo5LCAxNDogMiwgMTg6NSx9CmZpbmFsX3BvcyA9IDI1CgpuX3N0ZXBzID0gWzBdCgpkZWYgc25ha2VzX2xhZGRlcnMoKToKICAgIHBvc2l0aW9ucyA9IHswfSAgI2luaXRpYWwgcG9zaXRpb24gb2ZmIHRoZSBib2FyZAogICAgd2hpbGUgZmluYWxfcG9zIG5vdCBpbiBwb3NpdGlvbnM6CiAgICAgICAgbl9zdGVwc1swXSArPSAxCiAgICAgICAgb2xkX3Bvc2l0aW9ucyA9IHBvc2l0aW9ucwogICAgICAgIHBvc2l0aW9ucyA9IHNldCgpCiAgICAgICAgZm9yIHBvcyBpbiBvbGRfcG9zaXRpb25zOgogICAgICAgICAgICBmb3IgZGljZSBpbiByYW5nZSgxLCA3KToKICAgICAgICAgICAgICAgIG5ld19wb3MgPSBwb3MgKyBkaWNlCiAgICAgICAgICAgICAgICBwb3NpdGlvbnMuYWRkKGp1bXBzLmdldChuZXdfcG9zLCBuZXdfcG9zKSkKCiAgICBwcmludCAoZidSZWFjaGVkIGZpbmlzaCBpbiB7bl9zdGVwc1swXX0gc3RlcHMuJykKCmlmIF9fbmFtZV9fID09ICdfX21haW5fXyc6ICAgCiAgICAgc25ha2VzX2xhZGRlcnMoKQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
jumps = {2: 21, 4:9, 10:20, 17:23, 21:0, 19:9, 14: 2, 18:5,}
final_pos = 25

n_steps = [0]

def snakes_ladders():
    positions = {0}  #initial position off the board
    while final_pos not in positions:
        n_steps[0] += 1
        old_positions = positions
        positions = set()
        for pos in old_positions:
            for dice in range(1, 7):
                new_pos = pos + dice
                positions.add(jumps.get(new_pos, new_pos))

    print (f'Reached finish in {n_steps[0]} steps.')

if __name__ == '__main__':   
     snakes_ladders()