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

37
LINES

< > BotCompany Repo | #331 // Compare fonts

Lua code

1  
images1 = {"#1000061", "A", "#1000056", "H", "#1000064", "P", "#1000063", "X", "#1000062", "B"}
2  
images2 = {"#1000072", "A", "#1000073", "B", "#1000074", "P", "#1000075", "X", "#1000076", "H"}
3  
features = {"#326", "#327", "#328"}
4  
5  
-- make letter lookup map
6  
letter2images = {}
7  
for i=1, #images1, 2 do
8  
  letter = images1[i+1]
9  
  if letter2images[letter] == nil then letter2images[letter] = {} end
10  
  letter2images[letter][1] = images1[i]
11  
end
12  
for i=1, #images2, 2 do
13  
  letter = images2[i+1]
14  
  if letter2images[letter] == nil then letter2images[letter] = {} end
15  
  letter2images[letter][2] = images2[i]
16  
end
17  
18  
-- find out which results to load
19  
toget = {}
20  
for i=1, #images1, 2 do table.insert(toget, images1[i]) end
21  
for i=1, #images2, 2 do table.insert(toget, images2[i]) end
22  
for i=1, #features do table.insert(toget, features[i]) end
23  
results = getirresults(unpack(toget))
24  
25  
for _, feature in ipairs(features) do
26  
  print()
27  
  print(feature)
28  
  for letter, images in pairs(letter2images) do
29  
    img1, img2 = images[1], images[2]
30  
    s = letter..": "..tostring(img1)..", "..tostring(img2)
31  
    if img1 ~= nil and img2 ~= nil then
32  
      res1, res2 = results[img1], results[img2]
33  
      s = s.." | "..tostring(res1[feature])..", "..tostring(res2[feature])
34  
    end
35  
    print(s)
36  
  end
37  
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: 676 / 180
Referenced in: [show references]