Worn-tile Scrabble
$begingroup$
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)
code-golf string scrabble
$endgroup$
|
show 6 more comments
$begingroup$
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)
code-golf string scrabble
$endgroup$
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
1
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
3
$begingroup$
Suggested 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)
$endgroup$
– Arnauld
yesterday
1
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday
|
show 6 more comments
$begingroup$
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)
code-golf string scrabble
$endgroup$
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)
code-golf string scrabble
code-golf string scrabble
edited yesterday
Expired Data
asked yesterday
Expired DataExpired Data
792216
792216
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
1
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
3
$begingroup$
Suggested 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)
$endgroup$
– Arnauld
yesterday
1
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday
|
show 6 more comments
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
1
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
3
$begingroup$
Suggested 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)
$endgroup$
– Arnauld
yesterday
1
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
1
1
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
3
3
$begingroup$
Suggested test case:
[2,2,2,2,2,2,2]
(the only case where it's important to start with a D
rather than a G
if a cycling method is used)$endgroup$
– Arnauld
yesterday
$begingroup$
Suggested test case:
[2,2,2,2,2,2,2]
(the only case where it's important to start with a D
rather than a G
if a cycling method is used)$endgroup$
– Arnauld
yesterday
1
1
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday
|
show 6 more comments
13 Answers
13
active
oldest
votes
$begingroup$
JavaScript (ES6), 72 bytes
A shorter variant suggested by @supercat
a=>a.map(o=n=>'?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31])
Try it online!
JavaScript (ES6), 137 ... 84 78 77 76 bytes
Saved 10 bytes by using Neil's cycling method
Returns a list of tiles. Uses _
for blank tiles.
a=>a.map(o=n=>"____FHVWGDGD_K__BCMPEEEE_ZQ__XJ"[n*20%44%32+(o[n]=-~o[n])%4])
Try it online!
How?
For each number of points, we cycle through a group of exactly 4 tiles, starting with the second tile of each group (this is important for G
vs D
):
points | group | max. sequence
--------+-------+---------------
0 | ____ | __
1 | EEEE | EEEEEEE
2 | GDGD | DGDGDGD
3 | BCMP | CMPBCMP
4 | FHVW | HVWFHVW
5 | _K__ | K
8 | _XJ_ | XJ }--- these letters may only appear once each
10 | _ZQ_ | ZQ /
All these groups are stored as a single string of 31 characters:
____FHVWGDGD_K__BCMPEEEE_ZQ__XJ
^ ^ ^ ^ ^ ^ ^ ^
0 4 8 12 16 20 24 28
NB: We don't need to store the final "_"
in "_XJ_"
, as it will never be accessed anyway.
The number of points $n$ is converted to the correct index $i_n$ into this string with:
$$i_n=((20times n)bmod 44)bmod 32$$
n | *20 | mod 44 | mod 32 | group
----+-----+--------+--------+-------
0 | 0 | 0 | 0 | ____
1 | 20 | 20 | 20 | EEEE
2 | 40 | 40 | 8 | GDGD
3 | 60 | 16 | 16 | BCMP
4 | 80 | 36 | 4 | FHVW
5 | 100 | 12 | 12 | _K__
8 | 160 | 28 | 28 | _XJ_
10 | 200 | 24 | 24 | _ZQ_
The current position in each group is stored in the object $o$.
$endgroup$
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would bea=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version isa=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.
$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.
$endgroup$
– Arnauld
17 hours ago
add a comment |
$begingroup$
Charcoal, 33 bytes
⭆觧⪪”&↖“Vh_z↶∕¡⌈∨₂χ¹‖◨⌊″”¶ι№…θκι
Try it online! Link is to verbose version of code. Explanation:
θ Input array
⭆ Map over elements and join
”...” Literal string " nEnDGnBCMPnFHVWnKnnnJXnnQZ"
⪪ ¶ Split on newlines
§ ι Indexed by current element
§ Cyclically indexed by
№…θκι Number of times current element has already appeared
Implcitly print
$endgroup$
add a comment |
$begingroup$
Jelly, 31 30 27 26 bytes
“ñẒẎYñ(“Nut¦hß’ṃØA;€⁶ɓṢĖœị
A monadic Link accepting a list of integers which yields a list of characters.
- a mishmash of my previous, below, and my improvement of Nick Kennedy's
Try it online!
The output is not given in the same order as the input (this is allowed).
Using 2 of my own additions to the language in an answer does not happen often! (ṃ
and ɓ
here).
How?
“...“...’ṃØA;€⁶ɓṢĖœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...“...’ - list of base 250 integers [28089224382041, 77611203526272]
ØA - 'ABC...XYZ'
ṃ - base decompress (vectorises) ["EDMFKZZJZQ", "NGPYKZZXZZ"]
;€ - for €ach: concatenate:
⁶ - a space ["EDMFKZZJZQ ", "NGPYKZZXZZ "]
ɓ - start a new dyadic chain with swapped arguments - i.e. f(V,that)
Ṣ - sort [0,1,1,2,3,10,10]
Ė - enumerate [[1,0],[2,1],[3,1],[4,2],[5,3],[6,10],[7,10]]
œị - multi-dimensional index into " NEGMZQ"
(1-based and modular)
previous @ 30
“²rṛʂṂø5=Ɓṇ^N¥Y»⁾tky;⁶s2ɓṢĖUœị
A monadic Link accepting a list of integers which yields a list of characters.
Try it online!
This one's output is also mixed-case (this is allowed).
How?
“...»⁾tky;⁶s2ɓṢĖUœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...» - compression of dictionary entries:
- "end", "GMP", "fyttes", "adj", and "xci" and the string "qz"
- "endGMPfyttesadjxciqz"
y - translate with:
⁾tk - ['t', 'k'] "endGMPfykkesadjxciqz"
;⁶s2ɓṢĖUœị - ...
- ...then like the above method (except U reverses each pair of indices)
" neGMzq"
$endgroup$
$begingroup$
I think you made a typo in your first explanation.' NWGMZQ'
after the multi-dimensional index into would be quite a feat without anyW
in the string. ;)
$endgroup$
– Kevin Cruijssen
17 hours ago
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
add a comment |
$begingroup$
Pyth - 92 86 83 81 80 75 60 52 49 42 36 bytes
Loops through input, popping off the available letters. I just have one of each letter that together give 7 for that point category. Now using packed string encoding.
K[M*L7c."B_êº çÑOÒ
7âCkÑ"Lm.)@K
K Assign to K
[M Map list(for popping). Uses a quirk of M to splat each first
*L7 Map repeating each string by 7
c L Split on occurrences of 'L'
."..." Packed string encoding of the needed letters
m (Q) Map on input (input is taken implicitly)
.) Pop. This returns the first element after removing it
@K Index into K
(d) The loop variable is given implicitly
Btw, this is the original letter string before encoding: "_ E DG BCMP FHVW K JX QZ"
.
Try it online.
$endgroup$
add a comment |
$begingroup$
Perl 5, 71 bytes
@a=(__,'E'x7,DDDDGGG,BBCCMMP,FFHHVVW,K,1,1,JX,1,QZ);say chop$a[$_]for<>
Try it online!
$endgroup$
add a comment |
$begingroup$
05AB1E, 70 52 39 38 29 26 25 bytes
{ε.•3Oû}α›ηö‡.ÝŽ{•2ôÁyèNè?
-18 bytes thanks to @ExpiredData.
-13 bytes by using the same extend to size 7 from @Maltysen's Pyth answer.
-9 bytes by creating a port of @JonathanAllan's Jelly answer, so make sure to upvote him!
-3 bytes thanks to @Emigna.
Results in a list of characters, and uses lowercase letters and a space for blanks.
Try it online or verify some more test cases.
Explanation:
{ # Sort the (implicit) input-list
ε # Map each character `y` in this list to:
.•3Oû}α›ηö‡.ÝŽ{• # Push compressed string "endgmpfykkzzzzjxzzqz "
2ô # Split into parts of size 2
Á # Rotate it once towards the left so the space is leading
yè # Use integer `y` to index into the string-pairs
Nè # Then get the `N`'th character of the string-pair (with automatic
# wraparound), where `N` is the index of the loop
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•3Oû}α›ηö‡.ÝŽ{•
is "endgmpfykkzzzzjxzzqz "
.
Previous 38 bytes answer:
.•Mñ&Àû«ì{₆v*Å+µ-•#ðšε7∍}IvDyèн©?ε®õ.;
Try it online or verify some more test cases.
Explanation:
.•Mñ&Àû«ì{₆v*Å+µ-• # Push compressed string "e dg bcmp fhvw k jx qz"
# # Split on spaces: ["e","dg","bcmp","fhvw","k","","","jx","","qz"]
ðš # Prepend a space to this list
ε7∍} # Extend each string to size 7:
# [" ","eeeeeee","dgdgdgd","bcmpbcm","fhvwfhv","kkkkkkk","","","jxjxjxj","","qzqzqzq"]
Iv # Loop `y` over the input-list:
Dyè # Get the `y`'th string from a copy of the list
н # Get it's first character
©? # Store it in the register, and print it without trailing newline
ε # Then map each string in the list to:
®õ.; # Remove the first occurrence of the character from the register
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•Mñ&Àû«ì{₆v*Å+µ-•
is "e dg bcmp fhvw k jx qz"
.
$endgroup$
$begingroup$
Can't you use" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?
$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
$begingroup$
You can save 3 bytes using{v
instead of7F
andy
instead ofI{Nè
.
$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
add a comment |
$begingroup$
C (gcc), 110 bytes
_={0,7,14,21,0,0,22,0,24};f(char*s){for(;*s+1;s++)*s=*s?*s-1?"DDDDGGGBBCCMMPFFHHVVWKJXQZ"[_[*s-2]++]:69:32;}
Try it online!
Uses the _
array as an index into the static string "DDDDGGGBBCCMMPFFHHVVWKJXQZ"
dynamically with exceptions for 0 and 1.
Argument is a -1
-terminated array of scores which is transformed in-place into a -1
-terminated string.
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 104 90 bytes
a=>a.OrderBy(x=>x).Select((x,i)=>(x="_ E DG BCMP FHVW K JX QZ".Split()[x])[i%x.Length])
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 34 32 bytes
“¿RÇĊƈ⁸⁾%ỵṆþœsṀṂ’ṃØAṣ”A;⁶ẋ€7⁸ịḢ€
Try it online!
I hadn’t seen there was a shorter Jelly answer when I wrote this, and this uses a different approach so I thought was worth posting as well.
Thanks to @JonathanAllan for saving 2 bytes!
$endgroup$
$begingroup$
By using base-decompression,ṃ
, you can save 2 bytes
$endgroup$
– Jonathan Allan
yesterday
add a comment |
$begingroup$
Python 3, 178 142 135 127 112 117 bytes
def f(l):
d=list(map(list," _EEEEEEE_DDDDGGG_BBCCMMP_FFHHVVW_K___JX__QZ".split('_')))
return[d[i].pop()for i in l]
Try it online!
-1 byte thanks to cdlane
correct thanks to mathmandan
$endgroup$
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte
$endgroup$
– cdlane
yesterday
$begingroup$
This functionf
probably doesn't need to be named, so you can save 2 bytes. However,f
consumes the entries ofd
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, runningf([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885
$endgroup$
– mathmandan
yesterday
add a comment |
$begingroup$
Python 2, 102 bytes (or maybe 95?)
(Also fine for Python 3.)
lambda a:''.join([r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a))
Try it online!
I don't think the following would be acceptable:
lambda a:[[r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a)]
This second version would give output like ['__', 'JX', 'QZ', 'K']
. So the letters would be correct, but they would be collected by point value. (If this were acceptable, it would save 7 bytes.)
$endgroup$
add a comment |
$begingroup$
PHP, 101 bytes
$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($argv as$t){echo$c=($d=$b[$t])[0];$b[$t]=substr($d,1).$c;}
As a standalone program, input via command line:
$ php s.php 10 0 10 5 8 8 0
"Q_ZKJX_"
Try it online!
Or 112 bytes as a function
function($a){$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($a as$t)$b[$t]=substr($d=$b[$t],1).$c=$d[0];return$c;}
Try it online!
Output
[10,0,10,5,8,8,0] "Q_ZKJX_"
[1,1,1,1,1,1,1] "EEEEEEE"
[1,2,3,4,5,8,0] "EDBFKJ_"
[2,2,2,2,2,2,2] "DGDGDGD"
$endgroup$
add a comment |
$begingroup$
Ruby, 77 76 bytes
->a{r=%w{_ E DG BCMP FHVW K . . JX . QZ};a.map{|i|(r[i]<<r[i][0]).slice! 0}}
Try it online!
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182954%2fworn-tile-scrabble%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
JavaScript (ES6), 72 bytes
A shorter variant suggested by @supercat
a=>a.map(o=n=>'?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31])
Try it online!
JavaScript (ES6), 137 ... 84 78 77 76 bytes
Saved 10 bytes by using Neil's cycling method
Returns a list of tiles. Uses _
for blank tiles.
a=>a.map(o=n=>"____FHVWGDGD_K__BCMPEEEE_ZQ__XJ"[n*20%44%32+(o[n]=-~o[n])%4])
Try it online!
How?
For each number of points, we cycle through a group of exactly 4 tiles, starting with the second tile of each group (this is important for G
vs D
):
points | group | max. sequence
--------+-------+---------------
0 | ____ | __
1 | EEEE | EEEEEEE
2 | GDGD | DGDGDGD
3 | BCMP | CMPBCMP
4 | FHVW | HVWFHVW
5 | _K__ | K
8 | _XJ_ | XJ }--- these letters may only appear once each
10 | _ZQ_ | ZQ /
All these groups are stored as a single string of 31 characters:
____FHVWGDGD_K__BCMPEEEE_ZQ__XJ
^ ^ ^ ^ ^ ^ ^ ^
0 4 8 12 16 20 24 28
NB: We don't need to store the final "_"
in "_XJ_"
, as it will never be accessed anyway.
The number of points $n$ is converted to the correct index $i_n$ into this string with:
$$i_n=((20times n)bmod 44)bmod 32$$
n | *20 | mod 44 | mod 32 | group
----+-----+--------+--------+-------
0 | 0 | 0 | 0 | ____
1 | 20 | 20 | 20 | EEEE
2 | 40 | 40 | 8 | GDGD
3 | 60 | 16 | 16 | BCMP
4 | 80 | 36 | 4 | FHVW
5 | 100 | 12 | 12 | _K__
8 | 160 | 28 | 28 | _XJ_
10 | 200 | 24 | 24 | _ZQ_
The current position in each group is stored in the object $o$.
$endgroup$
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would bea=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version isa=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.
$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.
$endgroup$
– Arnauld
17 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 72 bytes
A shorter variant suggested by @supercat
a=>a.map(o=n=>'?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31])
Try it online!
JavaScript (ES6), 137 ... 84 78 77 76 bytes
Saved 10 bytes by using Neil's cycling method
Returns a list of tiles. Uses _
for blank tiles.
a=>a.map(o=n=>"____FHVWGDGD_K__BCMPEEEE_ZQ__XJ"[n*20%44%32+(o[n]=-~o[n])%4])
Try it online!
How?
For each number of points, we cycle through a group of exactly 4 tiles, starting with the second tile of each group (this is important for G
vs D
):
points | group | max. sequence
--------+-------+---------------
0 | ____ | __
1 | EEEE | EEEEEEE
2 | GDGD | DGDGDGD
3 | BCMP | CMPBCMP
4 | FHVW | HVWFHVW
5 | _K__ | K
8 | _XJ_ | XJ }--- these letters may only appear once each
10 | _ZQ_ | ZQ /
All these groups are stored as a single string of 31 characters:
____FHVWGDGD_K__BCMPEEEE_ZQ__XJ
^ ^ ^ ^ ^ ^ ^ ^
0 4 8 12 16 20 24 28
NB: We don't need to store the final "_"
in "_XJ_"
, as it will never be accessed anyway.
The number of points $n$ is converted to the correct index $i_n$ into this string with:
$$i_n=((20times n)bmod 44)bmod 32$$
n | *20 | mod 44 | mod 32 | group
----+-----+--------+--------+-------
0 | 0 | 0 | 0 | ____
1 | 20 | 20 | 20 | EEEE
2 | 40 | 40 | 8 | GDGD
3 | 60 | 16 | 16 | BCMP
4 | 80 | 36 | 4 | FHVW
5 | 100 | 12 | 12 | _K__
8 | 160 | 28 | 28 | _XJ_
10 | 200 | 24 | 24 | _ZQ_
The current position in each group is stored in the object $o$.
$endgroup$
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would bea=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version isa=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.
$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.
$endgroup$
– Arnauld
17 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 72 bytes
A shorter variant suggested by @supercat
a=>a.map(o=n=>'?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31])
Try it online!
JavaScript (ES6), 137 ... 84 78 77 76 bytes
Saved 10 bytes by using Neil's cycling method
Returns a list of tiles. Uses _
for blank tiles.
a=>a.map(o=n=>"____FHVWGDGD_K__BCMPEEEE_ZQ__XJ"[n*20%44%32+(o[n]=-~o[n])%4])
Try it online!
How?
For each number of points, we cycle through a group of exactly 4 tiles, starting with the second tile of each group (this is important for G
vs D
):
points | group | max. sequence
--------+-------+---------------
0 | ____ | __
1 | EEEE | EEEEEEE
2 | GDGD | DGDGDGD
3 | BCMP | CMPBCMP
4 | FHVW | HVWFHVW
5 | _K__ | K
8 | _XJ_ | XJ }--- these letters may only appear once each
10 | _ZQ_ | ZQ /
All these groups are stored as a single string of 31 characters:
____FHVWGDGD_K__BCMPEEEE_ZQ__XJ
^ ^ ^ ^ ^ ^ ^ ^
0 4 8 12 16 20 24 28
NB: We don't need to store the final "_"
in "_XJ_"
, as it will never be accessed anyway.
The number of points $n$ is converted to the correct index $i_n$ into this string with:
$$i_n=((20times n)bmod 44)bmod 32$$
n | *20 | mod 44 | mod 32 | group
----+-----+--------+--------+-------
0 | 0 | 0 | 0 | ____
1 | 20 | 20 | 20 | EEEE
2 | 40 | 40 | 8 | GDGD
3 | 60 | 16 | 16 | BCMP
4 | 80 | 36 | 4 | FHVW
5 | 100 | 12 | 12 | _K__
8 | 160 | 28 | 28 | _XJ_
10 | 200 | 24 | 24 | _ZQ_
The current position in each group is stored in the object $o$.
$endgroup$
JavaScript (ES6), 72 bytes
A shorter variant suggested by @supercat
a=>a.map(o=n=>'?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31])
Try it online!
JavaScript (ES6), 137 ... 84 78 77 76 bytes
Saved 10 bytes by using Neil's cycling method
Returns a list of tiles. Uses _
for blank tiles.
a=>a.map(o=n=>"____FHVWGDGD_K__BCMPEEEE_ZQ__XJ"[n*20%44%32+(o[n]=-~o[n])%4])
Try it online!
How?
For each number of points, we cycle through a group of exactly 4 tiles, starting with the second tile of each group (this is important for G
vs D
):
points | group | max. sequence
--------+-------+---------------
0 | ____ | __
1 | EEEE | EEEEEEE
2 | GDGD | DGDGDGD
3 | BCMP | CMPBCMP
4 | FHVW | HVWFHVW
5 | _K__ | K
8 | _XJ_ | XJ }--- these letters may only appear once each
10 | _ZQ_ | ZQ /
All these groups are stored as a single string of 31 characters:
____FHVWGDGD_K__BCMPEEEE_ZQ__XJ
^ ^ ^ ^ ^ ^ ^ ^
0 4 8 12 16 20 24 28
NB: We don't need to store the final "_"
in "_XJ_"
, as it will never be accessed anyway.
The number of points $n$ is converted to the correct index $i_n$ into this string with:
$$i_n=((20times n)bmod 44)bmod 32$$
n | *20 | mod 44 | mod 32 | group
----+-----+--------+--------+-------
0 | 0 | 0 | 0 | ____
1 | 20 | 20 | 20 | EEEE
2 | 40 | 40 | 8 | GDGD
3 | 60 | 16 | 16 | BCMP
4 | 80 | 36 | 4 | FHVW
5 | 100 | 12 | 12 | _K__
8 | 160 | 28 | 28 | _XJ_
10 | 200 | 24 | 24 | _ZQ_
The current position in each group is stored in the object $o$.
edited 17 hours ago
answered yesterday
ArnauldArnauld
80.8k797334
80.8k797334
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would bea=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version isa=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.
$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.
$endgroup$
– Arnauld
17 hours ago
add a comment |
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would bea=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version isa=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.
$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.
$endgroup$
– Arnauld
17 hours ago
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would be
a=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version is a=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.$endgroup$
– supercat
yesterday
$begingroup$
Advancing o[n] by 8 each time would cost one extra character for the advancement, but allow one to replace %4 and %32 both with &31 for a net win. My best, based on yours, would be
a=>a.map(o=n=>('?ED?BWQ?_EG?CFZ?_EDJMH?K?EGXPV'[n*9.4+(o[n]=7-~o[n])&31]))
. A shorter, "almost" version is a=>a.map(o=n=>("_EDBFK_EDCHJQEGMVXZEGPW"[n+(o[n]=5-~o[n])%24]))
but that approach would needs a compact way to map the values 8 and 10 into 11 and 12, plus a slight adjustment to the string to fix an off-by-one problem.$endgroup$
– supercat
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Sounds good! I'll have a closer look at it tomorrow.
$endgroup$
– Arnauld
yesterday
$begingroup$
@supercat Another interesting formula is
'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.$endgroup$
– Arnauld
17 hours ago
$begingroup$
@supercat Another interesting formula is
'_??VKWZHQFP?M?CGBGXDJD'[(n*96+(o[n]=32-~o[n]))%68%33]||'E'
, with a lookup string of only 22 characters. The full code is still 2 bytes longer than your solution, though.$endgroup$
– Arnauld
17 hours ago
add a comment |
$begingroup$
Charcoal, 33 bytes
⭆觧⪪”&↖“Vh_z↶∕¡⌈∨₂χ¹‖◨⌊″”¶ι№…θκι
Try it online! Link is to verbose version of code. Explanation:
θ Input array
⭆ Map over elements and join
”...” Literal string " nEnDGnBCMPnFHVWnKnnnJXnnQZ"
⪪ ¶ Split on newlines
§ ι Indexed by current element
§ Cyclically indexed by
№…θκι Number of times current element has already appeared
Implcitly print
$endgroup$
add a comment |
$begingroup$
Charcoal, 33 bytes
⭆觧⪪”&↖“Vh_z↶∕¡⌈∨₂χ¹‖◨⌊″”¶ι№…θκι
Try it online! Link is to verbose version of code. Explanation:
θ Input array
⭆ Map over elements and join
”...” Literal string " nEnDGnBCMPnFHVWnKnnnJXnnQZ"
⪪ ¶ Split on newlines
§ ι Indexed by current element
§ Cyclically indexed by
№…θκι Number of times current element has already appeared
Implcitly print
$endgroup$
add a comment |
$begingroup$
Charcoal, 33 bytes
⭆觧⪪”&↖“Vh_z↶∕¡⌈∨₂χ¹‖◨⌊″”¶ι№…θκι
Try it online! Link is to verbose version of code. Explanation:
θ Input array
⭆ Map over elements and join
”...” Literal string " nEnDGnBCMPnFHVWnKnnnJXnnQZ"
⪪ ¶ Split on newlines
§ ι Indexed by current element
§ Cyclically indexed by
№…θκι Number of times current element has already appeared
Implcitly print
$endgroup$
Charcoal, 33 bytes
⭆觧⪪”&↖“Vh_z↶∕¡⌈∨₂χ¹‖◨⌊″”¶ι№…θκι
Try it online! Link is to verbose version of code. Explanation:
θ Input array
⭆ Map over elements and join
”...” Literal string " nEnDGnBCMPnFHVWnKnnnJXnnQZ"
⪪ ¶ Split on newlines
§ ι Indexed by current element
§ Cyclically indexed by
№…θκι Number of times current element has already appeared
Implcitly print
answered yesterday
NeilNeil
82.8k745179
82.8k745179
add a comment |
add a comment |
$begingroup$
Jelly, 31 30 27 26 bytes
“ñẒẎYñ(“Nut¦hß’ṃØA;€⁶ɓṢĖœị
A monadic Link accepting a list of integers which yields a list of characters.
- a mishmash of my previous, below, and my improvement of Nick Kennedy's
Try it online!
The output is not given in the same order as the input (this is allowed).
Using 2 of my own additions to the language in an answer does not happen often! (ṃ
and ɓ
here).
How?
“...“...’ṃØA;€⁶ɓṢĖœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...“...’ - list of base 250 integers [28089224382041, 77611203526272]
ØA - 'ABC...XYZ'
ṃ - base decompress (vectorises) ["EDMFKZZJZQ", "NGPYKZZXZZ"]
;€ - for €ach: concatenate:
⁶ - a space ["EDMFKZZJZQ ", "NGPYKZZXZZ "]
ɓ - start a new dyadic chain with swapped arguments - i.e. f(V,that)
Ṣ - sort [0,1,1,2,3,10,10]
Ė - enumerate [[1,0],[2,1],[3,1],[4,2],[5,3],[6,10],[7,10]]
œị - multi-dimensional index into " NEGMZQ"
(1-based and modular)
previous @ 30
“²rṛʂṂø5=Ɓṇ^N¥Y»⁾tky;⁶s2ɓṢĖUœị
A monadic Link accepting a list of integers which yields a list of characters.
Try it online!
This one's output is also mixed-case (this is allowed).
How?
“...»⁾tky;⁶s2ɓṢĖUœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...» - compression of dictionary entries:
- "end", "GMP", "fyttes", "adj", and "xci" and the string "qz"
- "endGMPfyttesadjxciqz"
y - translate with:
⁾tk - ['t', 'k'] "endGMPfykkesadjxciqz"
;⁶s2ɓṢĖUœị - ...
- ...then like the above method (except U reverses each pair of indices)
" neGMzq"
$endgroup$
$begingroup$
I think you made a typo in your first explanation.' NWGMZQ'
after the multi-dimensional index into would be quite a feat without anyW
in the string. ;)
$endgroup$
– Kevin Cruijssen
17 hours ago
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
add a comment |
$begingroup$
Jelly, 31 30 27 26 bytes
“ñẒẎYñ(“Nut¦hß’ṃØA;€⁶ɓṢĖœị
A monadic Link accepting a list of integers which yields a list of characters.
- a mishmash of my previous, below, and my improvement of Nick Kennedy's
Try it online!
The output is not given in the same order as the input (this is allowed).
Using 2 of my own additions to the language in an answer does not happen often! (ṃ
and ɓ
here).
How?
“...“...’ṃØA;€⁶ɓṢĖœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...“...’ - list of base 250 integers [28089224382041, 77611203526272]
ØA - 'ABC...XYZ'
ṃ - base decompress (vectorises) ["EDMFKZZJZQ", "NGPYKZZXZZ"]
;€ - for €ach: concatenate:
⁶ - a space ["EDMFKZZJZQ ", "NGPYKZZXZZ "]
ɓ - start a new dyadic chain with swapped arguments - i.e. f(V,that)
Ṣ - sort [0,1,1,2,3,10,10]
Ė - enumerate [[1,0],[2,1],[3,1],[4,2],[5,3],[6,10],[7,10]]
œị - multi-dimensional index into " NEGMZQ"
(1-based and modular)
previous @ 30
“²rṛʂṂø5=Ɓṇ^N¥Y»⁾tky;⁶s2ɓṢĖUœị
A monadic Link accepting a list of integers which yields a list of characters.
Try it online!
This one's output is also mixed-case (this is allowed).
How?
“...»⁾tky;⁶s2ɓṢĖUœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...» - compression of dictionary entries:
- "end", "GMP", "fyttes", "adj", and "xci" and the string "qz"
- "endGMPfyttesadjxciqz"
y - translate with:
⁾tk - ['t', 'k'] "endGMPfykkesadjxciqz"
;⁶s2ɓṢĖUœị - ...
- ...then like the above method (except U reverses each pair of indices)
" neGMzq"
$endgroup$
$begingroup$
I think you made a typo in your first explanation.' NWGMZQ'
after the multi-dimensional index into would be quite a feat without anyW
in the string. ;)
$endgroup$
– Kevin Cruijssen
17 hours ago
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
add a comment |
$begingroup$
Jelly, 31 30 27 26 bytes
“ñẒẎYñ(“Nut¦hß’ṃØA;€⁶ɓṢĖœị
A monadic Link accepting a list of integers which yields a list of characters.
- a mishmash of my previous, below, and my improvement of Nick Kennedy's
Try it online!
The output is not given in the same order as the input (this is allowed).
Using 2 of my own additions to the language in an answer does not happen often! (ṃ
and ɓ
here).
How?
“...“...’ṃØA;€⁶ɓṢĖœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...“...’ - list of base 250 integers [28089224382041, 77611203526272]
ØA - 'ABC...XYZ'
ṃ - base decompress (vectorises) ["EDMFKZZJZQ", "NGPYKZZXZZ"]
;€ - for €ach: concatenate:
⁶ - a space ["EDMFKZZJZQ ", "NGPYKZZXZZ "]
ɓ - start a new dyadic chain with swapped arguments - i.e. f(V,that)
Ṣ - sort [0,1,1,2,3,10,10]
Ė - enumerate [[1,0],[2,1],[3,1],[4,2],[5,3],[6,10],[7,10]]
œị - multi-dimensional index into " NEGMZQ"
(1-based and modular)
previous @ 30
“²rṛʂṂø5=Ɓṇ^N¥Y»⁾tky;⁶s2ɓṢĖUœị
A monadic Link accepting a list of integers which yields a list of characters.
Try it online!
This one's output is also mixed-case (this is allowed).
How?
“...»⁾tky;⁶s2ɓṢĖUœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...» - compression of dictionary entries:
- "end", "GMP", "fyttes", "adj", and "xci" and the string "qz"
- "endGMPfyttesadjxciqz"
y - translate with:
⁾tk - ['t', 'k'] "endGMPfykkesadjxciqz"
;⁶s2ɓṢĖUœị - ...
- ...then like the above method (except U reverses each pair of indices)
" neGMzq"
$endgroup$
Jelly, 31 30 27 26 bytes
“ñẒẎYñ(“Nut¦hß’ṃØA;€⁶ɓṢĖœị
A monadic Link accepting a list of integers which yields a list of characters.
- a mishmash of my previous, below, and my improvement of Nick Kennedy's
Try it online!
The output is not given in the same order as the input (this is allowed).
Using 2 of my own additions to the language in an answer does not happen often! (ṃ
and ɓ
here).
How?
“...“...’ṃØA;€⁶ɓṢĖœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...“...’ - list of base 250 integers [28089224382041, 77611203526272]
ØA - 'ABC...XYZ'
ṃ - base decompress (vectorises) ["EDMFKZZJZQ", "NGPYKZZXZZ"]
;€ - for €ach: concatenate:
⁶ - a space ["EDMFKZZJZQ ", "NGPYKZZXZZ "]
ɓ - start a new dyadic chain with swapped arguments - i.e. f(V,that)
Ṣ - sort [0,1,1,2,3,10,10]
Ė - enumerate [[1,0],[2,1],[3,1],[4,2],[5,3],[6,10],[7,10]]
œị - multi-dimensional index into " NEGMZQ"
(1-based and modular)
previous @ 30
“²rṛʂṂø5=Ɓṇ^N¥Y»⁾tky;⁶s2ɓṢĖUœị
A monadic Link accepting a list of integers which yields a list of characters.
Try it online!
This one's output is also mixed-case (this is allowed).
How?
“...»⁾tky;⁶s2ɓṢĖUœị - Link: list of integers, V e.g. [10,1,0,3,2,1,10]
“...» - compression of dictionary entries:
- "end", "GMP", "fyttes", "adj", and "xci" and the string "qz"
- "endGMPfyttesadjxciqz"
y - translate with:
⁾tk - ['t', 'k'] "endGMPfykkesadjxciqz"
;⁶s2ɓṢĖUœị - ...
- ...then like the above method (except U reverses each pair of indices)
" neGMzq"
edited 5 hours ago
answered yesterday
Jonathan AllanJonathan Allan
54.1k537174
54.1k537174
$begingroup$
I think you made a typo in your first explanation.' NWGMZQ'
after the multi-dimensional index into would be quite a feat without anyW
in the string. ;)
$endgroup$
– Kevin Cruijssen
17 hours ago
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
add a comment |
$begingroup$
I think you made a typo in your first explanation.' NWGMZQ'
after the multi-dimensional index into would be quite a feat without anyW
in the string. ;)
$endgroup$
– Kevin Cruijssen
17 hours ago
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
$begingroup$
I think you made a typo in your first explanation.
' NWGMZQ'
after the multi-dimensional index into would be quite a feat without any W
in the string. ;)$endgroup$
– Kevin Cruijssen
17 hours ago
$begingroup$
I think you made a typo in your first explanation.
' NWGMZQ'
after the multi-dimensional index into would be quite a feat without any W
in the string. ;)$endgroup$
– Kevin Cruijssen
17 hours ago
1
1
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
$begingroup$
@KevinCruijssen - yws, typo fixwd; thanks!
$endgroup$
– Jonathan Allan
16 hours ago
add a comment |
$begingroup$
Pyth - 92 86 83 81 80 75 60 52 49 42 36 bytes
Loops through input, popping off the available letters. I just have one of each letter that together give 7 for that point category. Now using packed string encoding.
K[M*L7c."B_êº çÑOÒ
7âCkÑ"Lm.)@K
K Assign to K
[M Map list(for popping). Uses a quirk of M to splat each first
*L7 Map repeating each string by 7
c L Split on occurrences of 'L'
."..." Packed string encoding of the needed letters
m (Q) Map on input (input is taken implicitly)
.) Pop. This returns the first element after removing it
@K Index into K
(d) The loop variable is given implicitly
Btw, this is the original letter string before encoding: "_ E DG BCMP FHVW K JX QZ"
.
Try it online.
$endgroup$
add a comment |
$begingroup$
Pyth - 92 86 83 81 80 75 60 52 49 42 36 bytes
Loops through input, popping off the available letters. I just have one of each letter that together give 7 for that point category. Now using packed string encoding.
K[M*L7c."B_êº çÑOÒ
7âCkÑ"Lm.)@K
K Assign to K
[M Map list(for popping). Uses a quirk of M to splat each first
*L7 Map repeating each string by 7
c L Split on occurrences of 'L'
."..." Packed string encoding of the needed letters
m (Q) Map on input (input is taken implicitly)
.) Pop. This returns the first element after removing it
@K Index into K
(d) The loop variable is given implicitly
Btw, this is the original letter string before encoding: "_ E DG BCMP FHVW K JX QZ"
.
Try it online.
$endgroup$
add a comment |
$begingroup$
Pyth - 92 86 83 81 80 75 60 52 49 42 36 bytes
Loops through input, popping off the available letters. I just have one of each letter that together give 7 for that point category. Now using packed string encoding.
K[M*L7c."B_êº çÑOÒ
7âCkÑ"Lm.)@K
K Assign to K
[M Map list(for popping). Uses a quirk of M to splat each first
*L7 Map repeating each string by 7
c L Split on occurrences of 'L'
."..." Packed string encoding of the needed letters
m (Q) Map on input (input is taken implicitly)
.) Pop. This returns the first element after removing it
@K Index into K
(d) The loop variable is given implicitly
Btw, this is the original letter string before encoding: "_ E DG BCMP FHVW K JX QZ"
.
Try it online.
$endgroup$
Pyth - 92 86 83 81 80 75 60 52 49 42 36 bytes
Loops through input, popping off the available letters. I just have one of each letter that together give 7 for that point category. Now using packed string encoding.
K[M*L7c."B_êº çÑOÒ
7âCkÑ"Lm.)@K
K Assign to K
[M Map list(for popping). Uses a quirk of M to splat each first
*L7 Map repeating each string by 7
c L Split on occurrences of 'L'
."..." Packed string encoding of the needed letters
m (Q) Map on input (input is taken implicitly)
.) Pop. This returns the first element after removing it
@K Index into K
(d) The loop variable is given implicitly
Btw, this is the original letter string before encoding: "_ E DG BCMP FHVW K JX QZ"
.
Try it online.
edited yesterday
answered yesterday
MaltysenMaltysen
21.3k445116
21.3k445116
add a comment |
add a comment |
$begingroup$
Perl 5, 71 bytes
@a=(__,'E'x7,DDDDGGG,BBCCMMP,FFHHVVW,K,1,1,JX,1,QZ);say chop$a[$_]for<>
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 5, 71 bytes
@a=(__,'E'x7,DDDDGGG,BBCCMMP,FFHHVVW,K,1,1,JX,1,QZ);say chop$a[$_]for<>
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 5, 71 bytes
@a=(__,'E'x7,DDDDGGG,BBCCMMP,FFHHVVW,K,1,1,JX,1,QZ);say chop$a[$_]for<>
Try it online!
$endgroup$
Perl 5, 71 bytes
@a=(__,'E'x7,DDDDGGG,BBCCMMP,FFHHVVW,K,1,1,JX,1,QZ);say chop$a[$_]for<>
Try it online!
answered yesterday
XcaliXcali
5,505520
5,505520
add a comment |
add a comment |
$begingroup$
05AB1E, 70 52 39 38 29 26 25 bytes
{ε.•3Oû}α›ηö‡.ÝŽ{•2ôÁyèNè?
-18 bytes thanks to @ExpiredData.
-13 bytes by using the same extend to size 7 from @Maltysen's Pyth answer.
-9 bytes by creating a port of @JonathanAllan's Jelly answer, so make sure to upvote him!
-3 bytes thanks to @Emigna.
Results in a list of characters, and uses lowercase letters and a space for blanks.
Try it online or verify some more test cases.
Explanation:
{ # Sort the (implicit) input-list
ε # Map each character `y` in this list to:
.•3Oû}α›ηö‡.ÝŽ{• # Push compressed string "endgmpfykkzzzzjxzzqz "
2ô # Split into parts of size 2
Á # Rotate it once towards the left so the space is leading
yè # Use integer `y` to index into the string-pairs
Nè # Then get the `N`'th character of the string-pair (with automatic
# wraparound), where `N` is the index of the loop
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•3Oû}α›ηö‡.ÝŽ{•
is "endgmpfykkzzzzjxzzqz "
.
Previous 38 bytes answer:
.•Mñ&Àû«ì{₆v*Å+µ-•#ðšε7∍}IvDyèн©?ε®õ.;
Try it online or verify some more test cases.
Explanation:
.•Mñ&Àû«ì{₆v*Å+µ-• # Push compressed string "e dg bcmp fhvw k jx qz"
# # Split on spaces: ["e","dg","bcmp","fhvw","k","","","jx","","qz"]
ðš # Prepend a space to this list
ε7∍} # Extend each string to size 7:
# [" ","eeeeeee","dgdgdgd","bcmpbcm","fhvwfhv","kkkkkkk","","","jxjxjxj","","qzqzqzq"]
Iv # Loop `y` over the input-list:
Dyè # Get the `y`'th string from a copy of the list
н # Get it's first character
©? # Store it in the register, and print it without trailing newline
ε # Then map each string in the list to:
®õ.; # Remove the first occurrence of the character from the register
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•Mñ&Àû«ì{₆v*Å+µ-•
is "e dg bcmp fhvw k jx qz"
.
$endgroup$
$begingroup$
Can't you use" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?
$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
$begingroup$
You can save 3 bytes using{v
instead of7F
andy
instead ofI{Nè
.
$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
add a comment |
$begingroup$
05AB1E, 70 52 39 38 29 26 25 bytes
{ε.•3Oû}α›ηö‡.ÝŽ{•2ôÁyèNè?
-18 bytes thanks to @ExpiredData.
-13 bytes by using the same extend to size 7 from @Maltysen's Pyth answer.
-9 bytes by creating a port of @JonathanAllan's Jelly answer, so make sure to upvote him!
-3 bytes thanks to @Emigna.
Results in a list of characters, and uses lowercase letters and a space for blanks.
Try it online or verify some more test cases.
Explanation:
{ # Sort the (implicit) input-list
ε # Map each character `y` in this list to:
.•3Oû}α›ηö‡.ÝŽ{• # Push compressed string "endgmpfykkzzzzjxzzqz "
2ô # Split into parts of size 2
Á # Rotate it once towards the left so the space is leading
yè # Use integer `y` to index into the string-pairs
Nè # Then get the `N`'th character of the string-pair (with automatic
# wraparound), where `N` is the index of the loop
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•3Oû}α›ηö‡.ÝŽ{•
is "endgmpfykkzzzzjxzzqz "
.
Previous 38 bytes answer:
.•Mñ&Àû«ì{₆v*Å+µ-•#ðšε7∍}IvDyèн©?ε®õ.;
Try it online or verify some more test cases.
Explanation:
.•Mñ&Àû«ì{₆v*Å+µ-• # Push compressed string "e dg bcmp fhvw k jx qz"
# # Split on spaces: ["e","dg","bcmp","fhvw","k","","","jx","","qz"]
ðš # Prepend a space to this list
ε7∍} # Extend each string to size 7:
# [" ","eeeeeee","dgdgdgd","bcmpbcm","fhvwfhv","kkkkkkk","","","jxjxjxj","","qzqzqzq"]
Iv # Loop `y` over the input-list:
Dyè # Get the `y`'th string from a copy of the list
н # Get it's first character
©? # Store it in the register, and print it without trailing newline
ε # Then map each string in the list to:
®õ.; # Remove the first occurrence of the character from the register
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•Mñ&Àû«ì{₆v*Å+µ-•
is "e dg bcmp fhvw k jx qz"
.
$endgroup$
$begingroup$
Can't you use" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?
$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
$begingroup$
You can save 3 bytes using{v
instead of7F
andy
instead ofI{Nè
.
$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
add a comment |
$begingroup$
05AB1E, 70 52 39 38 29 26 25 bytes
{ε.•3Oû}α›ηö‡.ÝŽ{•2ôÁyèNè?
-18 bytes thanks to @ExpiredData.
-13 bytes by using the same extend to size 7 from @Maltysen's Pyth answer.
-9 bytes by creating a port of @JonathanAllan's Jelly answer, so make sure to upvote him!
-3 bytes thanks to @Emigna.
Results in a list of characters, and uses lowercase letters and a space for blanks.
Try it online or verify some more test cases.
Explanation:
{ # Sort the (implicit) input-list
ε # Map each character `y` in this list to:
.•3Oû}α›ηö‡.ÝŽ{• # Push compressed string "endgmpfykkzzzzjxzzqz "
2ô # Split into parts of size 2
Á # Rotate it once towards the left so the space is leading
yè # Use integer `y` to index into the string-pairs
Nè # Then get the `N`'th character of the string-pair (with automatic
# wraparound), where `N` is the index of the loop
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•3Oû}α›ηö‡.ÝŽ{•
is "endgmpfykkzzzzjxzzqz "
.
Previous 38 bytes answer:
.•Mñ&Àû«ì{₆v*Å+µ-•#ðšε7∍}IvDyèн©?ε®õ.;
Try it online or verify some more test cases.
Explanation:
.•Mñ&Àû«ì{₆v*Å+µ-• # Push compressed string "e dg bcmp fhvw k jx qz"
# # Split on spaces: ["e","dg","bcmp","fhvw","k","","","jx","","qz"]
ðš # Prepend a space to this list
ε7∍} # Extend each string to size 7:
# [" ","eeeeeee","dgdgdgd","bcmpbcm","fhvwfhv","kkkkkkk","","","jxjxjxj","","qzqzqzq"]
Iv # Loop `y` over the input-list:
Dyè # Get the `y`'th string from a copy of the list
н # Get it's first character
©? # Store it in the register, and print it without trailing newline
ε # Then map each string in the list to:
®õ.; # Remove the first occurrence of the character from the register
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•Mñ&Àû«ì{₆v*Å+µ-•
is "e dg bcmp fhvw k jx qz"
.
$endgroup$
05AB1E, 70 52 39 38 29 26 25 bytes
{ε.•3Oû}α›ηö‡.ÝŽ{•2ôÁyèNè?
-18 bytes thanks to @ExpiredData.
-13 bytes by using the same extend to size 7 from @Maltysen's Pyth answer.
-9 bytes by creating a port of @JonathanAllan's Jelly answer, so make sure to upvote him!
-3 bytes thanks to @Emigna.
Results in a list of characters, and uses lowercase letters and a space for blanks.
Try it online or verify some more test cases.
Explanation:
{ # Sort the (implicit) input-list
ε # Map each character `y` in this list to:
.•3Oû}α›ηö‡.ÝŽ{• # Push compressed string "endgmpfykkzzzzjxzzqz "
2ô # Split into parts of size 2
Á # Rotate it once towards the left so the space is leading
yè # Use integer `y` to index into the string-pairs
Nè # Then get the `N`'th character of the string-pair (with automatic
# wraparound), where `N` is the index of the loop
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•3Oû}α›ηö‡.ÝŽ{•
is "endgmpfykkzzzzjxzzqz "
.
Previous 38 bytes answer:
.•Mñ&Àû«ì{₆v*Å+µ-•#ðšε7∍}IvDyèн©?ε®õ.;
Try it online or verify some more test cases.
Explanation:
.•Mñ&Àû«ì{₆v*Å+µ-• # Push compressed string "e dg bcmp fhvw k jx qz"
# # Split on spaces: ["e","dg","bcmp","fhvw","k","","","jx","","qz"]
ðš # Prepend a space to this list
ε7∍} # Extend each string to size 7:
# [" ","eeeeeee","dgdgdgd","bcmpbcm","fhvwfhv","kkkkkkk","","","jxjxjxj","","qzqzqzq"]
Iv # Loop `y` over the input-list:
Dyè # Get the `y`'th string from a copy of the list
н # Get it's first character
©? # Store it in the register, and print it without trailing newline
ε # Then map each string in the list to:
®õ.; # Remove the first occurrence of the character from the register
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•Mñ&Àû«ì{₆v*Å+µ-•
is "e dg bcmp fhvw k jx qz"
.
edited 13 hours ago
answered yesterday
Kevin CruijssenKevin Cruijssen
42.7k571217
42.7k571217
$begingroup$
Can't you use" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?
$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
$begingroup$
You can save 3 bytes using{v
instead of7F
andy
instead ofI{Nè
.
$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
add a comment |
$begingroup$
Can't you use" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?
$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
$begingroup$
You can save 3 bytes using{v
instead of7F
andy
instead ofI{Nè
.
$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
$begingroup$
Can't you use
" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?$endgroup$
– Expired Data
yesterday
$begingroup$
Can't you use
" 0eeeeeee0ddddggg0bbccmmp0ffhhvvw0k000jx00qz"
?$endgroup$
– Expired Data
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
$begingroup$
@ExpiredData Ah, of course. You only draw 7 letter.. Thanks! Will change it.
$endgroup$
– Kevin Cruijssen
yesterday
1
1
$begingroup$
You can save 3 bytes using
{v
instead of 7F
and y
instead of I{Nè
.$endgroup$
– Emigna
16 hours ago
$begingroup$
You can save 3 bytes using
{v
instead of 7F
and y
instead of I{Nè
.$endgroup$
– Emigna
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
$begingroup$
@Emigna Ah, of course.. Thanks!
$endgroup$
– Kevin Cruijssen
16 hours ago
add a comment |
$begingroup$
C (gcc), 110 bytes
_={0,7,14,21,0,0,22,0,24};f(char*s){for(;*s+1;s++)*s=*s?*s-1?"DDDDGGGBBCCMMPFFHHVVWKJXQZ"[_[*s-2]++]:69:32;}
Try it online!
Uses the _
array as an index into the static string "DDDDGGGBBCCMMPFFHHVVWKJXQZ"
dynamically with exceptions for 0 and 1.
Argument is a -1
-terminated array of scores which is transformed in-place into a -1
-terminated string.
$endgroup$
add a comment |
$begingroup$
C (gcc), 110 bytes
_={0,7,14,21,0,0,22,0,24};f(char*s){for(;*s+1;s++)*s=*s?*s-1?"DDDDGGGBBCCMMPFFHHVVWKJXQZ"[_[*s-2]++]:69:32;}
Try it online!
Uses the _
array as an index into the static string "DDDDGGGBBCCMMPFFHHVVWKJXQZ"
dynamically with exceptions for 0 and 1.
Argument is a -1
-terminated array of scores which is transformed in-place into a -1
-terminated string.
$endgroup$
add a comment |
$begingroup$
C (gcc), 110 bytes
_={0,7,14,21,0,0,22,0,24};f(char*s){for(;*s+1;s++)*s=*s?*s-1?"DDDDGGGBBCCMMPFFHHVVWKJXQZ"[_[*s-2]++]:69:32;}
Try it online!
Uses the _
array as an index into the static string "DDDDGGGBBCCMMPFFHHVVWKJXQZ"
dynamically with exceptions for 0 and 1.
Argument is a -1
-terminated array of scores which is transformed in-place into a -1
-terminated string.
$endgroup$
C (gcc), 110 bytes
_={0,7,14,21,0,0,22,0,24};f(char*s){for(;*s+1;s++)*s=*s?*s-1?"DDDDGGGBBCCMMPFFHHVVWKJXQZ"[_[*s-2]++]:69:32;}
Try it online!
Uses the _
array as an index into the static string "DDDDGGGBBCCMMPFFHHVVWKJXQZ"
dynamically with exceptions for 0 and 1.
Argument is a -1
-terminated array of scores which is transformed in-place into a -1
-terminated string.
answered yesterday
LambdaBetaLambdaBeta
2,239418
2,239418
add a comment |
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 104 90 bytes
a=>a.OrderBy(x=>x).Select((x,i)=>(x="_ E DG BCMP FHVW K JX QZ".Split()[x])[i%x.Length])
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 104 90 bytes
a=>a.OrderBy(x=>x).Select((x,i)=>(x="_ E DG BCMP FHVW K JX QZ".Split()[x])[i%x.Length])
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 104 90 bytes
a=>a.OrderBy(x=>x).Select((x,i)=>(x="_ E DG BCMP FHVW K JX QZ".Split()[x])[i%x.Length])
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 104 90 bytes
a=>a.OrderBy(x=>x).Select((x,i)=>(x="_ E DG BCMP FHVW K JX QZ".Split()[x])[i%x.Length])
Try it online!
edited yesterday
answered yesterday
Expired DataExpired Data
792216
792216
add a comment |
add a comment |
$begingroup$
Jelly, 34 32 bytes
“¿RÇĊƈ⁸⁾%ỵṆþœsṀṂ’ṃØAṣ”A;⁶ẋ€7⁸ịḢ€
Try it online!
I hadn’t seen there was a shorter Jelly answer when I wrote this, and this uses a different approach so I thought was worth posting as well.
Thanks to @JonathanAllan for saving 2 bytes!
$endgroup$
$begingroup$
By using base-decompression,ṃ
, you can save 2 bytes
$endgroup$
– Jonathan Allan
yesterday
add a comment |
$begingroup$
Jelly, 34 32 bytes
“¿RÇĊƈ⁸⁾%ỵṆþœsṀṂ’ṃØAṣ”A;⁶ẋ€7⁸ịḢ€
Try it online!
I hadn’t seen there was a shorter Jelly answer when I wrote this, and this uses a different approach so I thought was worth posting as well.
Thanks to @JonathanAllan for saving 2 bytes!
$endgroup$
$begingroup$
By using base-decompression,ṃ
, you can save 2 bytes
$endgroup$
– Jonathan Allan
yesterday
add a comment |
$begingroup$
Jelly, 34 32 bytes
“¿RÇĊƈ⁸⁾%ỵṆþœsṀṂ’ṃØAṣ”A;⁶ẋ€7⁸ịḢ€
Try it online!
I hadn’t seen there was a shorter Jelly answer when I wrote this, and this uses a different approach so I thought was worth posting as well.
Thanks to @JonathanAllan for saving 2 bytes!
$endgroup$
Jelly, 34 32 bytes
“¿RÇĊƈ⁸⁾%ỵṆþœsṀṂ’ṃØAṣ”A;⁶ẋ€7⁸ịḢ€
Try it online!
I hadn’t seen there was a shorter Jelly answer when I wrote this, and this uses a different approach so I thought was worth posting as well.
Thanks to @JonathanAllan for saving 2 bytes!
edited yesterday
answered yesterday
Nick KennedyNick Kennedy
1,51649
1,51649
$begingroup$
By using base-decompression,ṃ
, you can save 2 bytes
$endgroup$
– Jonathan Allan
yesterday
add a comment |
$begingroup$
By using base-decompression,ṃ
, you can save 2 bytes
$endgroup$
– Jonathan Allan
yesterday
$begingroup$
By using base-decompression,
ṃ
, you can save 2 bytes$endgroup$
– Jonathan Allan
yesterday
$begingroup$
By using base-decompression,
ṃ
, you can save 2 bytes$endgroup$
– Jonathan Allan
yesterday
add a comment |
$begingroup$
Python 3, 178 142 135 127 112 117 bytes
def f(l):
d=list(map(list," _EEEEEEE_DDDDGGG_BBCCMMP_FFHHVVW_K___JX__QZ".split('_')))
return[d[i].pop()for i in l]
Try it online!
-1 byte thanks to cdlane
correct thanks to mathmandan
$endgroup$
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte
$endgroup$
– cdlane
yesterday
$begingroup$
This functionf
probably doesn't need to be named, so you can save 2 bytes. However,f
consumes the entries ofd
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, runningf([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885
$endgroup$
– mathmandan
yesterday
add a comment |
$begingroup$
Python 3, 178 142 135 127 112 117 bytes
def f(l):
d=list(map(list," _EEEEEEE_DDDDGGG_BBCCMMP_FFHHVVW_K___JX__QZ".split('_')))
return[d[i].pop()for i in l]
Try it online!
-1 byte thanks to cdlane
correct thanks to mathmandan
$endgroup$
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte
$endgroup$
– cdlane
yesterday
$begingroup$
This functionf
probably doesn't need to be named, so you can save 2 bytes. However,f
consumes the entries ofd
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, runningf([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885
$endgroup$
– mathmandan
yesterday
add a comment |
$begingroup$
Python 3, 178 142 135 127 112 117 bytes
def f(l):
d=list(map(list," _EEEEEEE_DDDDGGG_BBCCMMP_FFHHVVW_K___JX__QZ".split('_')))
return[d[i].pop()for i in l]
Try it online!
-1 byte thanks to cdlane
correct thanks to mathmandan
$endgroup$
Python 3, 178 142 135 127 112 117 bytes
def f(l):
d=list(map(list," _EEEEEEE_DDDDGGG_BBCCMMP_FFHHVVW_K___JX__QZ".split('_')))
return[d[i].pop()for i in l]
Try it online!
-1 byte thanks to cdlane
correct thanks to mathmandan
edited yesterday
answered yesterday
Noodle9Noodle9
30137
30137
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte
$endgroup$
– cdlane
yesterday
$begingroup$
This functionf
probably doesn't need to be named, so you can save 2 bytes. However,f
consumes the entries ofd
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, runningf([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885
$endgroup$
– mathmandan
yesterday
add a comment |
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte
$endgroup$
– cdlane
yesterday
$begingroup$
This functionf
probably doesn't need to be named, so you can save 2 bytes. However,f
consumes the entries ofd
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, runningf([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885
$endgroup$
– mathmandan
yesterday
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
in " -> in" for 111
$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte$endgroup$
– cdlane
yesterday
$begingroup$
d=list(map(list,"...".split('_')))
to save another byte$endgroup$
– cdlane
yesterday
$begingroup$
This function
f
probably doesn't need to be named, so you can save 2 bytes. However, f
consumes the entries of d
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, running f([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885$endgroup$
– mathmandan
yesterday
$begingroup$
This function
f
probably doesn't need to be named, so you can save 2 bytes. However, f
consumes the entries of d
, so I'm not sure that it fits the consensus requirement that "the function has to be reusable arbitrarily often, without...restating...any other code accompanying the submission." (For example, running f([10,0,10,5,8,8,0])
more than once would result in an error.) Please see meta discussion here: codegolf.meta.stackexchange.com/a/7615/36885$endgroup$
– mathmandan
yesterday
add a comment |
$begingroup$
Python 2, 102 bytes (or maybe 95?)
(Also fine for Python 3.)
lambda a:''.join([r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a))
Try it online!
I don't think the following would be acceptable:
lambda a:[[r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a)]
This second version would give output like ['__', 'JX', 'QZ', 'K']
. So the letters would be correct, but they would be collected by point value. (If this were acceptable, it would save 7 bytes.)
$endgroup$
add a comment |
$begingroup$
Python 2, 102 bytes (or maybe 95?)
(Also fine for Python 3.)
lambda a:''.join([r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a))
Try it online!
I don't think the following would be acceptable:
lambda a:[[r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a)]
This second version would give output like ['__', 'JX', 'QZ', 'K']
. So the letters would be correct, but they would be collected by point value. (If this were acceptable, it would save 7 bytes.)
$endgroup$
add a comment |
$begingroup$
Python 2, 102 bytes (or maybe 95?)
(Also fine for Python 3.)
lambda a:''.join([r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a))
Try it online!
I don't think the following would be acceptable:
lambda a:[[r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a)]
This second version would give output like ['__', 'JX', 'QZ', 'K']
. So the letters would be correct, but they would be collected by point value. (If this were acceptable, it would save 7 bytes.)
$endgroup$
Python 2, 102 bytes (or maybe 95?)
(Also fine for Python 3.)
lambda a:''.join([r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a))
Try it online!
I don't think the following would be acceptable:
lambda a:[[r*7for r in'_ E DG BCMP FHVW K * * JX * QZ'.split()][x][:a.count(x)]for x in set(a)]
This second version would give output like ['__', 'JX', 'QZ', 'K']
. So the letters would be correct, but they would be collected by point value. (If this were acceptable, it would save 7 bytes.)
answered 11 hours ago
mathmandanmathmandan
92367
92367
add a comment |
add a comment |
$begingroup$
PHP, 101 bytes
$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($argv as$t){echo$c=($d=$b[$t])[0];$b[$t]=substr($d,1).$c;}
As a standalone program, input via command line:
$ php s.php 10 0 10 5 8 8 0
"Q_ZKJX_"
Try it online!
Or 112 bytes as a function
function($a){$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($a as$t)$b[$t]=substr($d=$b[$t],1).$c=$d[0];return$c;}
Try it online!
Output
[10,0,10,5,8,8,0] "Q_ZKJX_"
[1,1,1,1,1,1,1] "EEEEEEE"
[1,2,3,4,5,8,0] "EDBFKJ_"
[2,2,2,2,2,2,2] "DGDGDGD"
$endgroup$
add a comment |
$begingroup$
PHP, 101 bytes
$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($argv as$t){echo$c=($d=$b[$t])[0];$b[$t]=substr($d,1).$c;}
As a standalone program, input via command line:
$ php s.php 10 0 10 5 8 8 0
"Q_ZKJX_"
Try it online!
Or 112 bytes as a function
function($a){$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($a as$t)$b[$t]=substr($d=$b[$t],1).$c=$d[0];return$c;}
Try it online!
Output
[10,0,10,5,8,8,0] "Q_ZKJX_"
[1,1,1,1,1,1,1] "EEEEEEE"
[1,2,3,4,5,8,0] "EDBFKJ_"
[2,2,2,2,2,2,2] "DGDGDGD"
$endgroup$
add a comment |
$begingroup$
PHP, 101 bytes
$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($argv as$t){echo$c=($d=$b[$t])[0];$b[$t]=substr($d,1).$c;}
As a standalone program, input via command line:
$ php s.php 10 0 10 5 8 8 0
"Q_ZKJX_"
Try it online!
Or 112 bytes as a function
function($a){$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($a as$t)$b[$t]=substr($d=$b[$t],1).$c=$d[0];return$c;}
Try it online!
Output
[10,0,10,5,8,8,0] "Q_ZKJX_"
[1,1,1,1,1,1,1] "EEEEEEE"
[1,2,3,4,5,8,0] "EDBFKJ_"
[2,2,2,2,2,2,2] "DGDGDGD"
$endgroup$
PHP, 101 bytes
$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($argv as$t){echo$c=($d=$b[$t])[0];$b[$t]=substr($d,1).$c;}
As a standalone program, input via command line:
$ php s.php 10 0 10 5 8 8 0
"Q_ZKJX_"
Try it online!
Or 112 bytes as a function
function($a){$b=[_,E,DG,BCMP,FHVW,K,8=>JX,0,QZ];foreach($a as$t)$b[$t]=substr($d=$b[$t],1).$c=$d[0];return$c;}
Try it online!
Output
[10,0,10,5,8,8,0] "Q_ZKJX_"
[1,1,1,1,1,1,1] "EEEEEEE"
[1,2,3,4,5,8,0] "EDBFKJ_"
[2,2,2,2,2,2,2] "DGDGDGD"
edited 10 hours ago
answered yesterday
gwaughgwaugh
2,0931518
2,0931518
add a comment |
add a comment |
$begingroup$
Ruby, 77 76 bytes
->a{r=%w{_ E DG BCMP FHVW K . . JX . QZ};a.map{|i|(r[i]<<r[i][0]).slice! 0}}
Try it online!
$endgroup$
add a comment |
$begingroup$
Ruby, 77 76 bytes
->a{r=%w{_ E DG BCMP FHVW K . . JX . QZ};a.map{|i|(r[i]<<r[i][0]).slice! 0}}
Try it online!
$endgroup$
add a comment |
$begingroup$
Ruby, 77 76 bytes
->a{r=%w{_ E DG BCMP FHVW K . . JX . QZ};a.map{|i|(r[i]<<r[i][0]).slice! 0}}
Try it online!
$endgroup$
Ruby, 77 76 bytes
->a{r=%w{_ E DG BCMP FHVW K . . JX . QZ};a.map{|i|(r[i]<<r[i][0]).slice! 0}}
Try it online!
edited 9 hours ago
answered 9 hours ago
iamnotmaynardiamnotmaynard
93349
93349
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182954%2fworn-tile-scrabble%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Do I need to output a string or is a list ok?
$endgroup$
– Maltysen
yesterday
$begingroup$
You can output a list, I'll update the question
$endgroup$
– Expired Data
yesterday
1
$begingroup$
What can I output for a blank?
$endgroup$
– Maltysen
yesterday
3
$begingroup$
Suggested 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)$endgroup$
– Arnauld
yesterday
1
$begingroup$
Notifications are @ then the person's name without spaces. I.e. Expired Data would become @ExpiredData.
$endgroup$
– Tau
yesterday