Program Pearls: Difference between revisions
Jump to navigation
Jump to search
(New page: This page simply list some nice piece of programs found around... == Sudoku solver == Here a very short Sudoku solver. Seen [http://cboard.cprogramming.com/cplusplus-programming/85307-de...) |
|||
Line 21: | Line 21: | ||
% ./sudoku.exe 123456789456789123789123456231564897564897231897231564312645978645978302000000000 |
% ./sudoku.exe 123456789456789123789123456231564897564897231897231564312645978645978302000000000 |
||
</source> |
</source> |
||
== Kuhn-Munkres algorithm == |
|||
The ''Kuhn-Munkres algorithm'' or ''[http://en.wikipedia.org/wiki/Hungarian_algorithm Hungarian algorithm]'' is a combinatorial optimization algorithm that solves the assignment problem in polynomial time. |
|||
Example of programs: |
|||
* '''[http://www.qtrac.eu/alt_key.html Alt_Key]''' — Find instantly the best keyboard accelerators in menu option tests and dialog labels. |
Latest revision as of 15:11, 19 November 2013
This page simply list some nice piece of programs found around...
Sudoku solver
Here a very short Sudoku solver. Seen here.
#include <stdio.h>
void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
/3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
Enters the grid to solve as a command-line parameter, using 0 for empty space:
% gcc sudoku.c -o sudoku
% ./sudoku.exe 123456789456789123789123456231564897564897231897231564312645978645978302000000000
Kuhn-Munkres algorithm
The Kuhn-Munkres algorithm or Hungarian algorithm is a combinatorial optimization algorithm that solves the assignment problem in polynomial time.
Example of programs:
- Alt_Key — Find instantly the best keyboard accelerators in menu option tests and dialog labels.