ich binns wieder HAUPTSCHULE !
ich habe 72 sitzplätze davon sind x belegt 1-72
die sollen in 6 Blöcke gleichmässig verteilt werden
x/6 der rest von block 1 her je +1 bis nix mehr da ist
bei x =52 sollte es so aussehen
platz_belegt =[9,9,9,9,8,8]
Bitte um Hilfe
mathematiches zerlegungsproblem
so in etwas sollte es dann doch laufen !
Code: Alles auswählen
platze=52
block= platze / 6
print block
rest = platze-(block*6)
print rest
platz_belegt =[]
for i in xrange(6):
if rest >0:
zahl= block +1
platz_belegt.append(zahl)
rest -=1
else:
zahl=block
platz_belegt.append(zahl)
print platz_belegt
auf die schnelle:
Code: Alles auswählen
seats = 52
row_cnt = 6
rows = [seats/row_cnt for i in range(row_cnt)]
for i in range(seats%row_cnt):
rows[i] +=1
[url=http://wiki.python-forum.de/PEP%208%20%28%C3%9Cbersetzung%29]PEP 8[/url] - Quak!
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]
Code: Alles auswählen
a, b = divmod(52, 6)
print [a + 1 if i < b else a for i in xrange(6)]
HWK
das habe ich gesuchtHWK hat geschrieben:MfGCode: Alles auswählen
a, b = divmod(52, 6) print [a + 1 if i < b else a for i in xrange(6)]
HWK
[url=http://wiki.python-forum.de/PEP%208%20%28%C3%9Cbersetzung%29]PEP 8[/url] - Quak!
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]