Skip to content

workshop#6

Open
FuryJayBee wants to merge 1 commit intoCodersLab-CZ:masterfrom
FuryJayBee:jbartl_workshop
Open

workshop#6
FuryJayBee wants to merge 1 commit intoCodersLab-CZ:masterfrom
FuryJayBee:jbartl_workshop

Conversation

@FuryJayBee
Copy link

No description provided.

@@ -0,0 +1,17 @@
from random import randint
number = randint(1, 100)
win = False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tady delas dvijity loop proc? to je zbytecne


#system draws 6 random numbers and sorts them
for x in range(6):
while True:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taky dvojity loop uplne zbytecne. jdi na to vic primocare

@@ -0,0 +1,35 @@
from random import randint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 => ")
Copy link

@ExperimentalHypothesis ExperimentalHypothesis Feb 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toto neni vubec potreba kontrolovat

#the cycle continues till the guess is correct
while answer != "3":

guess = int((max - min) / 2) + min

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flor div // je lepsi

import random
#using regex and random to simulate the dice throw
def roll_dice(dice_code):
pattern = r'(\d*)D(\d+)([-+]\d+)?'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wau!!

tohle je celkem optimalni resesni, skoda ze nemas dobre ten pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants