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

28
LINES

< > BotCompany Repo | #123 // Pitcher core

Lua code

-- expects two snippet IDs (solution, test case) as input
-- example: "#121 #122"

if input == nil then error("Needs input.") end

solutionID, testCaseID = input:match("([^ ]+) +([^ ]+)")
if not solutionID then
  error("Could not parse input, expected two snippet IDs")
end

solutionF = loadSnippet(solutionID)
assert(solutionF, 'Solution does not parse: '..solutionID)

pcall(solutionF)
if solution == nil then solution = function(_input)
  input = _input  -- yeah the whole env thing is hacky right here
  return solutionF()
end end

verifierF = loadSnippet(testCaseID)
assert(verifierF, 'Test case does not parse: '..testCaseID)
if verifierF() then
  print "Verified!"
  solution = nil -- to not apply RunCmd/DebugCmd's "find solution function" magic...
  return true
else
  error("Not verified.")
end

test run  test run with input  download  show line numbers   

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

Comments [hide]

ID Author/Program Comment Date
1010 #1000604 (pitcher) 2015-08-20 15:28:24
1009 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
-- expects two snippet IDs (solution, test case) as input
-- example: "#121 #122"

if input == nil then error("Needs input.") end

solutionID, testCaseID = input:match("([^ ]+) +([^ ]+)")
if not solutionID then
error("Could not parse input, expected two snippet IDs")
end

solutionF = loadSnippet(solutionID)
assert(solutionF, 'Solution does not parse: '..solutionID)

pcall(solutionF)
if solution == nil then solution = function(_input)
input = _input -- yeah the whole env thing is hacky right here
return solutionF()
end end

verifierF = loadSnippet(testCaseID)
assert(verifierF, 'Test case does not parse: '..testCaseID)
if verifierF() then
print "Verified!"
solution = nil -- to not apply RunCmd/DebugCmd's "find solution function" magic...
return true
else
error("Not verified.")
end

}}
2015-08-20 14:46:43  delete 

add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 833 [visualize]

Snippet ID: #123
Snippet name: Pitcher core
Eternal ID of this version: #123/1
Text MD5: 39f2e40d59c77373172a22a1afc52849
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2014-01-10 19:41:01
Source code size: 833 bytes / 28 lines
Pitched / IR pitched: Yes / Yes
Views / Downloads: 1376 / 4870
Referenced in: #28 - Writing chat-bots in Lua
#232 - dynamize
#599 - x9.java
#759 - "Leading Edge" JavaX Translator (Extension of #7)
#1000341 - Example blog post (for blog formatter)
#1001966 - Start Snippet Title Bot
#1003130 - Program Runner
#1003872 - Integrating #759 in One Program
#1003874 - Backup of #759 Before Integration
#1004091 - 759 with new loadClasses (spike)
#1004468 - Some Useful Rewrites
#1004863 - "Concepts" (persistent Java objects, include)
#1006722 - Transpiler Translator for #759
#1006723 - Higher-Level-Transpiled #759 Spike [old]
#1006724 - Backup of #759 before switching to higher-level-translation
#1007595 - "Super-Edgy" JavaX Translator (Extension of #752) [dev., broken]
#1010083 - Backup of "Super-Edgy" JavaX Translator (Extension of #7)
#1010084 - Speeding up "Super-Edgy" JavaX Translator (Extension of #7)
#1010087 - Speeding up "Super-Edgy" JavaX Translator (Extension of #7) 2
#1015578 - Show Suggestion Spike
#1015588 - Test showSuggestion - show two suggestions, the second replacing the first (OK)
#1015589 - Test suggestion in frame that doesn't grab focus (OK)
#1015591 - Test suggestion in frame that doesn't grab focus - without alwaysOnTop
#1015631 - Test optimizedJavaEval [OK]
#1022534 - tok_directSnippetRefs
#1025804 - Transpiler with TokenIndexedList3 [dev.]
#1025806 - "Super-Edgy" JavaX Translator (Extension of #7) before concurrent class compilation
#1026023 - #759 backup with reTok_multi in tok_conditionals (seems slower?)
#1026756 - dm_searchForServerModule - returns list of "#123 - bla"
#1030886 - "Concepts" [backup before parent]
#1031070 - "Concepts" [backup before new changes system]
#1032684 - #759 transpilation backup
#1032956 - JavaX Translator backup
#1032968 - JavaX Translator backup
#1032978 - JavaX Translator backup
#1033035 - JavaX Translator backup
#1033089 - Transpiler dev.
#1033090 - Transpiler reverting
#1034278 - "Concepts" (persistent Java objects, backup)
#1034497 - Experimental JavaX Transpiler [see #759]
#1034623 - mainTranspilationSnippetFromSrc
#1034627 - test_mainTranspilationSnippetFromSrc
#2000455 - Find snippet IDs in text
#3000024 - Contents of http://tinybrain.blog.de
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)