Because these are fun in languages you don't actually know, here's Haskell:
importData.Map(Map,(!))importqualifiedData.MapasMapscores::MapCharIntscores=Map.fromListpairswherepairs=[('a',1),('b',3),('c',3),('d',2),('e',1),('f',4),('g',2),('h',4),('i',1),('j',8),('k',5),('l',1),('m',3),('n',1),('o',1),('p',3),('q',10),('r',1),('s',1),('t',1),('u',1),('v',4),('w',4),('x',8),('y',4),('z',10)]scoreWord::String->IntscoreWordw=letsevenLetterBonus=if(length$stripMarkersw)==7then50else0wordMultiplier=letsuffix=dropWhile(/='(')winiflengthsuffix>0thencasesuffix!!1of't'->3'd'->2_->1else1-- preparedWord=expandMarkers$takeWhile(/='(')wrawScore=sum$scoreLetters$preparedWordinrawScore*wordMultiplier+sevenLetterBonuswherescoreLetterscs=map(\c->scores!c)cs-- transform doubles, triples, carats-- if we hit an asterisk, replace it with the previous letter-- if we hit a carat, drop the previus letterexpandMarkers::String->StringexpandMarkers[]=[]expandMarkers(c:[])=[c]expandMarkers(c:rest)=caseheadrestof'*'->if(head$tailrest)=='*'then[c]++[c]++[c]++(expandMarkers$drop2rest)else[c]++[c]++(expandMarkers$tailrest)'^'->expandMarkers$tailrest_->[c]++expandMarkersrest-- remove suffix and all markers for deciding on the 7-letter bonusstripMarkers::String->StringstripMarkersw=filter(\c->c/='*'&&c/='^')$takeWhile(/='(')w
I didn't provide tests, but I think it works. Maybe I'll write some later on.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Because these are fun in languages you don't actually know, here's Haskell:
I didn't provide tests, but I think it works. Maybe I'll write some later on.