Format fixes in 1994/imc/README.md

This commit is contained in:
Cody Boone Ferguson committed 2023-04-02 08:51:09 -07:00
1 parent 84c15f57fc
commit b3255975e2
1 file changed
+47 -45
+47 -45
View File
@@ -1,80 +1,82 @@
# Most Obfuscated Algorithm: # Most Obfuscated Algorithm:
Ian Collier Ian Collier
Oxford University Oxford University
57 Wyndham Avenue (home address) 57 Wyndham Avenue (home address)
BOLTON BOLTON
BL3 4LG BL3 4LG
England England
## To build: ## To build:
make all make all
## To run ## To run:
To use: To use:
./imc INTEGER ./imc INTEGER
## Judges' comments ## Try:
Try:
./imc 3 ./imc 3
./imc 3 ./imc 3
./imc 4 ./imc 4
./imc 4 ./imc 4
./imc 6 ./imc 6
This entry's algorithm is as magic as its output! ## Judges' comments:
## Author's comments This entry's algorithm is as magic as its output!
This program may be compiled with an ANSI or K&R compiler. A few
harmless warnings are displayed only if "gcc -Wall" is used.
This entry is really a set of library functions, but an example ## Author's comments:
main function has been added so that the library can be tested. If
the program appears too large, consider that functions o and s can
each be separated from the rest of the program (except for the short
functions p and r, which they require) and used alone. However, the
main part of the program is the function e, which does require all the
other functions (apart from main).
The program should be supplied with an integer parameter. If no This program may be compiled with an ANSI or K&R compiler. A few
parameter or an invalid parameter is given, then 5 is assumed. The harmless warnings are displayed only if "gcc -Wall" is used.
maximum parameter is determined only by the amount of cpu time, virtual
memory and display (or file) space available.
SPOILER: This entry is really a set of library functions, but an example
main function has been added so that the library can be tested. If
the program appears too large, consider that functions o and s can
each be separated from the rest of the program (except for the short
functions p and r, which they require) and used alone. However, the
main part of the program is the function e, which does require all the
other functions (apart from main).
OK, so you have probably seen magic square printers before. But what The program should be supplied with an integer parameter. If no
about one that deals with even sizes as well as odd ones, or one that parameter or an invalid parameter is given, then 5 is assumed. The
prints out a different one each time (or attempts to, at any rate)? maximum parameter is determined only by the amount of cpu time, virtual
memory and display (or file) space available.
I have formatted the important functions o, s and e to show how useful ### SPOILER:
the word "for" is, and (in function e) how useful the words "if" and
"else" are. In fact, hardly anything happens that isn't in one of these
instructions. I did this in order to simplify the code - the algorithms
used to make the random squares are quite complex without being shrouded
in obfuscated code! :-) Incidentally, I was surprised to find out how
useful the exclusive-or operator was while writing function s.
Here are the descriptions of the functions in the library: OK, so you have probably seen magic square printers before. But what
about one that deals with even sizes as well as odd ones, or one that
prints out a different one each time (or attempts to, at any rate)?
I have formatted the important functions o, s and e to show how useful
the word "for" is, and (in function e) how useful the words "if" and
"else" are. In fact, hardly anything happens that isn't in one of these
instructions. I did this in order to simplify the code - the algorithms
used to make the random squares are quite complex without being shrouded
in obfuscated code! :-) Incidentally, I was surprised to find out how
useful the exclusive-or operator was while writing function s.
Here are the descriptions of the functions in the library:
o(n,a,q,d): makes a magic square of order n when n is odd and at least 3. o(n,a,q,d): makes a magic square of order n when n is odd and at least 3.
s(n,a,q,d): makes a magic square of order n when n equals 4. s(n,a,q,d): makes a magic square of order n when n equals 4.
e(n,a,q,d): makes a magic square of order n when n is even and at least 6. e(n,a,q,d): makes a magic square of order n when n is even and at least 6.
In the above, a (of type int*) points to an area of memory in which In the above, `a` (of type `int*`) points to an area of memory in which
the magic square will be stored and q (also of type int*) points to the magic square will be stored and `q` (also of type `int*`) points to
an area of memory of length at least n*sizeof(int) bytes which can be an area of memory of length at least `n*sizeof(int)` bytes which can be
used as a work space. Both a and q must be allocated by the caller. used as a work space. Both `a` and `q` must be allocated by the caller.
The integer parameter d, usually zero, indicates the length of a gap The integer parameter `d`, usually zero, indicates the length of a gap
which will be left between adjacent rows of the magic square. which will be left between adjacent rows of the magic square.
The square which is returned will (or should) be a permutation of the The square which is returned will (or should) be a permutation of the
numbers 1 to n*n in which all rows and columns and the two diagonals numbers 1 to `n*n` in which all rows and columns and the two diagonals
add up to n*(n*n+1)/2. add up to `n*(n*n+1)/2`.
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License: