#aceyduecyh code jam
#30 minute
import random
firstCard = 0
secondCard = 0
thirdCard = 0
playerBet = 0
playerCash = 1000
cycle = True
def winCheck(first,second,third):
if third < first and third > second:
return True
elif first < third and second > third:
return True
else:
return False
def drawNum():
return random.randint(1,14)
def cycleCheck():
flow = input("Continue? (y/n) :").lower()
if flow == 'y':
return True
elif flow == 'n':
return False
else:
print("I'm Sorry, that is not a valid entry...\n")
ret = cycleCheck()
return ret
while cycle == True:
print("In this game, two numbers are randomly generated.\n")
print("You then bet on weither the third number generated will be between the first two\n")
print("You currently have ",playerCash,"$")
cycle = cycleCheck()
firstCard = drawNum()
secondCard = drawNum()
thirdCard = drawNum()
print("First and Second numbers: \n")
print(firstCard, "\n")
print(secondCard, "\n")
playerBet = int(input("Player Bets?: "))
if playerBet >> playerCash:
print("invalid bet...")
continue
elif playerBet == 0:
print("Chicken\n")
print("Third Number :", thirdCard,"\n")
if winCheck(firstCard,secondCard,thirdCard) == True:
playerCash = playerCash + playerBet
print("YOU WIN!!!")
elif winCheck(firstCard,secondCard,thirdCard) == False:
playerCash = playerCash - playerBet
print("Better luck next time")
that was mine, here's Critter's:
#!/usr/bin/python
import random
print "Welcome to the best acey ducey game EVER CREATED (by a person named Critter sitting on a couch in 103) \n"
cash = 100
while True:
print "\ncash: " + str(cash)
card1 = random.randint(1,13)
card2 = random.randint(1,13)
print "Cards dealt: " + str(card1) + ", " + str(card2)
answer = raw_input("Pass or Bet? ").lower()
if "p" in answer:
pass
elif "b" in answer:
bet = int(raw_input("How much you want to bet? "))
card3 = random.randint(1,13)
deck = [card1, card2, card3]
deck.sort()
print "The dealer drew: " + str(card3)
if card3 > card1 and card3 < card2:
print "Awesome! You win (a gambling addiction)!"
cash += bet
else:
print "Bwahahahaha! Ahhahahah.... Oh geeze...\n*wipes tears of laughter from face*\nYou SUCK!"
cash -= bet
and jacobs, aka Phear:
import random
deck = {11:'jack', 12:'queen', 13:'king', 14:'ace'}
for num in xrange(1, 11):
deck[num] = num
money = 100
while True:
print 'You now have', money, 'dollars.'
if money < 1:
print 'You are out of moneys!'
break
for _ in xrange(2):
first_card = random.randint(2, 14)
second_card = random.randint(2, 14)
new_card = random.randint(2, 14)
critterDeck = sorted([first_card, second_card, new_card])
print('here are your next two cards:')
print(deck[first_card])
print(deck[second_card])
try:
bet = int(raw_input('\nWhat is your bet? '))
except ValueError:
bet = 0
if new_card == critterDeck[1]:
money += bet
print(new_card)
print 'Congrats, you win!'
elif bet < 1:
print 'CHICKEN!'
else:
money -= bet
print(new_card)
print 'Sorry! You lose!'
Over all, i makes for a good excersice and later we'll work on collaboration. a good success. Next is OOP programming so we can do real collaborations.