-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have n elements. For the sake of an example, let's say, 7 elements, 1234567. I know there are 7! = 5040 permutations possible of these 7 elements.
I want a fast algorithm comprising two functions:
f(number) maps a number between 0 and 5039 to a unique permutation, and
f'(permutation) maps the…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello!
I want to do permutation in perl. For example I have three arrays. ["big", "tiny", "small"] and then I have ["red", "yellow", "green"] and also ["apple", "pear", "banana"].
How do I get:
["big", "red", "apple"]
["big", "red", "pear"]
..etc..
["small", "green", "banana"]
I understand this…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Continuing to learn prolog, I'm trying to write a permutation(L1, L2) predicate. It should return true, only if L1 can be made up of all elements in L2. My code so far is the following:
permutation([], []).
permutation([H|T], L2) :- remove(L2, H, R), permutation(T, R).
Assuming that the predicate…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Let say a=[A, B, C, D], each element has a weight w, and is set to 1 if selected, 0 if otherwise. I'd like to generate permutation in the below order
1,1,1,1
1,1,1,0
1,1,0,1
1,1,0,0
1,0,1,1
1,0,1,0
1,0,0,1
1,0,0,0
Let's w=[1,2,3,4] for item A,B,C,D ... and max_weight = 4. For each permutation…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I'm interested making an implementation of the 14-15 puzzle:
I'm creating an array with the values 0 - 15 in increasing order:
S = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
Now, what I want to do is shuffle them to create a new instance of the puzzle. However, I know that if I…
>>> More
-
as seen on Super User
- Search for 'Super User'
I'm just wonder, what the differences are between creating a BMP file algorithm and JPG file algorithm ?
If you know the others images' format algorithm, please post them.
Thanks.
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hii..
Can anybody help me to find an algorithm in Java code to find synonyms of a search word based on the context and I want to implement the algorithm with WordNet database.
For example, "I am running a Java program". From the context, I want to find the synonyms for the word "running", but the…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello,
Im doing a Java application and Im facing some doubts in which concerns performance.
I have a PriorityQueue which guarantees me the element removed is the one with greater priority. That PriorityQueue has instances of class Event (which implements Comparable interface). Each Event is associated…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
So I have Image like this
I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea)
I need algorithm for finding all straight lines on it by just reading colors of pixels. No hard math, no Haar, no Hough. Some algorithm which would be based on points…
>>> More
-
as seen on Game Development
- Search for 'Game Development'
So i implemented a Quad tree in Java for my 2D game and everything works fine except for when i run my collision detection algorithm, which checks if a object has hit another object and which side it hit.My problem is 80% of the time the collision algorithm works but sometimes the objects just go…
>>> More