単語内の単語内の単語。。。


17

このアルファベットの大文字のピクセル化されたフォントでは、すべての文字は幅5単位、高さ5単位です。

 ███  ████   ███  ████  █████ █████  ████ █   █ █████     █ █   █ █     █   █
█   █ █   █ █   █ █   █ █     █     █     █   █   █       █ █  █  █     ██ ██
█████ ████  █     █   █ ████  ████  █  ██ █████   █       █ ███   █     █ █ █
█   █ █   █ █   █ █   █ █     █     █   █ █   █   █   █   █ █  █  █     █   █
█   █ ████   ███  ████  █████ █      ████ █   █ █████  ███  █   █ █████ █   █

█   █  ███  ████   ███  ████   ████ █████ █   █ █   █ █   █ █   █ █   █ █████
██  █ █   █ █   █ █   █ █   █ █       █   █   █ █   █ █   █  █ █   █ █     █ 
█ █ █ █   █ ████  █   █ ████   ███    █   █   █  █ █  █ █ █   █     █     █  
█  ██ █   █ █     █  ██ █  █      █   █   █   █  █ █  █ █ █  █ █    █    █   
█   █  ███  █      ████ █   █ ████    █    ███    █    █ █  █   █   █   █████

ご覧のように、文字と行の間にも1単位のスペースがあります。したがって、各文字には最大6×6単位のスペースが必要です。

完全なブロック文字)を使用して文字の形状を直接形成する代わりに、同じフォントの他の文字を使用したいとします。これには、テキストのサイズを6倍に増やして、フルブロックで作成された文字を大きなテキストのフルブロック置換として使用できるようにすることが含まれます。

それが意味をなさない場合、うまくいけばこの例はそうなります。これは、ピクセル化フォントを使用したBでできたAです。

      ████  ████  ████       
      █   █ █   █ █   █      
      ████  ████  ████       
      █   █ █   █ █   █      
      ████  ████  ████       
                             
████                    ████ 
█   █                   █   █
████                    ████ 
█   █                   █   █
████                    ████ 
                             
████  ████  ████  ████  ████ 
█   █ █   █ █   █ █   █ █   █
████  ████  ████  ████  ████ 
█   █ █   █ █   █ █   █ █   █
████  ████  ████  ████  ████ 
                             
████                    ████ 
█   █                   █   █
████                    ████ 
█   █                   █   █
████                    ████ 
                             
████                    ████ 
█   █                   █   █
████                    ████ 
█   █                   █   █
████                    ████ 

Bは完全なブロックで構成され、AはBで構成されています。Bは、水平と垂直の間に1つのユニットがまだあることに注意してください。

単なる文字の代わりに単語を使用することで、このアイデアを拡張できます。「FIRE」で作られた「WATER」は次のとおりです。

█████                   █████             ████  █████ █████             █████ ████  █████ █████ █████       ████  █████ █████ █████ ████        █████ █████ █████ ████       
█                         █               █   █ █     █                   █   █   █ █     █       █         █   █ █     █       █   █   █       █     █       █   █   █      
████                      █               ████  ████  ████                █   ████  ████  ████    █         ████  ████  ████    █   ████        ████  ████    █   ████       
█                         █               █  █  █     █                   █   █  █  █     █       █         █  █  █     █       █   █  █        █     █       █   █  █       
█                       █████             █   █ █████ █                 █████ █   █ █████ █     █████       █   █ █████ █     █████ █   █       █████ █     █████ █   █      
                                                                                                                                                                             
█████                   █████       ████                    █████                   █████                   █████                               ████                    █████
█                         █         █   █                   █                       █                         █                                 █   █                   █    
████                      █         ████                    ████                    ████                      █                                 ████                    ████ 
█                         █         █  █                    █                       █                         █                                 █  █                    █    
█                       █████       █   █                   █████                   █                       █████                               █   █                   █████
                                                                                                                                                                             
█████       █████       ████        █████ █████ █████ ████  █████                   █████                   █████ ████  █████ █████             █████ ████  █████ █████      
█             █         █   █       █     █       █   █   █ █                       █                         █   █   █ █     █                   █   █   █ █     █          
████          █         ████        ████  ████    █   ████  ████                    ████                      █   ████  ████  ████                █   ████  ████  ████       
█             █         █  █        █     █       █   █  █  █                       █                         █   █  █  █     █                   █   █  █  █     █          
█           █████       █   █       █████ █     █████ █   █ █████                   █                       █████ █   █ █████ █                 █████ █   █ █████ █          
                                                                                                                                                                             
