Skip to content

Instantly share code, notes, and snippets.

@dat-vikash
Created March 31, 2015 16:25
Show Gist options
  • Save dat-vikash/d887af0fef06df61ceef to your computer and use it in GitHub Desktop.
Save dat-vikash/d887af0fef06df61ceef to your computer and use it in GitHub Desktop.
SIM Distribution: fitSenatorsBasedOnRarity
[1] def fitSenatorsBasedOnRarity(committeesWithIssueConfs: Map[Committee, mutable.Queue[String]], senators: Set[Senator], party: String) =
{
[2] var takenSenators: mutable.Set[Senator] = senators.to[mutable.Set]
[3] committeesWithIssueConfs.foreach(committee =>
committee._2.foreach(issue => {
// get a senator from each faction
[4] val tmpSenatorDem = takenSenators.find(s => s.faction.name.equalsIgnoreCase(party) && doesMatchPositionRule(issue, s))
[5] tmpSenatorDem match {
case None => // do nothing
case Some(senator) => {
[6] addSenatorToCommitteeForIssueConference(senator,committee._1,issue)
[7] takenSenators = takenSenators - senator
}
}
})
)
[8] takenSenators
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment