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

23
LINES

< > BotCompany Repo | #31 // Guesser (early version)

Lua code

1  
solutions = {
2  
  [[return input:upper()]],
3  
  [[return input:lower()]],
4  
}
5  
6  
local left, right = input:match('^(.*)=(.*)$')
7  
if not left then
8  
  return "Please enter a transformation example, e.g. abc=ABC"
9  
end
10  
11  
input = left -- so the solutions get the right input
12  
13  
for _, code in ipairs(solutions) do
14  
    f = load(code)
15  
    log("loaded code: "..tostring(f))
16  
    s = f() -- TODO: use pcall
17  
    log("result: "..tostring(s))
18  
    if s == right then
19  
        return "Solution found:\n\n"..code
20  
    end
21  
end
22  
23  
return "Sorry, no solution found..."

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

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 553 [visualize]

Snippet ID: #31
Snippet name: Guesser (early version)
Eternal ID of this version: #31/1
Text MD5: 8bbdf5393c41f59999d3e813429a7e60
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2013-12-13 23:05:59
Source code size: 553 bytes / 23 lines
Pitched / IR pitched: Yes / Yes
Views / Downloads: 1274 / 335
Referenced in: [show references]