How many triangle words can you make using the list of common English words?

Solution:

score::String->Intscore=sum.map((subtract64).ord.toUpper)istrig::Int->Boolistrign=istrig'ntrigsistrig'::Int->[Int]->Boolistrig'n(t:ts)|n==t=True|otherwise=ift<n&&headts>nthenFalseelseistrig'ntstrigs=map(\n->n*(n+1)`div`2)[1..]--get ws from the Euler sitews=["A","ABILITY"..."YOURSELF","YOUTH"]problem_42=length$filterid$map(istrig.score)ws

Find arithmetic sequences, made of prime terms, whose four digits are permutations of each other.

Solution:

I'm new to haskell, improve here :-)

I tidied up your solution a bit, mostly by using and composing library functions where possible...makes it faster on my system. Jim Burton 10:02, 9 July 2007 (UTC)

importData.Listisprime::(Integrala)=>a->Boolisprimen=isprime22whereisprime2x|x<n=ifn`mod`x==0thenFalseelseisprime2(x+1)|otherwise=True-- 'each' works like this: each (1234,4) => [1,2,3,4]each::(Int,Int)->[Int]each=unfoldr(\(y,o)->letx=10^(o-1)(d,m)=y`divMod`xinifo==0thenNothingelseJust(d,(m,o-1)))ispermut::Int->Int->Boolispermut=letf=(sort.each.(,)4)in(.f).(==).fisin::(Eqa)=>a->[[a]]->Boolisin=any.elemproblem_49_1::[Int]->[[Int]]->[[Int]]problem_49_1[]res=resproblem_49_1(pr:prims)res=problem_49_1primsres'whereres'=ifpr`isin`resthenreselseres++[pr:(filter(ispermutpr)(pr:prims))]problem_49::[[Int]]problem_49=problem_49_1[n|n<-[1000..9999],isprimen][]