diff --git a/1993/ejb/README.md b/1993/ejb/README.md index 57bb3c0d4..51cc9d0e4 100644 --- a/1993/ejb/README.md +++ b/1993/ejb/README.md @@ -54,8 +54,8 @@ text description of how to solve the puzzle. For the patience puzzle, the output is a sequence binary codes representing successive states of the puzzle. The rightmost digit represents the first ring. -A "1" means the ring is on the U; a "0" means it is off the U. The program -prints the word "Invalid" in response to illegal command line parameters. +A `1` means the ring is on the `U`; a `0` means it is off the `U`. The program +prints the word `"Invalid"` in response to illegal command line parameters. ### Motivation @@ -67,14 +67,14 @@ This program serves to show that counting semicolons will not always provide a meaningful measure of code size. This is especially true in this program where the number of semicolons itself is ambiguous. Does it have two or three? In addition, the -only "C" keyword this program uses besides type names and +only C keyword this program uses besides type names and qualifiers is `return`, and the only function defined in the code -is `main`. The level of complexity of the program without multiple +is `main()`. The level of complexity of the program without multiple semicolons, statements, and functions is achieved by abusing C operators, especially the comma operator. Considerable use of `||`, -`&&`, and `? :` helps too. In addition, main is called recursively. -The NULL pointer that terminates argv is used to pass additional -information into main. Even though the algorithms used by this +`&&`, and `?:` helps too. In addition, `main()` is called recursively. +The NULL pointer that terminates `argv` is used to pass additional +information into `main()`. Even though the algorithms used by this code are simple, this program is still hard to follow even when indented properly. (It is pretty hard to indent this code reasonably, however.) @@ -85,7 +85,7 @@ preprocessor at all. The only functions it uses are `atoi()`, `malloc()`, `memset()`, `printf()`, and `puts()`. It does, however, require that the architecture it runs on have bytes that are at least eight bits long and pointers that are at least four bytes long. In addition, it requires an ANSI -compiler since it uses "signed char" and ANSI-style function declarations. +compiler since it uses `signed char` and ANSI-style function declarations. ## Copyright and CC BY-SA 4.0 License: diff --git a/1993/ejb/patience.md b/1993/ejb/patience.md index 43fc7dd9e..ae9b688cf 100644 --- a/1993/ejb/patience.md +++ b/1993/ejb/patience.md @@ -21,38 +21,39 @@ ring at the end of the rod to its right. The only rod free of this restriction is the rightmost rod. What has been described so far is one of the two components of the puzzle. -The other component is another iron rod shaped like a U. -The U is as long from the tips to the base as the original -piece of iron with the holes in it. The ends of the U are +The other component is another iron rod shaped like a `U`. +The `U` is as long from the tips to the base as the original +piece of iron with the holes in it. The ends of the `U` are looped around another ring of about five centimeters in -diameter. In the puzzle's initial configuration, the U is +diameter. In the puzzle's initial configuration, the `U` is placed through the rings so that it is held in place by the -iron rods. Imagine starting with the U piece before the -iron loop is placed at the end. Slide the legs of the U +iron rods. Imagine starting with the `U` piece before the +iron loop is placed at the end. Slide the legs of the `U` through the loops so that the iron rods securing the loops -to the metal strip go up the center of the U. Placing the -final ring at the ends of the U prevents it from coming out. -The object of the puzzle is to free the U-shaped piece from +to the metal strip go up the center of the `U`. Placing the +final ring at the ends of the `U` prevents it from coming out. +The object of the puzzle is to free the `U`-shaped piece from the other piece. The following illustration (sideways) shows a three-ring case of this puzzle. If you look carefully, you can see -that the first ring could be lifted over the edge of the U -and slid down through the center of the U, thereby freeing -the U from the first iron rod. The second ring can also be +that the first ring could be lifted over the edge of the `U` +and slid down through the center of the `U`, thereby freeing +the `U` from the first iron rod. The second ring can also be freed in the initial configuration since it is already over the rod for the first ring. The third ring cannot be moved, -however, since it is blocked by the iron rod two which the +however, since it is blocked by the iron rod to which the first ring is attached. If the first first is removed, then the third ring is no longer blocked by the first ring's iron rod and can be removed freely. The second ring, however cannot be moved if the first ring is gone because it will then be blocked by the first ring in its new position -outside of the U. +outside of the `U`. Here is an illustration of the three-ring case. The bottom of the puzzle is on the left-hand side of the page. - + +``` @@ -105,7 +106,8 @@ of the puzzle is on the left-hand side of the page. \ | \\ || \ | \\|| \| \|| - +``` + This puzzle takes other forms as well. One such puzzle is called "Spin-Out". This puzzle consists of one plastic piece that encases another piece that can slide in and out @@ -131,14 +133,14 @@ free to move. The only other piece that is free to move is the second one that is still attached to the base it is trying to be freed from. In the case of the original puzzle, consider the rings numbered from 1 to 6 with ring 1 -being the one at the closed send of the U. Ring 1 can -always be removed from or added to the U. In the initial -state, when all rings are around the U, ring 2 is the other +being the one at the closed end of the `U`. Ring 1 can +always be removed from or added to the `U`. In the initial +state, when all rings are around the `U`, ring 2 is the other one that can be moved because it is second. If ring 1 is removed, then only two operations are possible: the restoration of ring 1 and the removal of ring 3. This is because ring 1 is always movable, and ring 3 is currently -the second ring still attached to the U. This constraint +the second ring still attached to the `U`. This constraint leads to a recursive solution to the puzzle. Like the [Towers of Hanoi](hanoi.md), the number of steps to solve this puzzle is exponential in the number of rings.