![]() |
|
[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 - Akane - 08-22-2015 (08-21-2015, 10:45 PM)Shebang Wrote: Done! Could you explain how the while loops work? RE: [Golfing] Collatz Conjecture - Shebang - 08-22-2015 (08-22-2015, 01:18 AM)Akane Wrote: Could you explain how the while loops work? 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:
So, what this code does is:
That's basically it! It's essentially a direct conversion of the Python code.
RE: [Golfing] Collatz Conjecture - lux - 08-22-2015 (08-22-2015, 02:42 AM)Shebang Wrote: Sure! Exact conversation of the JS code, too. RE: [Golfing] Collatz Conjecture - Equinox - 08-22-2015 I know this isn't exactly the smallest, and is quite large compared to some other entries, but I am entering since this is sort of a unique entry. I used the Wolfram language, which breaks off from both the Python and NodeJS entries. ![]() Also 69 byte master race! Code: n=10;While[1!=n,Print[n];n=Part[{n/2,(n*3)+1},Mod[n,2]+1]]; Print[n];
RE: [Golfing] Collatz Conjecture - lux - 08-22-2015 (08-22-2015, 03:47 AM)Stocking Wrote: I know this isn't exactly the smallest, and is quite large compared to some other entries, but I am entering since this is sort of a unique entry. I used the Wolfram language, which breaks off from both the Python and NodeJS entries. (08-21-2015, 04:09 PM)eclipse Wrote: from the input I don't see you inputting anything.
RE: [Golfing] Collatz Conjecture - Equinox - 08-22-2015 (08-22-2015, 03:50 AM)Lux Wrote: I don't see you inputting anything. ;w; Completely missed that part (I don't know how to get input from Wolfram, and honestly don't care to learn, so I guess that means I'm disqualified. meh) RE: [Golfing] Collatz Conjecture - lux - 08-22-2015 (08-22-2015, 03:53 AM)Stocking Wrote: ;w; It should still be considered, just a penalty applied. (Such as +10 bytes to score). Go fast Haskell))) https://www.haskell.org/ RE: [Golfing] Collatz Conjecture - Equinox - 08-22-2015 (08-22-2015, 03:55 AM)Lux Wrote: It should still be considered, just a penalty applied. (Such as +10 bytes to score). I guess technically it would be input, since the Wolfram programming cloud itself is in an interactive-mode type of input, though still not the input wanted in this challenge. RE: [Golfing] Collatz Conjecture - Eclipse - 08-22-2015 (08-22-2015, 03:47 AM)Stocking Wrote: I know this isn't exactly the smallest, and is quite large compared to some other entries, but I am entering since this is sort of a unique entry. I used the Wolfram language, which breaks off from both the Python and NodeJS entries. (08-22-2015, 03:55 AM)Lux Wrote: It should still be considered, just a penalty applied. (Such as +10 bytes to score). I agree with Lux, but your program isn't as small as Shebang's so you wouldn't win anyway, and I'd hate to add points to 69, so I'll accept your solution as-is.
RE: [Golfing] Collatz Conjecture - OversouL - 08-22-2015 (08-21-2015, 06:58 PM)Shebang Wrote: Well, firstly, that code doesn't work right Oh, I divided the odd number by 3. XD Code: #include <iostream>
int main(){int n;std::cin >> n;while(n > 1){n%2==0?n/=2:n=n*3+1;std::cout<<n<<" ";}return 0;}I wonder why n*=3+1 doesn't work, like n=n*3+1 ??? Anyway, it's 114 bytes now. Code: #include <iostream>
int main(){int n;std::cin>>n;while(n>1){n%2==0?n/=2:n=n*3+1;std::cout<<n<<" ";}return 0;}110 bytes after removing some spaces. :3 |