Last active
August 29, 2015 14:01
-
-
Save jinjor/a58d032efbea93a4d1aa to your computer and use it in GitHub Desktop.
CodeIQ「チケットゴブル問題」貪欲法 303bytes
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.Split;import Data.List;import Data.Ord;b(_,_,a)=a;p q[]=[];p q((n,w,a):t)|q<w=n:(p a t)|True=p q t;y a=(show.length)a++(a>>=id);main=do e<-readFile"tickets.txt";putStr.y.sort$p 0$sortBy(comparing b)[(' ':l!!0,w 1,w 3)|s<-lines e,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