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

23
LINES

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

Lua code

solutions = {
  [[return input:upper()]],
  [[return input:lower()]],
}

local left, right = input:match('^(.*)=(.*)$')
if not left then
  return "Please enter a transformation example, e.g. abc=ABC"
end

input = left -- so the solutions get the right input

for _, code in ipairs(solutions) do
    f = load(code)
    log("loaded code: "..tostring(f))
    s = f() -- TODO: use pcall
    log("result: "..tostring(s))
    if s == right then
        return "Solution found:\n\n"..code
    end
end

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: 1270 / 334
Referenced in: [show references]