Here follows an algorithmic styled write-up of the appendix to the Baynes' English translation of Wilhelm's German translation of the Chinese classic, the I Ching, entitled "On Consulting the Oracle."
The oracle is consulted with the help of yarrow stalks. Eighteen
choices are made during the manipulation of the stalks that results in the
generation of two but also possibly the same hexagram twice. (There are
three choices of how to divide the stalks for each of six lines.) The hexagram is interperted
with respect to the inquiry to the oracle.
Fifty stalks are used for this purpose.
One is put aside and plays no further part.
The process for generating a line begins when remaining 49 stalks are first divided into two heaps at random. (From what follows it seems the right-hand heap must contain at least 5 stalks and the left-hand heap must contain at least 4 stalks.)
One stalk is taken from the right-hand heap and put between the ring finger and the little finger of the left hand.
The left-hand heap is placed in the left hand, and the right hand takes from it bundles of four and puts them into a counted heap, until there are four or fewer stalks remaining.
This remainder is placed between the ring finger and middle finger of the left hand.
The right hand heap is then placed in the left hand and counted off by fours into the counted heap until there are four or fewer stalks remaining, and the remainder is placed between the middle finger and the forefinger of the left hand.
The sum of the stalks between the fingers of the left hand is either 9 or 6. (1+4+4 / 1+3+1 / 1+2+2 / 1+1+3)
9 counts as 2, 5 count as 3 when calculating this line at the end.
These stalks are now laid aside for the remainder of the time spent calculating this line.
The stalks not set aside permanently or temporarily that is, the counted heap, are gathered together and divide anew.
One stalk is taken from the right-hand heap and put between the ring finger and the little finger of the left hand.
The left-hand heap is placed in the left hand, and the right hand takes from it bundles of four and puts them into a counted heap, until there are four or fewer stalks remaining.
This remainder is placed between the ring finger and middle finger of the left hand.
The right hand heap is then placed in the left hand and counted off by fours into the counted heap until there are four or fewer stalks remaining, and the remainder is placed between the middle finger and the forefinger of the left hand.
This second time the sum of the stalks between the fingers of the left hand is either 8 or 4. (1+4+3 / 1+3+4 / 1+1+2 / 1+2+1)
8 counts as 2, 4 counts as 3 when calculating this line at the end.
These stalks are now laid aside for the remainder of the time spent calculating this line.
The stalks not set aside permanently or temporarily that is, the counted heap, are gathered together and divide anew.
One stalk is taken from the right-hand heap and put between the ring finger and the little finger of the left hand.
The left-hand heap is placed in the left hand, and the right hand takes from it bundles of four and puts them into a counted heap, until there are four or fewer stalks remaining.
This remainder is placed between the ring finger and middle finger of the left hand.
The right hand heap is then placed in the left hand and counted off by fours into the counted heap until there are four or fewer stalks remaining, and the remainder is placed between the middle finger and the forefinger of the left hand.
This third time the sum of the stalks between the fingers of the left hand is either 8 or 4. (1+4+3 / 1+3+4 / 1+1+2 / 1+2+1)
8 counts as 2, 4 counts as 3 when calculating this line at the end.
The line is calculated from the sum of the counts from each of the three parts.
A nine is called ‘old yang’, a six is called ‘old yin’, a seven is called ‘young yang’, and an eight is called ‘young yin’. (2+2+2=6, 2+2+3=2+3+2=3+2+2=7, 3+3+2=3+2+3=2+3+3=8, 3+3+3=9)
The lines are said to change in a repeating cycle from 'yang' to 'old yang' to 'yin' to 'old yin' to 'yang' again in each accord with their own proper time. A yang line is written as an unbroken line. A yin line is written as a broken line. An old yang line is written as an unbroken line with a circle in th middle where it will break to become a yin line. An old yin line is written as a broken line with a small 'x' to mark where it will fill in to become a yang line. Old lines are called 'changing' lines.
The first line is written at the bottom and the counted and temporary heaps are gathered together (=49).
Repeat the process for generating a line for total of six times to generate the hexagram(s).
Note which line positions (first, second, third...) of the hexagram are changing if any.
If there are any changing lines write a second hexagram with the old lines changed to their opposites. If there are no changing lines then there is only one persisting hexagram to write and interpret.