Mercurial > repos > icfp2013
view src/solver.tp @ 32:2b5357b13e2d
Initial work on solver
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 10 Aug 2013 19:54:20 -0700 |
parents | |
children | b00904b36aca |
line wrap: on
line source
#{ classify <- :prog trees { testvals <- #[] i <- 0 (os srand: (os time)) while: {i < 256} do: { i <- i + 1 testvals append: (uint64: (os rand64)) } root <- dict linear foreach: trees :idx tree { prog root!: tree res <- prog run: (testvals get: 0) arr <- root get: res withDefault: #[] arr append: tree if: (arr length) = 1 { root set: res arr } } #{ inputs <- { testvals } valmap <- { root } } } main <- :args { size <- 3 if: (args length) > 1 { size <- int32: (args get: 1) } prog <- bv program if: size >= 2 { trees <- (prog allOfSize: size) if: (args length) > 2 { ops <- (args get: 2) splitOn: "," trees <- prog filterTrees: trees ops } info <- classify: prog trees foreach: (info valmap) :val arr { print: "Value: 0x" . (hex: val) ." produced by " . (string: (arr length)) . "programs\n" } } } }