Created
January 5, 2012 01:20
-
-
Save MarkBorcherding/1563196 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
fs = require 'fs' | |
_ = require 'underscore' | |
users = [3,5,6] | |
class Graph | |
constructor: (text) -> | |
states = text.split '\n' | |
@states = {} | |
@taken = {} | |
_.each states, (state) => | |
[current, contigs...] = state.split ',' | |
@states[current] = contigs | |
console.log @states | |
map: (state, users, upos) -> | |
if users.length() == upos | |
return | |
user = users[upos] | |
if user == 0 | |
return map state, users, (upos+1) | |
else | |
if !@taken[state] | |
@taken[state] = upos | |
users[upos] = users[upos]-- | |
end | |
fs.readFile 'states.txt', 'utf8',(err, data) -> | |
g = new Graph data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment