Skip to content

Instantly share code, notes, and snippets.

@ilkermanap
Last active September 13, 2017 20:47
Show Gist options
  • Save ilkermanap/d79ca1491e307df32a56c82bb0fc85c9 to your computer and use it in GitHub Desktop.
Save ilkermanap/d79ca1491e307df32a56c82bb0fc85c9 to your computer and use it in GitHub Desktop.
istek uzerine..
import random
import sys
class Pul:
def __init__(self, renk, sayi):
self.renk = renk
self.sayi = sayi
class Sepet:
def __init__(self, kapasite = 360):
self.toplam = 0
self.kapasite = kapasite
self.pullar = {}
def pulEkle(self, pul):
if pul.renk in self.pullar.keys():
self.pullar[pul.renk] += pul.sayi
else:
self.pullar[pul.renk] = pul.sayi
self.toplam += pul.sayi
if self.toplam >= self.kapasite:
return self.pullar
else:
return None
renksayisi = int(sys.argv[1])
pulsayisi = int(sys.argv[2])
s = Sepet()
for i in range(pulsayisi):
renk = random.randint(1, renksayisi)
sayi = random.randint(1,16)
sonuc = s.pulEkle(Pul(renk,sayi))
if sonuc is not None:
print("sepet doldu", s.toplam)
print(sonuc)
s = Sepet()
print("son sepet", s.toplam)
print(s.pullar)
"""
calistirmak icin,
python tavla.py 10 5000
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment