royal
The adjective royal meaning “pertaining to a king” is first attested in the late 1300s. It’s in use in English by the mid-1200s instead meaning “fit for a king”, and comes from the Old French “roial”. From 1066 through 1400, every ruler of England natively spoke Old French, so this is a natural borrowing. “Roial”, in turn, is descended from the Latin “rēgālis”, the adjective form of “rēx”, meaning “king”. That is likely descended from the reconstructed Proto-Italic “rēks” and the Proto-Indo-European “h₃rḗǵs”, which is the likely source for Sanskrit “राजन्” (rā́jan) and eventually Hindi “राजा” (rājā). The concept of a ruler is likely one of the most durable and unusually clear to trace through time.
Regal, a close cousin of royal, also entered English in the late 1300s, in this case directly from that Latin root “rēgālis”. Legal documents in England were all written in Latin at the time, so this seems like another natural borrowing. But wait, if a ruler is a very durable concept, shouldn’t English also have had an adjective meaning “kingly” already?
Kingly is amazingly also first attested in the late 1300s, but can be traced back through Old English variant spellings to “cyninglīċ” through to Proto-Germanic “kuningaz”, meaning “king”. It has cognates in the other Germanic langauges, such as German König, the namesake of the city containing the Seven Bridges of Königsberg (currently named Kaliningrad).
Royal, regal, and kingly make up one of English’s etymological triplets, three distinct words that mean similar things from similar origins. They are typically from Old English, Old French, and Latin, due to the way languages overlapped in 1300s England. Wikipedia has a good list if you’re hungry for more.
wiki
The description wiki for a collection of hyperlinked documents that anyone can edit was coined by Ward Cunningham in 1995 when he created the first one. The concept was inspired by HyperCard stacks. When creating the WikiWikiWeb, which is still online at https://wiki.c2.com/, he named it after the Wiki Wiki Shuttle at Honolulu International Airport and the Hawaiian word for “quick”, wikiwiki. The Hawaiian word is a reduplication of “wiki”, a Hawaiian verb meaning “speed up”, which likely descends from Proto-Polynesian “witi”.
One feature of the WikiWikiWeb that often surprises people now is that words are hyperlinks if and only if they are a single CamelCase word. Each CamelCase word automatically linked to either an article with its title or an option to create that article if it didn’t exist.
The most notable [citation needed] wiki today, Wikipedia, was established in 2001 using what was then called a WikiWikiClone, UseModWiki for Usenet moderation coordination. It was not until later in 2001 that UseModWiki added support for what is now standard [[wikilink syntax]]; Wikipedia itself retained many CamelCase links well into the early 2000s as it transitioned over.
kraken
The word kraken to describe a giant squid was invented by Norwegian bishop Erik Pontoppidan in 1753. It’s based on the Norwegian dialectal “krake”, meaning sea monster, itself based on Old Norse “kraki”, literally “something twisted”. (The reconstructed Proto-Germanic root it’s likely derived from, “krankaz”, is also the likely source of e.g. English “crank”.)
But wait, you might ask. How is it that this Norwegian word first attested in the 1700s is used to describe a beast from Greek mythology? The 1981 film Clash of the Titans, a Greek epic, is the source of this connection. It includes both a kraken and the still-memed-today line “Release the kraken!” despite kraken having no prior relation to Greek mythology.
The less exciting middle part includes the Norwegian word making it into English through misattribution to Carl Linnaeus’s famous 1735 taxonomy and becoming a well-known English term by the time of Alfred Tennyson’s 1830 poem The Kraken. The less exciting end part includes the hockey team the Seattle Kraken, est’d 2018.
Constrained programming, part 2
The second letter in “etaoin shrdlu” is t. Some Ruby method names and keywords that contain the letter t include return, #match, true, #split, #to_i, next, #empty?, #length, and #select. I write this here so I don’t have to figure out how to talk around those explicitly forbidden words.
Of the above, I couldn’t figure out how to get around #to_i without implementing it myself.
Day 2 | Ruby | Avoiding glyph before ‘u’
def as_number(word) if word == "100" 100 elsif word.size == 1 word.ord - 48 else (word.ord - 48) * 10 + word.chars[1].ord - 48 end end # Problem 1 games = IO.readlines('02').map(&:chop) ids = games.map do |game| draws = game.scan /(\d+) ([bgr])/ invalid = draws.keep_if do |draw| num = as_number(draw[0]) color = draw[1] (num > 12 && color == 'r') || (num > 13 && color == 'g') || (num > 14 && color == 'b') end invalid.size == 0 ? as_number(game.scan(/Game (\d+)/)[0][0]) : 0 end p ids.sum # Problem 2 powers = games.map do |game| cubes = {"r" => 0, "b" => 0, "g" => 0} game.scan(/(\d+) ([bgr])/) do |draw| num = as_number(draw[0]) color = draw[1] cubes[color] = num if cubes[color] < num end cubes.values.reduce(&:*) end p powers.sum
Constrained programming
I’ve enjoyed constrained writing (e.g. Oulipo) for a long time and am going to be trying to practice constrained programming in Advent of Code for as long as I can maintain interest this year. In particular, my plan is to go through each day as a lipogram of the nth-most-frequent letter in English. For the first twelve, even though English letter frequency is slightly different than ETAOIN SHRDLU, I’ll use that iconic order.
So my day 1 solution will not include the letter ‘e’, day 2 will not include the letter ‘t’, and so on. I’m excited to try this out. Here’s day 1:
Day 1 | Ruby | Avoiding fifth glyph
# part 1 digits = inputs.map { |input| input.gsub(/\D/, '')} calibrations = digits.map { |digit| digit.chars.first.to_i * 10 + digit.chars.last.to_i } p calibrations.sum # part 2 glyph_to_avoid = "d".succ @trigrams = {"two" => 2, "six" => 6} @trigrams["onz".gsub(/z/, glyph_to_avoid)] = 1 @quadragrams = {"four" => 4} @quadragrams["fivz".gsub(/z/, glyph_to_avoid)] = 5 @quadragrams["ninz".gsub(/z/, glyph_to_avoid)] = 9 @quintagrams = {} @quintagrams["thrzz".gsub(/z/, glyph_to_avoid)] = 3 @quintagrams["szvzn".gsub(/z/, glyph_to_avoid)] = 7 @quintagrams["zight".gsub(/z/, glyph_to_avoid)] = 8 calibrations = inputs.map { |input| first_digit = nil (0..input.chars.count - 1).map { |idx| first_digit = input[idx].to_i if !first_digit && /\d/ =~ input[idx] tri = input[idx-2, 3] if idx >= 2 first_digit = @trigrams[tri] if !first_digit && tri && @trigrams[tri] quad = input[idx-3, 4] if idx >= 3 first_digit = @quadragrams[quad] if !first_digit && quad && @quadragrams[quad] quint = input[idx-4, 5] if idx >= 4 first_digit = @quintagrams[quint] if !first_digit && quint && @quintagrams[quint] } last_digit = nil (1..input.chars.count).map { |idx| last_digit = input[-idx].to_i if !last_digit && /\d/ =~ input[-idx] tri = input[-idx, 3] if idx >= 2 last_digit = @trigrams[tri] if !last_digit && tri && @trigrams[tri] quad = input[-idx, 4] if idx >= 3 last_digit = @quadragrams[quad] if !last_digit && quad && @quadragrams[quad] quint = input[-idx, 5] if idx >= 4 last_digit = @quintagrams[quint] if !last_digit && quint && @quintagrams[quint] } first_digit * 10 + last_digit } p calibrations.sum
Not using control flow words was tough to work around. I initially had ‘x’ for a proxy glyph until I got to ‘six’.