Dict Challenge


In [1]:
konum = {
    0: "Başlangıç konumu",
    1: "Yol",
    2: "Tepe",
    3: "Bina",
    4: "Vadi",
    5: "Orman"}

In [2]:
yonler = [
    {"Q": 0},
    {"K":5, "B":2, "G":4, "D":3, "Q":0},
    {"K":5, "Q":0},
    {"K":1, "Q":0},
    {"K":1, "B":2, "Q":0},
    {"B":2, "G":1, "Q":0}]

In [3]:
loc = 1
while True:
    if loc == 0:
        break
    mumkunYonler = ", ".join(yonler[loc].keys())
    yon = input("Gitmenin mümkün olduğu yönler: "+ mumkunYonler + " Birini seçin   : " ).upper()
    if yon in yonler[loc]:
        loc = yonler[loc][yon]
    else:
        print("O yöne gidemezsiniz.")


Gitmenin mümkün olduğu yönler: B, Q, D, G, K Birini seçinQ

Bombayı Etkisiz Hale Getirme

To disarm the bomb you have to cut some wires. These wires are either white, black, purple, red, green or orange. The rules for disarming are simple: If you cut a white cable you can't cut white or black cable. If you cut a red cable you have to cut a green one If you cut a black cable it is not allowed to cut a white, green or orange one If you cut a orange cable you should cut a red or black one If you cut a green one you have to cut a orange or white one If you cut a purple cable you can't cut a purple, green, orange or white cable If you have anything wrong in the wrong order, the bomb will explode. There can be multiple wires with the same colour and these instructions are for one wire at a time. Once you cut a wire you can forget about the previous ones.

You will recieve a sequence of wires that where cut in that order and you have to determine if the person was succesfull in disarming the bomb or that it blew up.

Input 1

white red green white Input 2

white orange green white

Wheter or not the bomb exploded Output 1 "Bomb defused"

Output 2

"Boom"


In [14]:
renkler = {
    "white" : 0,
    "red" : 1,
    "black" : 2,
    "orange" : 3,
    "green" : 4,
    "purple" : 5
            }

In [15]:
teller = [
    {"purple":6 , "red":2, "orange": 4, "green":5},
    {"green":5},
    {"black":3,"purple":6,"red":2 },
    {"red":2, "black":3},
    {"orange": 4, "white":1},
    {"red":2,"black":3}
         ]

In [17]:
print("Kesmeniz gereken teller: "+ ", ".join(renkler.keys()))
kesmeSirasi = input("Lütfen bombayı etkisiz hale getirmek için telleri kesme sırasını giriniz: ").lower()
kesmeSirasi=kesmeSirasi.split(",")

for i in range(len(kesmeSirasi)-1):
    mumkunteller=list(teller[renkler.get(kesmeSirasi[i])].keys())
    if not(kesmeSirasi[i+1] in mumkunteller):
        print("BOOOOM")
        break
    else:
        print("checking "+ kesmeSirasi[i+1]+" cable...")


Kesmeniz gereken teller: orange, red, purple, green, white, black
Lütfen bombayı etkisiz hale getirmek için telleri kesme sırasını giriniz: red, green
BOOOOM

In [ ]: