@EyDu:
Die Grundregeln der Mathematik sind mir durchaus bekannt. Tut mir leid, dass dich mein Enthusiasmus, dies einmal an größeren Zahlen zu sehen, derart gelangweilt hat...
Collatz-Vermutung
- __blackjack__
- User
- Beiträge: 14396
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Beim Video gefiel mir der Kommentar von @peterboy209: „Vorhin ist mir der Beweis gelungen. Leider hat meine Frau mich was gefragt was mich abgelenkt hat und danach ist mir die Lösung entfallen. Sorry“ 
“It is well known that a vital ingredient of success is not knowing that what you're attempting can't be done.”
— Terry Pratchett, Equal Rites
— Terry Pratchett, Equal Rites
- __blackjack__
- User
- Beiträge: 14396
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
@narpfel: Der Funktionsname ist viel zu lang, und warum die beiden Lambda-Funktionen? Wenn man das kurz haben möchte, komme ich auf 49 Bytes runter:
Code: Alles auswählen
f=lambda n:[n]+(n-1 and f((n//2,3*n+1)[n%2])or[])“It is well known that a vital ingredient of success is not knowing that what you're attempting can't be done.”
— Terry Pratchett, Equal Rites
— Terry Pratchett, Equal Rites
- __blackjack__
- User
- Beiträge: 14396
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Das hier, oder habe ich noch ein anderes übersehen?
Code: Alles auswählen
f=lambda n:[n]+(n-1and f((n//2,3*n+1)[n%2])or[])“It is well known that a vital ingredient of success is not knowing that what you're attempting can't be done.”
— Terry Pratchett, Equal Rites
— Terry Pratchett, Equal Rites
Code: Alles auswählen
f=lambda n:n-1and[n]+f((n//2,3*n+1)[n%2])or[1]
- __blackjack__
- User
- Beiträge: 14396
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Dieses eine Byte sollte man geniessen solange es noch geht, denn das wird in absehbarer Zeit abgeschafft, wie die Dokumentation von Python 3.14 verspricht:
Currently Python accepts numeric literals immediately followed by keywords, for example ``0in x, 1or x, 0if 1else 2``. It allows confusing and ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as ``[0x1 for x in y]`` or ``[0x1f or x in y]``). A syntax warning is raised if the numeric literal is immediately followed by one of keywords ``and``, ``else``, ``for``, ``if``, ``in``, ``is`` and ``or``. In a future release it will be changed to a syntax error.
“It is well known that a vital ingredient of success is not knowing that what you're attempting can't be done.”
— Terry Pratchett, Equal Rites
— Terry Pratchett, Equal Rites
