![]() |
|
[Golfing] Collatz Conjecture - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: [Golfing] Collatz Conjecture (/Thread-Golfing-Collatz-Conjecture) |
RE: [Golfing] Collatz Conjecture - Equinox - 08-21-2015 (08-21-2015, 04:26 PM)Shebang Wrote: You're lucky Stuck has no while-loops ;P Maybe you should hop on that. ![]() Also props to you, your little code golf actually taught me something about Python. Thankies to you.
RE: [Golfing] Collatz Conjecture - Jolly - 08-21-2015 (08-21-2015, 04:44 PM)Shebang Wrote: Well, it is a code-golf ;P I'll un-golf a little and explain it though! This is quite clever to be honest! However, why doesn't it get an error since Input() returns a string value, but you are operating with integers. RE: [Golfing] Collatz Conjecture - Eclipse - 08-21-2015 (08-21-2015, 08:46 PM)Jolly Wrote: This is quite clever to be honest! Input doesn't require any arguments. That line takes input from the user and assigns it to n. Also, input has differences in python 2 and 3. RE: [Golfing] Collatz Conjecture - Jolly - 08-21-2015 (08-21-2015, 08:48 PM)eclipse Wrote: Input doesn't require any arguments. That line takes input from the user and assigns it to n. Also, input has differences in python 2 and 3. I see, thanks for that list indexing tip though, learned something new today
RE: [Golfing] Collatz Conjecture - lux - 08-21-2015 Poor little JavaScript code being ignored... RE: [Golfing] Collatz Conjecture - Eclipse - 08-21-2015 (08-21-2015, 08:58 PM)Lux Wrote: Poor little JavaScript code being ignored... If you choose the JavaScript path, you walk down it alone. (08-21-2015, 08:57 PM)Jolly Wrote: I see, thanks for that list indexing tip though, learned something new today No problem. It was Shebang who posted the indexing tip, not me. RE: [Golfing] Collatz Conjecture - Shebang - 08-21-2015 (08-21-2015, 08:46 PM)Jolly Wrote: This is quite clever to be honest! So, here's the difference: In Python 2, we have raw_input(), which reads a string. This is equivalent to Python 3's input(). In Python 2, we have input() too. However, ours essentially performs the operation eval(raw_input()), which interprets the string given and tries to figure out it's type, and casts the value to that. So, with input() in Python 2, you can interpret pretty much any type that exists in Python as input! You can replicate it in Python 3 with eval(input()), but at that point you may as well be using the appropriate name if it's shorter, like int(input()). RE: [Golfing] Collatz Conjecture - Shebang - 08-21-2015 (08-21-2015, 07:59 PM)Stocking Wrote: Maybe you should hop on that. Done! ![]() This doesn't count for anything since I added it after the challenge started though ![]() Code: i"1>""_2%;_3*1+;2/?p"hRE: [Golfing] Collatz Conjecture - Eclipse - 08-21-2015 (08-21-2015, 10:45 PM)Shebang Wrote: Done! I'm thinking of adding stuck to my list of languages to learn. After C (in progress) and possibly Go. RE: [Golfing] Collatz Conjecture - lux - 08-21-2015 (08-21-2015, 10:55 PM)eclipse Wrote: I'm thinking of adding stuck to my list of languages to learn. After C (in progress) and possibly Go. +rep @lux for telling you about Go. |