Skip to content

Instantly share code, notes, and snippets.

@MarkBorcherding
Created January 5, 2012 01:20
Show Gist options
  • Save MarkBorcherding/1563196 to your computer and use it in GitHub Desktop.
Save MarkBorcherding/1563196 to your computer and use it in GitHub Desktop.
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