-
as seen on Stack Overflow
- Search for 'Stack Overflow'
This is more of a maths question than programming but I figure a lot of people here are pretty good at maths! :)
My question is: Given a 9 x 9 grid (81 cells) that must contain the numbers 1 to 9 each exactly 9 times, how many different grids can be produced. The order of the numbers doesn't matter…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Can someone please explain algorithm for itertools.permutations routine in Python standard lib 2.6? I see its code in the documentation but don't undestand why it work?
Thanks
Code is:
def permutations(iterable, r=None):
# permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I know you can generate all permutations from a list, using glob or Algorithm::Permute for example - but how do you generate all possible permutations from a regular expression?
I want to do like:
@perms = permute( "/\s[A-Z][0-9][0-9]/" );
sub permute( $regex ) {
# code - put all permutations…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I know you can generate all permutations from a list, using glob or Algorithm::Permute for example - but how do you generate all possible permutations from a regular expression?
i want to do like:
@perms = permute( "/\s[A-Z][0-9][0-9]/" );
sub permute( $regex ) {
# code - put all permutations…
>>> 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