█████       █████       ████        █████                   █████                   █████                   ████                                █████             █████      
█             █         █   █       █                       █                         █                     █   █                               █                 █          
████          █         ████        ████                    ████                      █                     ████                                ████              ████       
█             █         █  █        █                       █                         █                     █  █                                █                 █          
█           █████       █   █       █████                   █                       █████                   █   █                               █████             █          
                                                                                                                                                                             
      █████       █████             ████                    █████                   █████                   █████ ████  █████ █████ █████       ████                    █████
      █             █               █   █                   █                       █                         █   █   █ █     █       █         █   █                   █    
      ████          █               ████                    ████                    ████                      █   ████  ████  ████    █         ████                    ████ 
      █             █               █  █                    █                       █                         █   █  █  █     █       █         █  █                    █    
      █           █████             █   █                   █████                   █                       █████ █   █ █████ █     █████       █   █                   █████

「FIRE」が各行にどのように繰り返し表示されるかに注意してください。文字間のスペースがどれだけあるかに関係なく、常に順番に表示されます。「水」の文字がどのように形作られているかにより、「火」の右端の3つのインスタンスが早期に切断されました。

この考えは、言葉で作られたこれらの言葉を使用して、言葉で作られた言葉で作られた言葉、または言葉で作られた言葉で作られた言葉でさえ作ることによって、さらに拡張することができます。理論的には制限はありません。

別の例では、この投稿を3万文字の制限を超えますが、この気の利いたスタックスニペットを実行すると、「単語でできた単語でできた単語」の意味を確認できます。パラメータをデフォルトのままにして、「Go!」を押すだけです。「マウス」という単語でできた「CAT」という単語でできた「DOG」という単語が表示されます。

大文字のみを含む単語のスペース区切りリストを入力しますテキストボックスにと、3番目、4番目、...で構成される2番目の単語で構成される最初の単語が生成されます。

警告:4語または3語以上を入力すると、大量のテキストが生成され、時間がかかります。ブラウザ/コンピューター/車がクラッシュする可能性があります。

チャレンジ

この課題の目標は、スタックスニペットが行う文字数を最小限に抑えることです。

スペースで区切られた大文字のみの単語の文字列を取り込んで、上記のピクセル化フォントを使用して、最初の単語「made of」、2番目の「made of」などを出力するプログラムを作成する必要があります。

[プレーンASCII]チェックボックスとスニペットのフォントサイズ機能は、プログラムでサポートする必要はありません。単語のリストから単語で構成された単語への変換をミラーリングすることが主要なポイントであり、唯一の要件です。

詳細

  • 入力は、コマンドラインであるstdinから行う必要があります。または、文字列を受け取る関数を記述することもできます。

  • 入力は常に有効であると見なすことができます。つまり、先頭または末尾にスペースを入れずに、1つのスペースで区切られた大文字で構成される単語のストリングです。

  • 出力は、stdout(または同様の代替)または選択した名前のファイルに移動する必要があります。

  • 出力は完全に空スペース文字全スペース文字、および改行で構成する必要があります。

    • 空/フル空白文字のいずれかスペースとフルブロック(であるべきで()はそれぞれ、又は期間及びX .Xそれぞれ)。
  • 出力には、空白文字のみを含む先頭の列を含めないでください。ただし、行の末尾の空白文字の組み合わせは許可されます。

    • したがって、これは許可されています:

      X...X.XXXXX..
      X...X.X
      X.X.X.XXXX....
      X.X.X.X..
      .X.X..XXXXX..
      
    • しかし、これはそうではありません:

      .X...X.XXXXX..
      .X...X.X
      .X.X.X.XXXX....
      .X.X.X.X..
      ..X.X..XXXXX..
      
  • 空白文字のみを含む先頭または末尾の行はありません。オプションで、単一の末尾改行を使用できます。

以下は、より文字列に適したバージョンのフォントです。

.XXX.
X...X
XXXXX
X...X
X...X

XXXX.
X...X
XXXX.
X...X
XXXX.

.XXX.
X...X
X....
X...X
.XXX.

XXXX.
X...X
X...X
X...X
XXXX.

XXXXX
X....
XXXX.
X....
XXXXX

XXXXX
X....
XXXX.
X....
X....

.XXXX
X....
X..XX
X...X
.XXXX

X...X
X...X
XXXXX
X...X
X...X

XXXXX
..X..
..X..
..X..
XXXXX

....X
....X
....X
X...X
.XXX.

X...X
X..X.
XXX..
X..X.
X...X

