Last active
August 29, 2015 14:01
-
-
Save jinjor/36ffc69a807ad3e228f8 to your computer and use it in GitHub Desktop.
CodeIQ「チケットゴブル問題」
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
import Data.List;import Data.List.Split;import Data.Ord;l=length;f(_,b,_)=b;g(_,_,m)=m;d=comparing;y(p,e,r)b=(p,r,m$dropWhile((>=)e.f)b):b;m[]=[];m t=maximumBy(d l)[a:b|(a,_,b)<-t];a s=(show.l$s):s>>=id;main=do c<-readFile"tickets.txt";putStr.a.sort$m$foldr y[]$sortBy(d g)[(' ':l!!0,w 3,w 1)|s<-lines c,let l=splitOneOf" -/"s;p=read.(!!)l;w i=31*(p i)+(p$i+1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment