Den haben wir doppelt, den müssen wir leider abziehen.
Gyroplast
Bildliche Gestaltung ist meine Leidenschaft? In meinem 2025? Un-er-hört!
Die Angabe hat die Schnüffelprüfung schon nicht überstanden, auswendig wusste ich das auch nicht mehr. 5 Joule sind echt wenig, und ein Liter Wasser schon echt viel. 5 Joule erzeuge ich Dir geschätzt mit einem freundlichen Handschlag auf die Wasseroberfläche, davon wird das nicht 1 °K wärmer.
Aus der Schulzeit hängt mir noch heute was im Kopf: 1 Joule entspricht etwa der Kraft, die man auf der Erde aufwendet, um eine Tafel Schokolade (≙ 100 g) einen Meter gerade nach oben zu heben.
Macht doch Watt ihr Volt, ihr kommt euch bestimmt total Coulomb dabei vor.
Und um 1 m³ Wasser um 1 °K zu erwärmen, braucht es offensichtlich ≈ 4.19 Mg · m² · s¯².
DAS WEIẞ MAN DOCH!!
Beeindruckend. Nur um einen Faktor 1000 falsch, aber super freundlich. Wohlfühlbullenscheiße.
Bissken unverschämt, gleich zwei Hackbraten für'n Mittach mitzunehmen.
"I'm not alone here. Gotta setup a k-line to this surfer's cyberjack and ice his codes before he cracks my firewalls!"
TL;DR: You're getting different results for negative or otherwise invalid/unexpected input arguments.
A non-equivalence appears when passing a negative value as arg0 or arg1, which will always result in averageBets == 0
in the example, but >=0 with your code.
The reason for this happening basically hides in your conditional incrementing of games
, which allows for unintended "extra loops" if your conditions desiredGain <= 0
or stake < 1
are not met.
Also, the condition desiredGain = goal - stake; (desiredGain <= 0)
⬄ (goal - stake <= 0)
⬄ (goal <= stake)
in your "win branch" is not equivalent to cash < goal
, returning different results for all arg0 >= arg1
.
The simpler example implementation handles these edge cases implicitly with cash > 0
and cash < goal
, skipping the main work, but still running exactly all tries. It'd be fine, and actually preferable, IMHO, to add explicit input validation to your code to basically abort early, if the input values are out of bounds, but there's always a case to be made for keeping loops and conditions as simple, local, and immutable as possible, to avoid creating sneaky edge cases.
Unfortunately, it is very common for many examples to lack error checking and/or input validation altogether, just like here.
Da hat jemand Mutti gestört.
Durch sorgfältige Materialauswahl und patentierte Bearbeitungstechnik ist ein Hackenriemen überflüssig! Statt dessen halten tausende hölzerne Widerhaken die Fußsohle garantiert rutschfest an Ort und Stelle, ganz natürlich und biologisch. Genial!
Consider a key pair, consisting of two brutally large numbers, but otherwise pretty much identical. Magical math exists that makes it so that if you math your data with one of these brutally large numbers, you get the original data back only if you math it with the other large number. That's basically it.
Now we slap convention onto this, and keep one of the paired, large numbers a secret, and call it our private key, the other number is disseminated and called the public key for that reason.
Now everyone can math data with your public key, so that only the paired private key, which only you know, can de-math it. This is encryption/decryption.
Signing is very similar, but now you use your private key, which only you know, to math a digest of your data, and all the world can de-math this correctly only with your public key, thus proving it was indeed your private key used to math the data in the first place, and by extension attribute the signature to your public key identity. Your private key is never known to anyone but you, which is an essential difference to "classical" symmetric encryption with a shared secret.
You may realize how easily a code signature can become a liability, if you fail to keep your private key secret for any reason. You can be trivially impersonated, with basically no chance of recourse or deniability with an SSH key, while you can at least invalidate a GPG key publicly and mark it as "stolen" that way. This is potentially very important, if there's any legal meaning attached to your signature, and if not, why bother with code signing in the first place, if "trust me bro" is well enough.
Das schlägt langsam wirklich dem Fass die Krone in's Gesicht!