# HG changeset patch # User William Morgan # Date 1376212615 25200 # Node ID 4750da71cae6956a53f6c6cdc3b971627ec52811 # Parent c42d3c8b1d759e6c9f064898a0d2254113d12b8a parsing myproblems.json, needs fix diff -r c42d3c8b1d75 -r 4750da71cae6 src/requests.tp --- a/src/requests.tp Sat Aug 10 23:30:12 2013 -0700 +++ b/src/requests.tp Sun Aug 11 02:16:55 2013 -0700 @@ -178,8 +178,7 @@ } } - problem <- :bod { - decoded <- json decode: bod + _problem <- :decoded { #{ id <- decoded get: "id" withDefault: -1 size <- decoded get: "size" withDefault: -1 @@ -201,7 +200,20 @@ } } + problem <- :bod { + decoded <- json decode: bod + _problem: decoded + } + + problems <- :bod { + decoded <- json decode: bod + decoded map: :idx el{ + _problem: el + } + } + main <- :args { + print: "Program Start." testId0 <- "wdThP1AgVrS2rp7q6qt9mLqp" // TRAINING PROGRAM ID! not real one. response in data folder. testId1 <- "QwhG7ZpaVsfXiLRvbJfIfxl8" // TRAINING PROGRAM ID! not real one. response in data folder. someProblem <- "{\"id\":\"QwhG7ZpaVsfXiLRvbJfIfxl8\",\"size\":15,\"operators\":[\"and\",\"if0\",\"shl1\",\"shr16\",\"tfold\"]}" @@ -209,15 +221,23 @@ //print: ((evalId: "someId" #[1u64 2u64 3u64]) string) . "\n" //print: ((guess: "someId" "someProg") string) . "\n" - print: ((problem: someProblem) string) . "\n" + //print: ((problem: someProblem) string) . "\n" + + file <- os open: "/home/wbm25/Desktop/icfp2013/data/myproblems.json" (os O_RDONLY) + fstr <- (os read: file 400 * 1024) // file was 276k before bonus problems... + os close: file + + print: (((problems: fstr) get: 0) string ) + + if: (args length) > 1 { key <- args get: 1 //print: ((evalProgram: "(lambda (input) (shl1 input))" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) //print: ((evalId: testId0 #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) - print: ((guess: testId0 someProgram) sendWithKey: key) - + //print: ((guess: testId0 someProgram) sendWithKey: key) + println: "derp" } } }