Login Register


[Golfing] Collatz Conjecture filter_list
Author
Message
RE: [Golfing] Collatz Conjecture #23
(08-22-2015, 02:42 AM)Shebang Wrote: Sure!

So, in this instance, h is the character that triggers the while-loop. What it does is pop off the top three items from the stack:
  • A string, which is the body of the while loop.
  • A string, which is the condition the while loop executes on
  • A value, which is passed to the condition and body.
In this case:
  • _2%;_3*1+;2/?p is the body of the loop.
  • 1> is the condition
  • i is the value (coming from user input in this case).

So, what this code does is:
  • Take user input.
  • While this user input is greater than 1:
    • Check if it's divisible by 2.
    • If so, divide it by 2.
    • If not, multiply by 3 and add 1.
    • Print out the result.

That's basically it! Smile It's essentially a direct conversion of the Python code.

Exact conversation of the JS code, too.

Reply





Messages In This Thread
[Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 04:09 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 04:26 PM
RE: [Golfing] Collatz Conjecture - by Jolly - 08-21-2015, 04:37 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 04:44 PM
RE: [Golfing] Collatz Conjecture - by Jolly - 08-21-2015, 08:46 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 09:13 PM
RE: [Golfing] Collatz Conjecture - by Equinox - 08-21-2015, 07:59 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 10:45 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 04:27 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 04:31 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 04:53 PM
RE: [Golfing] Collatz Conjecture - by lux - 08-21-2015, 06:10 PM
RE: [Golfing] Collatz Conjecture - by OversouL - 08-21-2015, 06:23 PM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-21-2015, 06:58 PM
RE: [Golfing] Collatz Conjecture - by OversouL - 08-22-2015, 09:55 AM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-22-2015, 12:29 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 08:48 PM
RE: [Golfing] Collatz Conjecture - by Jolly - 08-21-2015, 08:57 PM
RE: [Golfing] Collatz Conjecture - by lux - 08-21-2015, 08:58 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 09:04 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-21-2015, 10:55 PM
RE: [Golfing] Collatz Conjecture - by lux - 08-21-2015, 11:14 PM
RE: [Golfing] Collatz Conjecture - by Akane - 08-22-2015, 01:18 AM
RE: [Golfing] Collatz Conjecture - by Shebang - 08-22-2015, 02:42 AM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 02:51 AM
RE: [Golfing] Collatz Conjecture - by Equinox - 08-22-2015, 03:47 AM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 03:50 AM
RE: [Golfing] Collatz Conjecture - by Equinox - 08-22-2015, 03:53 AM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 03:55 AM
RE: [Golfing] Collatz Conjecture - by Equinox - 08-22-2015, 03:58 AM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-22-2015, 08:35 AM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 02:48 PM
RE: [Golfing] Collatz Conjecture - by OversouL - 08-22-2015, 04:16 PM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 03:58 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-22-2015, 04:07 PM
RE: [Golfing] Collatz Conjecture - by lux - 08-22-2015, 04:18 PM
RE: [Golfing] Collatz Conjecture - by OversouL - 08-22-2015, 04:46 PM
RE: [Golfing] Collatz Conjecture - by Eclipse - 08-22-2015, 05:28 PM



Users browsing this thread: 1 Guest(s)