diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | census.icl | 34 |
2 files changed, 39 insertions, 0 deletions
@@ -1,3 +1,4 @@ +# TeX *.aux *.glo *.idx @@ -27,3 +28,7 @@ *.synctex.gz _minted-*/ +# Clean +Clean System Files/ +census + diff --git a/census.icl b/census.icl new file mode 100644 index 0000000..a236fe2 --- /dev/null +++ b/census.icl @@ -0,0 +1,34 @@ +//http://codegolf.stackexchange.com/a/70115/42682 +module census + +import StdEnv + +//Start = v 538 [("CA",38000000.0), ("NH",1300000.0)] +//Start = v 2 [("A",1.0)] +//Start = v 538 [("DC", 1000000.0), ("RH", 1.0)] +Start=votes 100 [("A",12.0),("B",8.0),("C",3.0),("D",0.0)] + +f=fst +d=snd +q=sqrt +l=length +v n s#d=filter(((==)"DC")o f)s +=sortBy(\(a,b)(c,d).b>d)([(t,3.0)\\t<-d]++w(n-3*(l s))[(t,1.0)\\t<-removeMembers s d]) +w 0 s=map(\(p,r).(p,r+2.0))s +w n s#s=sortBy(\a b.A a>A b)s +#(p,r)=hd s +=w(n-1)[(p,r+1.0):tl s] +A ((_,p),r)=p/q(r*r+r) + +votes n states +# dc = filter (((==)"DC")o fst) states += sortBy (\(a,b)(c,d).b>d) ([(t,3.0) \\ t <- dc] ++ votes` (n-3*length states) [(t,1.0)\\t<-removeMembers states dc]) +where + votes` 0 states = map (\(p,r).(p,r+2.0)) states + votes` n states + # states = sortBy (\a b.A a > A b) states + # (p,r) = hd states + = votes` (n-1) [(p,r+1.0):tl states] + + A ((_,p),r) = p / sqrt(r*r+r) + |