All pastes #186975 Raw Edit

Anonymous

public text v1 · immutable
#186975 ·published 2006-09-30 18:01 UTC
rendered paste body
Sep 30 18:47:20 <birkenfeld>	also
Sep 30 18:47:37 <blinx>	ok, also hier
Sep 30 18:48:03 <birkenfeld>	wenn du ins 3er-system konvertierst, brauchst du nur die ziffern 0..2
Sep 30 18:48:17 <blinx>	dann fllt der Rest weg, ok klar
Sep 30 18:48:24 <birkenfeld>	ok
Sep 30 18:48:34 <birkenfeld>	dann musst du dir berlegen wie die stellensysteme aufgebaut sind
Sep 30 18:48:35 <birkenfeld>	sprich:
Sep 30 18:48:37 <blinx>	als was soll ich das nun speichern, tuple, liste oder so?
Sep 30 18:48:44 <birkenfeld>	blinx tuple oder liste, egal
Sep 30 18:48:48 <blinx>	ok
Sep 30 18:48:52 <blinx>	fahre fort
Sep 30 18:49:53 <birkenfeld>	wenn man die stellen von hinten zhlt
Sep 30 18:50:06 <blinx>	ja
Sep 30 18:50:09 <birkenfeld>	dann sind an der 0. stelle die einer
Sep 30 18:50:14 <birkenfeld>	an der 1. stelle die "zehner"
Sep 30 18:50:15 <birkenfeld>	etc.
Sep 30 18:50:15 <blinx>	ja
Sep 30 18:50:26 <birkenfeld>	also holst du dir zuerst die einer
Sep 30 18:50:34 <birkenfeld>	weit du wie das geht?
Sep 30 18:50:46 <blinx>	dmom
Sep 30 18:51:59 <blinx>	liste = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Sep 30 18:52:08 <blinx>	liste[0]
Sep 30 18:52:12 <blinx>	-> 1
Sep 30 18:52:14 <blinx>	oder`
Sep 30 18:52:16 <blinx>	?
Sep 30 18:52:18 <birkenfeld>	n
Sep 30 18:52:20 <birkenfeld>	z.B.
Sep 30 18:52:22 <birkenfeld>	zahl = 1234
Sep 30 18:52:28 <birkenfeld>	wie kriegst du die einer raus?
Sep 30 18:52:40 <blinx>	also die 4
Sep 30 18:52:41 <blinx>	hm
Sep 30 18:52:57 <blinx>	eigentlich ka
Sep 30 18:52:58 <blinx>	sorry
Sep 30 18:53:08 <blinx>	er soll nur die hintere stelle lesen
Sep 30 18:53:13 <blinx>	bzw. beachten..
Sep 30 18:53:17 <birkenfeld>	genau
Sep 30 18:53:22 <blinx>	naja, nun wei ich nicht wei
Sep 30 18:53:26 <blinx>	*wie
Sep 30 18:53:27 <birkenfeld>	mit modulo
Sep 30 18:53:30 <birkenfeld>	zahl % 10
Sep 30 18:53:41 <blinx>	moment
Sep 30 18:53:50 <blinx>	modulo ist ja der rest einer division
Sep 30 18:54:04 <birkenfeld>	genau
Sep 30 18:54:21 <blinx>	bingo funzt
Sep 30 18:54:37 <blinx>	das system von modulo ist mir im mom aber noch nicht so klar
Sep 30 18:55:41 <blinx>	wieso muss ich denn durch 10 dividieren?
Sep 30 18:56:09 <birkenfeld>	stell dirs so vor:
Sep 30 18:56:25 <birkenfeld>	du schmeit alles was durch 10 teilbar ist weg
Sep 30 18:56:34 <birkenfeld>	dann bleiben die einer brig
Sep 30 18:56:40 <blinx>	ah..
Sep 30 18:56:42 <blinx>	der ist gut
Sep 30 18:56:49 <blinx>	kannst gut erklren..
Sep 30 18:56:54 <blinx>	habs verstanden!
Sep 30 18:56:55 <blinx>	danke
Sep 30 18:57:01 <blinx>	ok
Sep 30 18:57:14 <blinx>	wenn ich die 10er nun haben will, dann 1234 %100
Sep 30 18:57:22 <birkenfeld>	nicht ganz
Sep 30 18:57:28 <birkenfeld>	da bleiben ja 34 brig
Sep 30 18:57:39 <blinx>	mom
Sep 30 18:59:07 <blinx>	dann soll er ja die letzte ziffer vergessen
Sep 30 18:59:12 <birkenfeld>	genau
Sep 30 18:59:18 <birkenfeld>	also: dazu machst du (1234 // 10) % 10
Sep 30 18:59:32 <blinx>	ok
Sep 30 18:59:37 <blinx>	was ist denn nu 1234? 
Sep 30 18:59:41 <blinx>	sorry
Sep 30 18:59:45 <blinx>	 //
Sep 30 18:59:57 <birkenfeld>	/ ist "floor division"
Sep 30 19:00:02 <birkenfeld>	 //
Sep 30 19:00:19 <blinx>	was ist denn das?
Sep 30 19:00:29 <birkenfeld>	d.h. du teilst durch, aber schmeit die kommastellen weg
Sep 30 19:01:04 <birkenfeld>	-> 1234 // 10 = 123
Sep 30 19:01:27 <blinx>	ich knnte mir das so vorstellen: 1234 %10 =4 1234-4=123
Sep 30 19:01:56 <blinx>	d.h. zahl %10 = x zahl-x= zahlohne die letzte stelle...
Sep 30 19:01:57 <blinx>	?
Sep 30 19:02:01 <birkenfeld>	1234-4 ist ja 1230
Sep 30 19:02:14 <blinx>	stimmt
Sep 30 19:02:15 <blinx>	mist
Sep 30 19:02:39 <blinx>	alles kompliziert
Sep 30 19:02:59 <blinx>	ok, naja, system ist jetzt egal, wei ja, was gemeint is..
Sep 30 19:03:07 <blinx>	nun haben wir die 10er
Sep 30 19:03:44 <birkenfeld>	ich bin mal ne halbe stunde weg
Sep 30 19:03:59 <blinx>	ok
Sep 30 19:04:09 <blinx>	hast du nachher noch ein wenig zeit?
Sep 30 19:14:26 <birkenfeld>	re
Sep 30 19:14:30 <birkenfeld>	ging doch schneller :)
Sep 30 19:19:56 <blinx>	fein
Sep 30 19:20:01 <blinx>	hast du denn noch lust?
Sep 30 19:20:14 <birkenfeld>	sicher
Sep 30 19:20:15 <blinx>	also dich mit mir rumzuschlagen...?
Sep 30 19:20:20 <blinx>	ok
Sep 30 19:20:21 <birkenfeld>	jetzt haben wirs ja gleich
Sep 30 19:20:29 <blinx>	naja, mal hoffen
Sep 30 19:20:29 <birkenfeld>	also zusammenfassung bisher
Sep 30 19:20:35 <blinx>	also, hab mir was berlegt:
Sep 30 19:20:38 <birkenfeld>	ja
Sep 30 19:20:46 <blinx>	er soll die lnge der zahl rausfinden
Sep 30 19:20:49 <blinx>	len(zahl)
Sep 30 19:20:59 <blinx>	die ja nun im dezimalsys ist
Sep 30 19:21:33 <birkenfeld>	also len(str(zahl))
Sep 30 19:22:30 <blinx>	http://wiki.python.de/Paste/230
Sep 30 19:22:37 <blinx>	naja, da kommt nun ein error
Sep 30 19:23:34 <birkenfeld>	was denn fr einer?
Sep 30 19:23:50 <blinx>	sys:1: DeprecationWarning: Non-ASCII character '\xf6' in file ./zahlensysteme.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Sep 30 19:23:53 <blinx>	  File "./zahlensysteme.py", line 51
Sep 30 19:23:55 <blinx>	    break
Sep 30 19:23:58 <blinx>	    ^
Sep 30 19:24:00 <blinx>	das hatte ich schon mal irgends
Sep 30 19:24:03 <blinx>	SyntaxError: invalid syntax
Sep 30 19:24:12 <birkenfeld>	"else:l"
Sep 30 19:24:40 <blinx>	oha
Sep 30 19:24:46 <blinx>	was macht das?
Sep 30 19:25:01 <blinx>	1 ist ja schon da
Sep 30 19:25:19 <birkenfeld>	nein, das ist der fehler
Sep 30 19:26:43 <blinx>	was heit das?
Sep 30 19:26:52 <birkenfeld>	dass das "l" weg muss
Sep 30 19:26:55 <blinx>	hm, jetz isser weg
Sep 30 19:27:23 <blinx>	ok weita
Sep 30 19:27:33 <birkenfeld>	was hast dir jetzt weiter berlegt?
Sep 30 19:28:34 <blinx>	je weiterer stelle soll er also fr x (1234 // 10x) %10 eine Null dranmachen
Sep 30 19:28:38 <blinx>	also ne for schleife?
Sep 30 19:29:04 <blinx>	for x in range... oder so?
Sep 30 19:29:07 <blinx>	hm
Sep 30 19:29:16 <blinx>	was meinste?
Sep 30 19:29:19 <birkenfeld>	jo, klingt gut
Sep 30 19:29:28 <blinx>	ich kanns nicht fassen
Sep 30 19:29:43 <birkenfeld>	die frage ist halt, wie die null dranmachen
Sep 30 19:30:58 <blinx>	hm
Sep 30 19:31:02 <blinx>	gute frage
Sep 30 19:31:09 <birkenfeld>	also
Sep 30 19:31:10 <blinx>	(1234 // 10
Sep 30 19:31:16 <blinx>	+0..
Sep 30 19:31:17 <blinx>	ne
Sep 30 19:31:19 <birkenfeld>	fr x = 0 wollen wir 1
Sep 30 19:31:19 <blinx>	sorry
Sep 30 19:31:23 <birkenfeld>	fr x = 1 wollen wir 10
Sep 30 19:31:29 <birkenfeld>	fr x = 2 wollen wir 100
Sep 30 19:31:29 <birkenfeld>	etc.
Sep 30 19:31:34 <blinx>	das sind die stellen, ok
Sep 30 19:31:42 <blinx>	stelle 0 = die einer
Sep 30 19:31:54 <blinx>	stelle 1 die 10er
Sep 30 19:31:55 <blinx>	usw.
Sep 30 19:31:55 <blinx>	ok, verstanden
Sep 30 19:31:55 <birkenfeld>	welche funktion bildet 0 -> 1, 1 -> 10, 2 -> 100 ab?
Sep 30 19:32:03 <blinx>	die liste[]
Sep 30 19:32:14 <birkenfeld>	n
Sep 30 19:32:25 <blinx>	stimmt
Sep 30 19:32:38 <birkenfeld>	du brauchst 10**x
Sep 30 19:32:56 <blinx>	hm
Sep 30 19:33:03 <blinx>	verstehe ich leider nicht..
Sep 30 19:33:07 <birkenfeld>	10 hoch x
Sep 30 19:33:11 <blinx>	ah
Sep 30 19:33:56 <blinx>	die rechte stelle ist die basis hoch 0, die zweite von rechts die basis hoch 2 etc
Sep 30 19:34:02 <birkenfeld>	genau
Sep 30 19:34:11 <blinx>	weiter
Sep 30 19:34:33 <birkenfeld>	also:
Sep 30 19:34:35 <blinx>	er soll das x immer um 1 vergrern
Sep 30 19:34:41 <birkenfeld>	die gewnschte ziffer ist
Sep 30 19:34:47 <birkenfeld>	(1234 // 10**x) % 10
Sep 30 19:35:06 <blinx>	hm
Sep 30 19:35:16 <blinx>	ist mir nicht ganz klar
Sep 30 19:35:43 <birkenfeld>	das hast du doch oben schon geschrieben
Sep 30 19:35:53 <birkenfeld>	<blinx> je weiterer stelle soll er also fr x (1234 // 10x) %10 eine Null dranmachen
Sep 30 19:36:15 <blinx>	ah
Sep 30 19:36:22 <blinx>	10 = 100
Sep 30 19:36:28 <blinx>	10 =1000
Sep 30 19:36:37 <blinx>	naja, selten dmlich...
Sep 30 19:36:43 <blinx>	von mir..
Sep 30 19:36:57 <blinx>	pro null also den exponenten um 1 erhhen
Sep 30 19:37:07 <blinx>	d.h.: for x in range:
Sep 30 19:37:41 <blinx>	(1234 //10**x) % 10
Sep 30 19:37:57 <blinx>	der beginnt ja automatisch mit x bei 0, oder?
Sep 30 19:38:12 <birkenfeld>	jo
Sep 30 19:38:34 <blinx>	ok
Sep 30 19:38:37 <blinx>	und nun...?
Sep 30 19:38:51 <blinx>	jetzt haben wir jede stelle fr sich?
Sep 30 19:39:08 <birkenfeld>	das ist dann unser index in die oben erstellte liste
Sep 30 19:39:18 <blinx>	ok
Sep 30 19:39:25 <blinx>	wie msste denn dann der code aussehen?
Sep 30 19:39:34 <birkenfeld>	res = ""
Sep 30 19:39:40 <birkenfeld>	for x in range():
Sep 30 19:39:41 <blinx>	?
Sep 30 19:39:45 <blinx>	ok
Sep 30 19:40:04 <birkenfeld>	 res = ziffern[(zahl // basis**x) % basis] + res
Sep 30 19:40:28 <blinx>	ok, res ist klar, ziffern?
Sep 30 19:40:42 <birkenfeld>	ziffern ist die liste
Sep 30 19:41:19 <blinx>	basis wre nun was?
Sep 30 19:41:28 <blinx>	ich habe das ausgangssys
Sep 30 19:41:32 <blinx>	und das zielsys
Sep 30 19:41:40 <blinx>	zielsys?
Sep 30 19:41:51 <birkenfeld>	basis ist zielsys
Sep 30 19:42:12 <blinx>	o
Sep 30 19:42:12 <blinx>	k
Sep 30 19:42:17 <blinx>	weiter
Sep 30 19:42:45 <blinx>	nun mal die ausgabe anschauen
Sep 30 19:42:52 <birkenfeld>	es geht noch nicht so
Sep 30 19:43:06 <birkenfeld>	range() braucht einen parameter
Sep 30 19:43:28 <blinx>	welche gibt es denn zur auswahl?
Sep 30 19:43:44 <birkenfeld>	naja, range() braucht einen endpunkt
Sep 30 19:44:01 <blinx>	also die lnge!
Sep 30 19:44:09 <blinx>	laenge haben wir
Sep 30 19:44:12 <birkenfeld>	ja, aber die lnge im neuen system
Sep 30 19:44:16 <birkenfeld>	nicht die im dezimalsystem
Sep 30 19:44:34 <blinx>	hm, wie finden wir das denn raus
Sep 30 19:44:47 <birkenfeld>	schwierig...
Sep 30 19:45:03 <birkenfeld>	d.h. lieber keine for-schleife
Sep 30 19:45:06 <blinx>	eigentlich bruchten wir dann ja die umgerechnete zahl..
Sep 30 19:45:07 <blinx>	ok
Sep 30 19:45:23 <birkenfeld>	du brauchst eine abbruchbedingung
Sep 30 19:45:41 <blinx>	wenn len = ?? then break?
Sep 30 19:45:45 <birkenfeld>	n
Sep 30 19:45:50 <birkenfeld>	len haben wir nicht
Sep 30 19:45:58 <birkenfeld>	aber was anderes
Sep 30 19:46:02 <blinx>	mom
Sep 30 19:46:10 <blinx>	wann soll range aufhren
Sep 30 19:46:11 <blinx>	?
Sep 30 19:46:15 <birkenfeld>	das wissen wir nicht
Sep 30 19:46:23 <blinx>	hm
Sep 30 19:46:35 <blinx>	wir haben die lnge der ausgangszahl
Sep 30 19:46:41 <birkenfeld>	das ntzt nix
Sep 30 19:46:47 <blinx>	genau
Sep 30 19:46:51 <birkenfeld>	du brauchst eine andere bedingung
Sep 30 19:46:54 <blinx>	das zielsys
Sep 30 19:47:02 <blinx>	und das ausgangssys
Sep 30 19:47:14 <blinx>	ne, was anderes
Sep 30 19:47:19 <blinx>	komm, sag... :)
Sep 30 19:47:35 <birkenfeld>	was passiert wenn 10**x grer als zahl ist?
Sep 30 19:48:01 <blinx>	hm
Sep 30 19:48:15 <blinx>	also, 10 hoch x > 1234
Sep 30 19:48:20 <birkenfeld>	genau
Sep 30 19:48:32 <blinx>	also, 10 hoch 8 > 1234
Sep 30 19:48:37 <birkenfeld>	z.B.
Sep 30 19:48:45 <birkenfeld>	auch schon 10 hoch 5 > 1234
Sep 30 19:48:48 <blinx>	dann soll er abbrechen
Sep 30 19:48:53 <blinx>	ja klar
Sep 30 19:49:03 <birkenfeld>	genau
Sep 30 19:49:12 <birkenfeld>	und was ist dann 1234 // 10**5 ?
Sep 30 19:49:14 <blinx>	dann braucht er die stellen nicht weiter zu ...
Sep 30 19:49:31 <blinx>	nix
Sep 30 19:49:33 <blinx>	0
Sep 30 19:49:36 <birkenfeld>	genau!
Sep 30 19:49:44 <birkenfeld>	also sobald das 0 wird knnen wir abbrechen
Sep 30 19:49:48 <blinx>	ok
Sep 30 19:49:49 <blinx>	also:
Sep 30 19:49:52 <blinx>	while 1:
Sep 30 19:49:53 <blinx>	...
Sep 30 19:49:59 <birkenfeld>	ja
Sep 30 19:50:10 <blinx>	if zahl // basis hoch ??
Sep 30 19:50:24 <blinx>	then false
Sep 30 19:50:26 <blinx>	?
Sep 30 19:50:27 <birkenfeld>	bah
Sep 30 19:50:30 <blinx>	ja
Sep 30 19:50:31 <blinx>	isses
Sep 30 19:50:34 <blinx>	ich gebs zu
Sep 30 19:50:40 <birkenfeld>	if zahl // basis**x == 0:
Sep 30 19:50:41 <birkenfeld>	    break
Sep 30 19:50:51 <blinx>	auch gut
Sep 30 19:51:15 <blinx>	ja
Sep 30 19:51:24 <blinx>	und was soll er vorher machen
Sep 30 19:51:26 <blinx>	?
Sep 30 19:51:41 <blinx>	die for schleife hatten wir eben ausgeschlossen..
Sep 30 19:52:14 <birkenfeld>	while 1:
Sep 30 19:52:17 <birkenfeld>	hatten wir doch schon
Sep 30 19:52:29 <blinx>	aha, also doch nicht bah
Sep 30 19:52:50 <blinx>	*g*
Sep 30 19:52:55 <blinx>	witzig mit dir...
Sep 30 19:52:57 <blinx>	naja, weiter
Sep 30 19:53:19 <blinx>	er soll wie gesagt ne stelle dranhngen also x=+ 1
Sep 30 19:53:20 <blinx>	?
Sep 30 19:53:23 <birkenfeld>	nein, bah war nur alles ab "if"
Sep 30 19:53:29 <birkenfeld>	genau
Sep 30 19:53:40 <blinx>	while 1:
Sep 30 19:53:48 <blinx>	x =+1
Sep 30 19:54:05 <blinx>	if zahl // basis**x == 0
Sep 30 19:54:06 <blinx>	break
Sep 30 19:54:17 <birkenfeld>	genau
Sep 30 19:54:37 <blinx>	naja, gerechnet hat er ja noch nix?
Sep 30 19:54:59 <blinx>	hat einfach x+1 gemacht und geguckt, ob zahl // basis**x ==0
Sep 30 19:55:03 <birkenfeld>	n, das mit res muss wieder zurck
Sep 30 19:55:07 <blinx>	was wollten wir eigentlich?
Sep 30 19:55:20 <blinx>	sorry, hab den berblick verloren
Sep 30 19:55:45 <birkenfeld>	wir wollten jetzt die stelle berechnen und an den ausgangsstring anhngen
Sep 30 19:56:17 <blinx>	nun haben wir geprft, ob die zahl auch immer kleiner ist, als....?
Sep 30 19:56:27 <blinx>	muss mir mal kommentare reinschreiben
Sep 30 19:56:33 <blinx>	sonst blicke ich gar net mehr durch
Sep 30 19:57:32 <blinx>	ob x auch kleiner ist als die anzahl der stellen
Sep 30 19:58:47 <blinx>	ne, ob die l hoch x auch nicht grer als die wirkliche zahl ist?
Sep 30 19:58:51 <blinx>	mist
Sep 30 19:59:01 <blinx>	ne, ob die basis hoch x auch nicht grer als die wirkliche zahl ist