No, I'm not a student looking to get my program written for me.
I'm just trying to find the most optimized solution to a problem, and at the same time it makes a decent challenge for /prog/.
The problem :-
Name:
Anonymous2008-05-16 8:14
You have a set of doubly-linked classes. (Yes this is C++).
Each class contains an int of any value.
You must rearrange the links so that every possible combination of numbers is displayed to the console screen.
E.g
class 1 contains 1, 2 contains 2, 3 contains 3.
So it's 123.
Now the program needs to have this output:
123
132
213
231
321
312
First the whole linked list bullshit is retarded Basically a linked list optimized algorithm for this type of problem is retarded. It's like saying hey here is a stack now use it to efficiently randomly access certain numbers, now make it optimized!!! OMG
The fastest implementation of this is basically moronic. There is no "fastest implementation".
The problem of arranging it in every combination is a factorial.
Factorial gets extremely slow the more numbers added.
There really is no optimized way to output them since you basically are forced to take a factorial time algorithm to do so. It's worse then an NP complete problem.
so in ending fuck off.
Name:
Anon2008-05-18 8:13
I'd also love to give advice. Just need to solve the following problem:
>>2
Work with plain old arrays and stop being a faggot. Shit, even more, if i had to solve this, i'd malloc() a fucking array of integers of the size of your linked list.
If you insist it must be OMG OPTIMIZED, then suggest how would some code that does this be useful in real life apps.
Name:
Anonymous2008-05-19 10:50
import List
permu l = map fst $ iterate (concatMap (\(f,s) -> fmap(\x -> (x:f, delete x s)) s)) [([], l)] !! length l
Data.List is one of the fundamental Haskell core libraries. As well disallow C++ solutions from using the STL. All he's using from List is 'delete', and that's a like one-line definition for this usage.
>>36
All I see is THE METAVERSE IS A DANGEROUS PLACE; HOW'S YOUR SECURITY? CALL HIRO PROTAGONIST SECURITY ASSOCIATES FOR A FREE INITIAL CONSULTATION.
Name:
Anonymous2008-05-21 20:36
>>36
Now we need to create an extensible smell description language.
Name:
Anonymous2008-05-22 7:49
Treat a subset of double-linked list as a ring.
***>
/2-3-4\
1< >5
\8-7-6/
<***
==>
/3-4-5\
1-2< |
\8-7-6/
<==
->
/4-5\
1-2-3< >6
\8-7/
<-
(Operation applies within every rotating ring after every turn using whatever order of existing links it has until the ring is back in its initial position. Then outer ring makes its step)