We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For some reason I get a runtime error on testcase 14 that I can't replicate... testcase works fine on my laptop any help would be much appreciated.
Here is my code:
-- Enter your code here. Read input from STDIN. Print output to STDOUTimportControl.MonaddataPrimeFactor=PrimeFactor{prime::Int,indice::Int}deriving(Eq)instanceShowPrimeFactorwhereshowx=show(primex)++" "++show(indicex)instanceOrdPrimeFactorwherecomparec1c2=compare(primec1,indicec1)(primec2,indicec2)asPrime::[String]->[PrimeFactor]asPrime(a:b:xs)=(PrimeFactor(reada)(readb)):asPrimexsasPrime_=[]gcdEl::[PrimeFactor]->[PrimeFactor]->[PrimeFactor]gcdEl(a:as)(b:bs)|x==y=minab:gcdElasbs|x<y=gcdEl(b:bs)as|otherwise=gcdEl(a:as)bswhere((PrimeFactorx_),(PrimeFactory_))=(a,b)gcdEl__=[]gcdLs::[[PrimeFactor]]->[PrimeFactor]gcdLs[a,b]=gcdElabgcdLs(a:as)=gcdEla$gcdLsasgcdLs_=[]main::IO()main=doq<-getLineelements<-replicateM(readq)getLineputStrLn$unwords$mapshow$gcdLs$map(asPrime.words)elements
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lists and GCD
You are viewing a single comment's thread. Return to all comments →
For some reason I get a runtime error on testcase 14 that I can't replicate... testcase works fine on my laptop any help would be much appreciated. Here is my code: