How to count to ten in Yan Tan Tethera
Java this time, counting to ten in the Derbyshire variant of the old sheep-counting language based on ancient vigesimal, or base-20, Celtic number names. If you've read Terry Pratchett's stories about the adventures of young witch Tiffany Aching and the Nac Mac Feegle (the roughest, most criminally inclined fairies of all time), you'll recognize these as the ones used by shepherds on the Chalk in Discworld. Tiffany, being her twentieth grandchild, is called "little jiggit" by her sheep-herding grandmother.
Since these number names include pairs of rhyming words, it seemed a good choice for a non-obvious (silly, even) implementation. Five and ten are unique words, so the "prefixes" array contains their translations in full. All other numbers from one to ten are composed of an initial letter followed by one of just three suffixes (or blank for five and ten). To get a full name, combine a prefix with matching suffix. To avoid duplicating suffixes, we iterate through an array of indices into the suffixes array, rather than the suffixes array itself.
public class YanTanTethera { public static void main(String[] args) { String[] prefixes = {"y", "t", "t", "m", "pip", "s", "l", "h", "d", "dick"}; String[] suffixes = {"an", "ethera", "overa", ""}; int[] suffix_for_num = {0, 0, 1, 1, 3, 1, 1, 2, 2, 3}; for (int i = 1; i<=10; i++) { System.out.println(prefixes[i-1]+suffixes[suffix_for_num[i-1]]); } } }
Output:
yan
tan
tethera
methera
pip
sethera
lethera
hovera
dovera
dick
This is just one dialect of yan tan tethera. There are many more, some quite similar, others more varied. Anyone sufficiently intrigued can try adapting the above to other dialects. Much more information can be found at:
Yan tan tethera - Wikipedia, the free encyclopedia