Skip to content

Instantly share code, notes, and snippets.

@vird
Created April 28, 2016 12:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vird/453a86cf16903c017b060cdd457baf86 to your computer and use it in GitHub Desktop.
Save vird/453a86cf16903c017b060cdd457baf86 to your computer and use it in GitHub Desktop.
npm i iced-coffee-script
iced test.coffee
# or ./test.coffee
#!/usr/bin/iced
String.prototype.ljust = (length, char = ' ')->
append = new Array(Math.max(0, length - @length) + 1).join char
append = append.substr 0, length - @length
@ + append
Number.prototype.ljust = (length)-> @.toString().ljust length
h_count = (t)->
ret = 0
for k of t
ret++
ret
zlib = require 'zlib'
fs = require 'fs'
buf_gz = fs.readFileSync 'serialize.gz'
await zlib.gunzip buf_gz, defer err, buf
throw err if err
await fs.readFile "./validation.json", defer err, verify_txt
throw err if err
verify_hash = JSON.parse verify_txt
solution = require './solution'
solution.init(buf)
score = 0
fp = 0
fn = 0
bool_format = (t)->
t.toString().ljust 5
for k,v of verify_hash
res = solution.test k
console.log "#{k.ljust 100} => #{bool_format res} #{bool_format v}" if res != v
if res == v
score++
else if res && !v
fp++
else if !res && v
fn++
console.log "#{score}/#{h_count verify_hash} (#{(100*score/h_count verify_hash).toFixed(2)}%)"
console.log "fn = #{fn}"
console.log "fp = #{fp}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment