与えられた入力 n
では、可能な限り数バイトでサイズ n
の単語グリッドを生成します。
詳細
提供される数字は常に奇数になります。グリッドの中央の四角は、常に空でなければなりません(空白文字)。グリッドを埋める文字は、英語のスクラブル文字の配布からランダムに選択する必要があります。すなわち、各タイルは、以下の100文字からランダムに、均一な確率で選択されなければならない。
??EEEEEEEEEEEEAAAAAAAAAIIIIIIIIIOOOOOOOONNNNNNRRRRRRTTTTTTLLLLSSSSUUUUDDDDGGGBBCCMMPPFFHHVVWWYYKJXQZ
?
は空白のタイルを示します。
スクラブルボードと同様に、このボードのタイルはボーナスタイルで高い得点が得られます。これらのタイルは、9以上のサイズのボードでのみ表示されます。中央の正方形から外側に広がるパターンで3行ごとに表示する必要がありますが、最も外側の文字には表示しないでください。ボーナス四角は小文字で表記され、?
ではなく!
と指定された空白のタイルが表示されます。
このビジュアルデモまたは参照の実装を参照して、ボーナスタイルを正しく配布する方法の例を参照してください。
例
Input: 5
出力:
VNZNT
IFOSN
UD VD
ZIOO?
KTLED
Input: 9
出力:
UWDESTKPW
ItDBaDEdI
TERMDYSTR
ROANJLEFT
EkCI OOsT
IPAJPGM?Y
MZLORETVI
G!EGgPUeI
MNROYOEER
ルール
This is code-golf
so the shortest code in bytes wins.
- 一貫性があると仮定して、I/Oには合理的な形式を使用できます。
- グリッドは少なくとも999まで扱えるはずです。
- すべての標準の抜け穴は禁止されています。
ベストアンサー
Jelly, 67 65 64 66 64
63 bytes
”?;ØAx“³Ċu~Ṿr¥rṇ⁽ȦƑ’ḃ12¤µŒl⁾?!yW,WKF€
H3ṬṚ¤ṁ‘1¦ṚŒḄ0,0j«þ`ị¢X€€Y
数値を取得して文字のリストを返すモナドリンク、または結果を印刷するフルプログラム。
Try it
online! (I prefer it using G
rather than
Y
since that’s more
square)
どうやって?
”?;ØAx“³Ċu~Ṿr¥rṇ⁽ȦƑ’ḃ12¤µŒl⁾?!yW,WKF€ - Link 1, getLetterSets: no arguments
”? - literal '?'
ØA - yield uppercase alphabet
; - concatenate
¤ - nilad followed by link(s) as a nilad:
“³Ċu~Ṿr¥rṇ⁽ȦƑ’ - base 250 number
ḃ12 - converted to bijective base 12 (frequencies)
x - times (repeat each)
µ - start a new monadic chain, call that uppers
Œl - to lower-case
⁾?! - literal ['?','!']
y - translate (change '?'s to '!'s)
W - wrap (that) in a list
W - wrap (uppers) in a list
, - pair
K - join with a space, ' '
F€ - flatten €ach (both flattens the wrapped lists
- AND makes the lone ' ' into [' '])
H3ṬṚ¤ṁ‘1¦ṚŒḄ0,0j«þ`ị¢X€€Y - Main link: number, n e.g. 13
H - halve 6.5
¤ - nilad followed by link(s) as a nilad:
3 - literal three 3
Ṭ - untruth [0,0,1]
Ṛ - reverse [1,0,0]
ṁ - mould like (implicit range(int(right))) [1,0,0,1,0,0]
¦ - sparse application:
1 - ...to indices: 1
‘ - ...action: increment [2,0,0,1,0,0]
Ṛ - reverse [0,0,1,0,0,2]
ŒḄ - bounce [0,0,1,0,0,2,0,0,1,0,0]
0,0 - literal [0,0] [0,0]
j - join [0,0,0,1,0,0,2,0,0,1,0,0,0]
` - repeat left argument as right argument with:
þ - outer product using: [[0,0,0,0,0,0,0,0,0,0,0,0,0],
« - minimum [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,1,0,0,1,0,0,1,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,1,0,0,2,0,0,1,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,1,0,0,1,0,0,1,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0]]
¢ - call the last link (1) as a nilad (the letter sets)
ị - index into - gets the correct letter sets for each cell
X€€ - random-choice for €ach cell in €ach row
Y - join with newlines
- if running as a full program: implicit print