I need help Sup Forums. I need to write a program (in C) for a class, that would get all the solutions to the 5 queen domination problem
5 queen domination
tfw you have an easy checkmate but upgrade as many pawns as you can instead to piss off your friend John who won't resign
Literally freshman work. Look up backtracking
>tfw you forget about stalemate
>tfw u never even knew about stalemate
>tfw u review ur match and realise u missed mate in 2 5 times in a row
Take your "queen domination" shit to /gif/, nobody is interested in your weird fetishes here.
kek
>(in C)
Dropped
>take 64bit integer
>iterate over all 7.624.512 permutations (5 1s and rest 0s) and check if the rules are adhered to
anyone any better ideas?
bye pajeet, have a happy javascript
isn't there a lot more permuations than that?
5 out of 64
[spoiler]no[/spoiler]
for fucks sake
64 * 63 * 62 * 61 * 60
you don't need to read a combinatorics book to understand that
Also, the checking part might be very interesting, it could involve a lot of nice bit fiddling. I'm probably going to do this.
that's too much, you don't need all those
I think even my number was too high
you need way less permutations for the queens problem
some permutations are the same permutation as others from another viewing angle
so I'd say it depends
do you need ALL possible positions on the board or just all the positions of the queens i depending of the other queens positions?
my engrish be very gud 2day I cee
How did you get that number? Now that I include horizontal and vertical symmetry, it's down to 229 million, but it's still much bigger than yours.
binomial coefficient
1- Start with empty board, copy it
2- Place a queen on copy
3- Remove threathened squares from copy
4- Repeat 2; if copy becomes empty, backtrack (remove last queen); if 5 queens on board, you win
Why do you have to turn everything into a maze?
complicated and takes too long
Do you guys hate optimization? It's a C class ffs
>optimization
Where? Did I miss it?
Can't find any in your post
It was a joke, man. I appreciate different approaches to the same problem.
I never understood exercises like this.
This is an exercise in logic, not in C.
What's logic got to do with C?
honestly
this is still better than
>send this server a hello world
3 lines code exercise
with logic like this you have to write some "more" code
So how fast can you do it Sup Forums?
Ill start at a modest 100ms
> time python queenst.py
[[1 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0]]
0.08user 0.00system 0:00.09elapsed 96%CPU
>1 solution
fucking read the OP
also
>100ms
I can fucking think of one solution faster than that
is it something along the lines of...
> from chess import queens
Sry just woke up
> time python queenst.py
Solutions: 10
0.20user 0.00system 0:00.20elapsed 99%CPU
Only numpy desu
Post this on stack overflow, also look into backtracking.
Also python -c 'import numpy' takes 100ms
Jesus Christ python is shit