Conversation
| @@ -0,0 +1,17 @@ | |||
| from random import randint | |||
| number = randint(1, 100) | |||
| win = False | |||
There was a problem hiding this comment.
ten kod by mel byt zabaleny do funcki.
| matched=0 | ||
| #system collects 6 different numbers in given range and sorts them | ||
| for x in range(6): | ||
| while True: |
There was a problem hiding this comment.
tady delas dvijity loop proc? to je zbytecne
|
|
||
| #system draws 6 random numbers and sorts them | ||
| for x in range(6): | ||
| while True: |
There was a problem hiding this comment.
taky dvojity loop uplne zbytecne. jdi na to vic primocare
| @@ -0,0 +1,35 @@ | |||
| from random import randint | |||
There was a problem hiding this comment.
zase ten kod by mel byt zalbaleny do funcki
| count += 1 | ||
|
|
||
| #user inputs a number to give a clue to the system | ||
| answer = input("Your verdict 1 - Too small, 2 - Too big, 3 - You win => ") |
There was a problem hiding this comment.
neni osetrena vyjimka kdyz nekdo zada neco jineho nez 3 nebo 2.
Vlastne to skace vzdy do else vetve kdyz clovek zada neco jineho, takze tahle logika neni spravne
|
|
||
| #If the count of guesses reaches 10, user must be cheating, therefore system calls him liar | ||
| #Otherwise system cointinues guessing | ||
| if count == 10: |
There was a problem hiding this comment.
toto neni vubec potreba kontrolovat
| #the cycle continues till the guess is correct | ||
| while answer != "3": | ||
|
|
||
| guess = int((max - min) / 2) + min |
| import random | ||
| #using regex and random to simulate the dice throw | ||
| def roll_dice(dice_code): | ||
| pattern = r'(\d*)D(\d+)([-+]\d+)?' |
There was a problem hiding this comment.
tenhle pattern neni spravne. umozni to napsat treba D7 coz je zakazno
| num_rolls = int(match.group(1)) if match.group(1) else 1 | ||
| dice_type = int(match.group(2)) | ||
| modifier = int(match.group(3)) if match.group(3) else 0 | ||
| result = sum(random.randint(1, dice_type) for _ in range(num_rolls)) + modifier |
There was a problem hiding this comment.
wau!!
tohle je celkem optimalni resesni, skoda ze nemas dobre ten pattern.
No description provided.