Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #331 // Compare fonts

Lua code

images1 = {"#1000061", "A", "#1000056", "H", "#1000064", "P", "#1000063", "X", "#1000062", "B"}
images2 = {"#1000072", "A", "#1000073", "B", "#1000074", "P", "#1000075", "X", "#1000076", "H"}
features = {"#326", "#327", "#328"}

-- make letter lookup map
letter2images = {}
for i=1, #images1, 2 do
  letter = images1[i+1]
  if letter2images[letter] == nil then letter2images[letter] = {} end
  letter2images[letter][1] = images1[i]
end
for i=1, #images2, 2 do
  letter = images2[i+1]
  if letter2images[letter] == nil then letter2images[letter] = {} end
  letter2images[letter][2] = images2[i]
end

-- find out which results to load
toget = {}
for i=1, #images1, 2 do table.insert(toget, images1[i]) end
for i=1, #images2, 2 do table.insert(toget, images2[i]) end
for i=1, #features do table.insert(toget, features[i]) end
results = getirresults(unpack(toget))

for _, feature in ipairs(features) do
  print()
  print(feature)
  for letter, images in pairs(letter2images) do
    img1, img2 = images[1], images[2]
    s = letter..": "..tostring(img1)..", "..tostring(img2)
    if img1 ~= nil and img2 ~= nil then
      res1, res2 = results[img1], results[img2]
      s = s.." | "..tostring(res1[feature])..", "..tostring(res2[feature])
    end
    print(s)
  end
end

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #331
Snippet name: Compare fonts
Eternal ID of this version: #331/1
Text MD5: 26322ca4447e10fe67f409f493717f3c
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-01-24 01:20:30
Source code size: 1301 bytes / 37 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 675 / 179
Referenced in: [show references]