How Many Properties Apart Are These Inks?
Two blue inks can look nearly identical in their bottles and behave quite differently on paper. One shades, one sheens, and perhaps only one leaves a legible trace after a drop of water. A consistent swatch gives those differences somewhere to show themselves.
For this little catalogue, give each ink three yes-or-no observations in the same order: shading, sheen and visible writing after a water test. Write each answer as a bit. The codes 110 and 101 differ in two positions: the first ink has sheen, while the second leaves visible writing after the test.
That count is the Hamming distance. Richard Hamming introduced the idea in 1950 in work on error-detecting and error-correcting codes. There, differences between bit strings help identify damaged messages. Here, the same count offers a quick way to find samples with similar observed properties.
package main
import "fmt"
func main() {
a, b := "110", "101"
distance := 0
for i := range a {
if a[i] != b[i] {
distance++
}
}
fmt.Println(distance)
}
Lua reaches the same answer by comparing one-character substrings:
local a, b = "110", "101"
local distance = 0
for i = 1, #a do
if a:sub(i, i) ~= b:sub(i, i) then
distance = distance + 1
end
end
print(distance)
Both programs print 2. They assume equally long strings containing one ASCII bit per observation; a catalogue accepting arbitrary input should check that assumption first.
The score is only as consistent as the swatches behind it. Paper, nib and drying time can all affect the observations, so record them alongside each sample. The distance also counts every property equally and says nothing about how much an ink shades or which property differs. It is a useful starting point for choosing samples to inspect, not a substitute for looking at the page.