diff options
-rwxr-xr-x | ascii+32.lua | 9 | ||||
-rwxr-xr-x | decimal.lua | 11 | ||||
-rw-r--r-- | eyes/init.lua | 22 | ||||
-rw-r--r-- | reading.lua | 38 |
4 files changed, 80 insertions, 0 deletions
diff --git a/ascii+32.lua b/ascii+32.lua new file mode 100755 index 0000000..c16eb6f --- /dev/null +++ b/ascii+32.lua @@ -0,0 +1,9 @@ +#!/usr/bin/env lua +local eyes = require "eyes" +local reading = require "reading" +for _, message in ipairs(eyes) do + for _, value in reading.values(message) do + io.write(string.char(value + 32)) + end + print() +end diff --git a/decimal.lua b/decimal.lua new file mode 100755 index 0000000..6f32e5d --- /dev/null +++ b/decimal.lua @@ -0,0 +1,11 @@ +#!/usr/bin/env lua +local eyes = require "eyes" +local reading = require "reading" +for _, message in ipairs(eyes) do + local start, value = reading.next_value(message) + io.write(value) + for _, value in reading.values(message, start) do + io.write(",", value) + end + print() +end diff --git a/eyes/init.lua b/eyes/init.lua new file mode 100644 index 0000000..de63d08 --- /dev/null +++ b/eyes/init.lua @@ -0,0 +1,22 @@ +return { + require "eyes.east1", + require "eyes.east2", + require "eyes.east3", + require "eyes.east4", + require "eyes.east5", + require "eyes.west1", + require "eyes.west2", + require "eyes.west3", + require "eyes.west4", + east1 = require "eyes.east1", + east2 = require "eyes.east2", + east3 = require "eyes.east3", + east4 = require "eyes.east4", + east5 = require "eyes.east5", + west1 = require "eyes.west1", + west2 = require "eyes.west2", + west3 = require "eyes.west3", + west4 = require "eyes.west4", + permutations = require "eyes.permutations", + random = require "eyes.random", +} diff --git a/reading.lua b/reading.lua new file mode 100644 index 0000000..2b74446 --- /dev/null +++ b/reading.lua @@ -0,0 +1,38 @@ +local function next_trigram (message, index) + index = (index or 0) + 1 + local offset = (index - 1) * 3 + local a = message[offset + 1] + if not a then + return nil + end + return index, a, message[offset + 2], message[offset + 3] +end + + +local function next_value (message, index) + local a, b, c + index, a, b, c = next_trigram(message, index) + if not index then + return nil + end + return index, a * 25 + b * 5 + c +end + + +local reading = { + next_trigram = next_trigram, + next_value = next_value, +} + + +function reading.trigrams (message, start) + return next_trigram, message, start +end + + +function reading.values (message, start) + return next_value, message, start +end + + +return reading |