X....
X....
X....
X....
XXXXX

X...X
XX.XX
X.X.X
X...X
X...X

X...X
XX..X
X.X.X
X..XX
X...X

.XXX.
X...X
X...X
X...X
.XXX.

XXXX.
X...X
XXXX.
X....
X....

.XXX.
X...X
X...X
X..XX
.XXXX

XXXX.
X...X
XXXX.
X..X.
X...X

.XXXX
X....
.XXX.
....X
XXXX.

XXXXX
..X..
..X..
..X..
..X..

X...X
X...X
X...X
X...X
.XXX.

X...X
X...X
.X.X.
.X.X.
..X..

X...X
X...X
X.X.X
X.X.X
.X.X.

X...X
.X.X.
..X..
.X.X.
X...X

X...X
.X.X.
..X..
..X..
..X..

XXXXX
...X.
..X..
.X...
XXXXX

得点

これはので、バイト単位での最短の提出勝ちです。完全なブロック()のインスタンスは、3ではなく1バイトとしてカウントされるため、使用するサブミッションにXは利点がありません。


5
次のJavaScriptスニペットを実行して(たとえばjavascript:、URLバーに入力して貼り付ける)、ここでASCIIアートをはるかに読みやすくすることができます$('#question pre').css('line-height',1)。結果:i.stack.imgur.com/XmB8C.png
ドアノブ

1
または回答を含めるには$('#question pre, .answer pre').css('line-height',1)
マーティン・エンダー

この冗談を言うには少し遅すぎることは知っていますが、抵抗できませんでした:i.imgur.com/vAZi1Zt.png
algorithmshark

このチャレンジを見逃したのはどうしてですか?!
魔法のタコUr

回答:


8

CJam、171 165 162 161バイト

