Created
April 28, 2016 12:22
-
-
Save vird/453a86cf16903c017b060cdd457baf86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i iced-coffee-script | |
iced test.coffee | |
# or ./test.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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