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

56
LINES

< > BotCompany Repo | #529 // Extraction task solver (on example task: #2000060)

Lua code - Snippet producer

1  
get("#349") -- table functions
2  
3  
taskID = input or "#2000060" -- change this to do another task
4  
5  
visualizerID = "#316" -- crop executor. don't change this
6  
7  
function findImage(taskID)
8  
  local title = getSnippetTitle(taskID)
9  
  return collectSnippetIDs(title)[1]
10  
end
11  
12  
function findCoordinates(text)
13  
  for r in text:gmatch("%d+,%s*%d+,%s*%d+,%s*%d+") do
14  
    print("Coordinates: "..r)
15  
    table.insert(coordinates, r)
16  
  end
17  
end
18  
19  
function collectSnippetIDs(text)
20  
  local ids = {}
21  
  for id in (text.." "):gmatch("(#%d+)[^0-9]") do
22  
    table.insert(ids, id)
23  
  end
24  
  return ids
25  
end
26  
  
27  
coordinates = {}
28  
29  
-- get hints
30  
refs = getTitleReferences(taskID)
31  
for hintID in all(refs) do
32  
  hint = getSnippet(hintID)
33  
  print("Hint "..hintID..": "..hint)
34  
  findCoordinates(hint)
35  
  
36  
  for id in all(collectSnippetIDs(hint)) do
37  
    print("snippet id: "..id)
38  
    findCoordinates(getSnippet(id))
39  
  end
40  
end
41  
42  
print("Coordinates found: "..#coordinates)
43  
44  
if #coordinates == 0 then error "War wohl nix" end
45  
46  
print("Trying first set of coordinates.")
47  
r = coordinates[1]
48  
49  
imageID = findImage(taskID)
50  
result = "image "..imageID.." transform through "..visualizerID.." with input "..("%q"):format(r)
51  
title = "An image generation expression for "..taskID
52  
53  
print("\n-- Result: "..title)
54  
print(result)
55  
56  
return {type="nt", title=title, text=result}

test run  test run with input  produce a snippet  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: #529
Snippet name: Extraction task solver (on example task: #2000060)
Eternal ID of this version: #529/1
Text MD5: 42dc052ff6aa01cba04227e3fac9a996
Author: stefan
Category:
Type: Lua code - Snippet producer
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-14 01:25:32
Source code size: 1363 bytes / 56 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 718 / 175
Referenced in: [show references]