qS/_0=,0a*a\{{W:I;{'[{RI):I=}?i65-"c¿»ÐòO*4Õ]%ÐÎ<à IX]{-ïèq=ô}s×o)½2~û³'é¨1ÃlØeúN!Ö3~4ÜË|ÕÇäaepý®"255b2b5/5/=}%z1af*}%R,1a*a*}fR2a*"█ 
"f=

私は1バイトとして扱っています。残りの文字はすべてASCIIの範囲内であるため、1バイトとしても扱われます。

使用できます このペーストビンを正確なコードにます

入力の出力例:

FIRST HELLO WORLD

ここに画像の説明を入力してください

使い方

まず第一に

"c¿»ÐòO*4Õ]%ÐÎ<à IX]{-ïèq=ô}s×o)½2~û³'é¨1ÃlØeúN!Ö3~4ÜË|ÕÇäaepý®"255b2b5/5/

(位置)と(位置)でA-Z構成される27文字(およびスペース)のそれぞれの単純なパターンです。デコードした後、これは、5行5列表現の2Dアレイの27素子アレイが得られるとし0X1.X. 27文字のそれぞれについての。この配列をL

残りのコード:

qS/                      "Read the input and split it on space to get array Q";
   _0=                   "Get a copy of the first element of the above array";
      ,0a*               "Create an array filled with 0 with length of the first element";
          a\             "Wrap that array in another array and swap to get Q on top";
{  ...  }fR              "This is a for each loop on the array Q with R having the";
                         "current element value in each loop";
 {...}%                  "In the first iteration, the 0 array we created will be the";
                         "only thing on stack, in subsequent iterations, the result";
                         "of previous iteration will be on stack";
  W:I;                   "Initialize variable I with -1";
      {...}%             "Run this block on each element of the current array";
{'[{RI):I=}?i65-L=}%     "This is the above code block. In each iteration, we figure";
                         "out what character needs to be be put at the current index";
                         "Then we get the pattern of 0 and 1 for that character";
 '[{      }?             "Stack contains either 0 or 1. If it is 1, we want to leave";
                         "that index blank, so we put pattern of '[ which is 5X5 spaces";
    RI_:I=               "When we do not want a blank character, we get the next"
                         "character from R to fill the non empty space";
            i65-         "Convert A-Z  to 0-27 notation";
                L=       "Get the corresponding pattern from the pattern array L";
z1af*                    "After the above iterations, for each line of the previous";
                         "iteration's output, we get a vertical 2D array for next";
                         "iteration. We transpose it and join each character in";
                         "this line using a space";
      R,1a*a*            "After getting all lines from current iteration, we join them";
                         "with one full line of space characters";

 2a*                     "After all iterations, we have the 0 1 based 2D array for the";
                         "final output ASCII with each row representing a line. We join";
                         "these lines with 2, to get a 0 1 2 based array";
     "█                  "A brick, a space and a newline. Mapping 1 to 1 with 0 1 2";
"                        "based array";
 f=                      "For each of the 0 1 2 based array element, convert them to";
                         "one of the brick, space and new line character";

こちらからオンラインでお試しください


9

Python 3、437バイト

from numpy import*
s=input().split()
d=fromstring('NONO__^Q_PQAQQNONO^_QQQQQ_QQQQAAAQDPIA[SQQQQADQQQJJH_OAQOOY_DPGAUUQOQONDQJUDDDQQQQAAQQDQIAQYQAYIPDQJUJDBQONO_A^Q_NQ_QQNA^QODNDJQD_',byte)[:,None]>>arange(5)&1
b=0
x=1
y=len(s[0])
n=[[1]*y]
for w in s:
 g=n;b+=x;x*=6;n=zeros((x,x*y),int);i=-6
 for q in g:
  o=j=0;i+=6
  for p in q:n[i:i+5,j:j+5]|=d[ord(w[o%len(w)])-65::26]*p;o+=p;j+=6
for r in n[:-b]:print(''.join(' █'[x] for x in r))

文字の形状はASCIIでエンコードされます。各ASCIIバイトは1文字の1行に対応し、ビットは単位ブロックを表します。これは非常に効率的なスキームではありませんが、各文字のNumPyビットマスクに簡単に展開できます。

1の2D配列から始めます。最初の単語の各文字に対して1つの列と1つの行があります。次に、各単語に対して、0の新しい配列を作成します。これは、前の配列の6倍、6倍の幅です。前の配列に1があった場合、新しい配列の対応する6x6セクションには適切な文字のビットマスクが入力されます。

次に例を示します(非常に小さなフォントを使用)。

ここに画像の説明を入力してください


5

CJam、181 174 170バイト

これらの非ASCII文字はすべて拡張ASCIIの範囲内にあるため、すべて1バイトでエンコードできます。(を除きますが、その仕様はチャレンジ仕様に従って特別に扱われます。)したがって、各文字をバイトとしてカウントしています。

"Á  :½A%õ­Íú£à˪ë8!Õ*j4¶fVËa¡ùÔ¯{+ÛyéâõKn#@?
9Ôia)(Ñç;~LÒª"257b2bYYb" █"er5/5/:L;lS/_0=,'█*a\{f{W:T;\{' ={S5*a5*}{T):T1$='A-L=}?\}%W<zSf*}Sa*}/N*

Stack Exchangeはおそらく印刷できない文字の一部を破壊しているので、このpastebinからコードをコピーする必要があるかもしれません。

ここでテストしてください。

STDINを介して、スペースで区切られた単語のリストとして入力を受け取ります。最初の単語は最大のスケールです。例えば:

HOLISM REDUCTIONISM

利回り

████                    █████             ████  █   █  ███              █████                               █████  ███  █   █ █████  ████             █   █ ████  █████ ████        █   █                    ███ 
█   █                   █                 █   █ █   █ █   █               █                                   █   █   █ ██  █   █   █                 ██ ██ █   █ █     █   █       █   █                   █   █
████                    ████              █   █ █   █ █                   █                                   █   █   █ █ █ █   █    ███              █ █ █ ████  ████  █   █       █   █                   █    
█  █                    █                 █   █ █   █ █   █               █                                   █   █   █ █  ██   █       █             █   █ █  █  █     █   █       █   █                   █   █
█   █                   █████             ████   ███   ███                █                                 █████  ███  █   █ █████ ████              █   █ █   █ █████ ████         ███                     ███ 

████                    █████       ████                    █   █        ███                                            █████                   █████                                ███  █   █       █████  ████
█   █                   █           █   █                   █   █       █   █                                             █                       █                                 █   █ ██  █         █   █    
████                    ████        █   █                   █   █       █                                                 █                       █                                 █   █ █ █ █         █    ███ 
█  █                    █           █   █                   █   █       █   █                                             █                       █                                 █   █ █  ██         █       █
█   █                   █████       ████                     ███         ███                                              █                     █████                                ███  █   █       █████ ████ 

████  █████ ████  █   █  ███        █████                   █████        ███                                            █   █                         █████  ████ █   █             ████        █████       ████ 
█   █ █     █   █ █   █ █   █         █                       █         █   █                                           ██  █                           █   █     ██ ██             █   █       █           █   █
████  ████  █   █ █   █ █             █                       █         █   █                                           █ █ █                           █    ███  █ █ █             ████        ████        █   █
█  █  █     █   █ █   █ █   █         █                       █         █   █                                           █  ██                           █       █ █   █             █  █        █           █   █
█   █ █████ ████   ███   ███          █                     █████        ███                                            █   █                         █████ ████  █   █             █   █       █████       ████ 

████                    █████       ████                    █   █        ███                                            █████                                           █████        ███                    █   █
█   █                   █           █   █                   █   █       █   █                                             █                                               █         █   █                   ██  █
████                    ████        █   █                   █   █       █                                                 █                                               █         █   █                   █ █ █
█  █                    █           █   █                   █   █       █   █                                             █                                               █         █   █                   █  ██
█   █                   █████       ████                     ███         ███                                              █                                             █████        ███                    █   █

████                    █████             ████  █   █  ███              █████ █████  ███  █   █ █████        ████ █   █ ████  █████ ████        █   █  ███  █████ █████              ███                    █   █
█   █                   █                 █   █ █   █ █   █               █     █   █   █ ██  █   █         █     ██ ██ █   █ █     █   █       █   █ █   █   █     █               █   █                   ██  █
████                    ████              █   █ █   █ █                   █     █   █   █ █ █ █   █          ███  █ █ █ ████  ████  █   █       █   █ █       █     █               █   █                   █ █ █
█  █                    █                 █   █ █   █ █   █               █     █   █   █ █  ██   █             █ █   █ █  █  █     █   █       █   █ █   █   █     █               █   █                   █  ██
█   █                   █████             ████   ███   ███                █   █████  ███  █   █ █████       ████  █   █ █   █ █████ ████         ███   ███    █   █████              ███                    █   █

説明

まず、文字の形状のルックアップテーブルを次の場所に保存しますL

"Á  :½A%õ­Íú£à˪ë8!Õ*j4¶fVËa¡ùÔ¯{+ÛyéâõKn#@?
9Ôia)(Ñç;~LÒª"257b2bYYb" █"er5/5/:L;

最初の文字列は圧縮された数字です。コードポイントを257基の数字として扱い、結果の数値を2進数に変換します。YYb2は基数2なので、を与え[1 0]ます。要素の置換を使用し" █"て、数字をスペースとブロック文字に変換します。最後に、文字列を5文字の行に分割し、再び5行のブロックに分割します。結果はに保存されますLスタックに、スタックから破棄ます。

ここでの一般的な考え方は、最大規模の単語の長さの1行から始めることです。そして、単語ごとに既存のグリッドを通過し、すべてのブロックを次の小さいスケールで対応する文字に展開します(分離のために空の行と列を挿入します)。入力準備は次のとおりです。

lS/_0=,'█*a\
lS/          "Read input, split on spaces.";
   _0=       "Duplicate and get first word.";
      ,'█*   "Get length repeat █ that many times.";
          a  "Wrap in array, to make the grid two-dimensional.";
           \ "Swap with word list.";

最初に残りのプログラムの最も外側の構造を見てみましょう。次のブロック{...}/はすべての単語に対して実行され、各ブロック文字を展開します。

{f{...}Sa*}/N*
{         }/   "Process each word in the input.";
 f{...}        "Map this block onto each line of the grid, passing in the current word as well.";
       Sa*     "Since each original line will be turned into 5 lines, the grid is still grouped
                into blocks of 5 lines. We join them together with empty lines as required.";
            N* "Join all lines together with newlines.";

最後に、1行がどのように展開されるかを見てみましょう。

W:T;\{' ={S5*a5*}{T):T1$='A-L=}?\}%
W:T;                                "Store -1 in T.";
    \                               "Swap word with line.";
     {                           }% "Map this block onto each character.";
      ' =                           "Check if the character is a space.";
         {      }{            }?    "If it is, run the first block, otherwise the second.";
          S5*                       "Create a string of five spaces.";
             a5*                    "Create an array of five such strings.";
                  T):T              "Push T, increment, store in T.";
                      1$=           "Copy the word and access the T'th character, cyclically.";
                         'A-        "Subtract A from the letter.";
                            L=      "Use the result to get the character shape from L.";
                                \   "Swap resulting block with word.";

"At this point each character is replaced with a 5x5 array of new characters.
 So we actually have a 3D array right now. Since we used a map operation, the
 current word will also be at the end of the array, which we need to get rid off.";

W<zSf*
W<     "Discard last array element - the current word.";
  z    "Zip or transpose the top two levels of the array.";
   Sf* "Join each line together with spaces.";

結果はプログラムの最後に自動的に印刷されます。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.