Good old C. Be advised though there are ways to bork this one with some inputs not consistent with the rubric.
int score(char *word) { // Digits are one less than score values for each letter // This maps 1-10 to 0-9, allowing one-character representation of each score char *letter_scores = "02210313074020029000033739"; int score = 0, letter_count = 0, mult=1; for(char *ptr = word; *ptr; ptr++) { if (isalpha(*ptr)) { letter_count++; int letter_score = letter_scores[toupper(*ptr)-'A']-'0'+1; score += letter_score; if (*(ptr+1) == '*') { score += letter_score; if (*(ptr+2) == '*') { score += letter_score; } } } if (*ptr == '(') { mult = *(ptr+1) == 'd' ? 2 : 3; break; } } return score*mult+50*(letter_count == 7); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Good old C. Be advised though there are ways to bork this one with some inputs not consistent with the rubric.