35
1
Problem
You're stuck in a cabin in the middle of the woods, with only an old scrabble set to entertain yourselves. Upon inspection you see that the scrabble letters are so worn, that only the points for each letter are visible.
Nonetheless you decide to play a game. You pull seven letters from the bag and place them on your tray, your challenge is to determine what those letters could be.
So generally, given a list of points convert it into any possible string or list of letters.
Scrabble Tiles and Distributions
- 2 blank tiles (scoring 0 points)
- 1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4
- 2 points: D ×4, G ×3
- 3 points: B ×2, C ×2, M ×2, P ×2
- 4 points: F ×2, H ×2, V ×2, W ×2, Y ×2
- 5 points: K ×1
- 8 points: J ×1, X ×1
- 10 points: Q ×1, Z ×1
So if you have a list of points [10,10,8,5,1,1,1]
then "QZJKEEE"
would be valid but "QQJKEEE"
would not be valid (since there is only 1 Q tile in the bag)
Problem Specific Rules
- You may assume all inputs are valid and that there will always be 7 tiles (i.e it wont be a list of seven 10 point tiles and won't be 9 tiles)
- You can assume no tiles have been previously pulled from the bag (so the distribution is the standard distribution of english tiles as defined above)
- You do not have to generate a valid word, only a valid string of letters.
- The order of your string is irrelevant as long as for each tile there is a corresponding letter.
- Points are based on the standard english scrabble tile points as defined above.
- You may output in upper or lower case, for a blank tile you may output either a space character or an underscore '_'
- Your answer may output as any reasonable representation of the tiles such as a List, String, Array or Sequence
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.
Test Cases
Obviously since you can output any possible value it's difficult to define strict test cases.
Some cases with a possible valid return value:
[10,0,10,5,8,8,0] -> "Q ZKJX "
[1,1,1,1,1,1,1] -> "EEEEEEE"
[1,2,3,4,5,8,0] -> "NDBHKJ "
[2,2,2,2,2,2,2] -> "DGDGDGD"
Some cases with an invalid return value:
[10,0,10,5,8,8,0] -> "Q QKJX " - Too many Qs
[1,1,1,1,1,1,1] -> "EEEEEE " - Space is 0 points not 1
[1,2,3,4,5,8,0] -> "NDBH" - Too short
[1,2,3,4,5,8,0] -> "NDBHKJ I" - Too long
[1,2,3,4,5,8,0] -> "ÉDBHKJ1" - Contains none scrabble characters
[2,2,2,2,2,2,2] -> "GDGDGDG" - Contains too many Gs (case for invalid cycling)
Do I need to output a string or is a list ok? – Maltysen – 2019-04-10T11:51:56.010
You can output a list, I'll update the question – Expired Data – 2019-04-10T11:52:47.510
1What can I output for a blank? – Maltysen – 2019-04-10T12:09:16.030
Good question I'll let you output a space or _, since typically it could be represented by either. I'll update the question – Expired Data – 2019-04-10T12:11:27.097
3Suggested test case:
[2,2,2,2,2,2,2]
(the only case where it's important to start with aD
rather than aG
if a cycling method is used) – Arnauld – 2019-04-10T13:13:36.767"You may output in upper or lower case" - is mixed-case output allowed? – Jonathan Allan – 2019-04-10T18:36:58.277
Yes mixed case is allowed – Expired Data – 2019-04-10T18:38:41.663
Thanks (pro tip: use @ to notify someone [only 1 person] - as the poster you are notified of all comments here, but others are not) – Jonathan Allan – 2019-04-10T18:47:54.080
Yeah it doesn't work on my phone @jonathan allan – Expired Data – 2019-04-10T18:55:26.933
1Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData. – Tau – 2019-04-10T20:56:11.513
Must the input be an array of integers, or can it be an array of string? – Reinstate Monica -- notmaynard – 2019-04-10T22:45:51.530