Skip to content

Instantly share code, notes, and snippets.

@jinjor
Last active August 29, 2015 14:01
Show Gist options
  • Save jinjor/36ffc69a807ad3e228f8 to your computer and use it in GitHub Desktop.
Save jinjor/36ffc69a807ad3e228f8 to your computer and use it in GitHub Desktop.
CodeIQ「チケットゴブル問題」
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