编写格式化的摩尔斯电码备忘单


24

挑战:

编写一个产生以下输出的程序:

. E   .. I   ... S   .... H
                     ...- V
             ..- U   ..-. F
                     ..--  
      .- A   .-. R   .-.. L
                     .-.-  
             .-- W   .--. P
                     .--- J
- T   -. N   -.. D   -... B
                     -..- X
             -.- K   -.-. C
                     -.-- Y
      -- M   --. G   --.. Z
                     --.- Q
             --- O   ---.  
                     ----  

这是从A到Z的字母的摩尔斯电码格式的表格。每列由三个空格分隔。

有四个缺失的插槽,国际字符集使用这些插槽。您的程序必须在此处写一个空格。

输出必须仅由ASCII空格,点,破折号,大写字母和换行符(LF或CRLF)组成。

您的程序不接受任何输入。

以下是产生所需输出的示例Python程序:

b = "."
out = []
last = 0
ch = "EISHVUF ARL WPJTNDBXKCYMGZQO  "
cx = 0
while b:
    if last >= len(b):
        print("   ".join(out))
        out = ["   ", "    ", "     ", "      "][0:len(b) - 1]
    out.append(b + " " + ch[cx])
    cx += 1
    last = len(b)
    if len(b) < 4:
        b += "."
    elif b[-1] == ".":
        b = b[0:-1] + "-"
    else:
        i = len(b) - 1
        while b[i] == "-":
            i -= 1
            if i < 0:
                break
        if i < 0:
            break
        b = b[0:i] + "-"
print("   ".join(out))

这是,因此最短的答案以字节为单位。


1
每行3个可以前置空格吗?
dzaima '17

1
标准漏洞不允许解决方案进行硬编码。我们允许对多少表进行硬编码?
布鲁纳

@Brunner考虑到该表大约为450个字节,我怀疑硬编码是最佳解决方案
Cyoce

@Cyoce绝对不是这里最短的版本,但Joerg Huelsermann在他精采的php答案中将其缩减为208个字节。
布鲁纳

1
我们可以有尾随空格吗?
阿达姆(Adám)'17年

Answers:


5

果冻,85 字节

ØQj⁶“_ȦeƤbṅỌU@⁼Cq’œ?;⁶$⁺ṁ®L€€¤
4R2ṗ©ị⁾.-;€€⁶ż"¢;€€⁶$⁺W€€j"731Dẋ@⁶¤ZµKFṚ;⁶ẋ³¤ḣ29ṫ3Ṛµ€Y

完整程序打印备忘单。

在线尝试!

怎么样?

注意:我确实认为可能存在一种方法,可以通过形成一个使用网格原子正确设置格式的列表来进行精简G,但是我还不太清楚如何做到这一点。

ØQj⁶“_ȦeƤbṅỌU@⁼Cq’œ?;⁶$⁺ṁ®L€€¤ - Link 1: get "letters" lists: no arguments
ØQ                             - Qwerty yield = ["QWERTYUIOP","ASDFGHJKL","ZXCVBNM"]
  j⁶                           - join with spaces = "QWERTYUIOP ASDFGHJKL ZXCVBNM"
    “_ȦeƤbṅỌU@⁼Cq’             - base 250 number = 23070726812742121430711954614
                  œ?           - lexicographical permutation at index = "ETIANMSURWDKGOHVF L PJBXCYZQ"
                       ⁺       - do this twice:
                      $        -   last two links as a monad
                    ;⁶         -     concatenate a space              = "ETIANMSURWDKGOHVF L PJBXCYZQ  "
                             ¤ - nilad followed by link(s) as a nilad:
                         ®     -   recall from registry (4R2ṗ from the Main link)
                          L€€  -   length for €ach for €ach = [[1,1],[2,2,2,2],[3,3,3,3,3,3,3,3],[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]]
                        ṁ      - mould like = ["ET","IANM","SURWDKGO","HVF L PJBXCYZQ  "]

4R2ṗ©ị⁾.-;€€⁶ż"¢;€€⁶$⁺W€€j"731Dẋ@⁶¤ZµKFṚ;⁶ẋ³¤ḣ29ṫ3Ṛµ€Y - Main link: no arguments
4R                                                     - range(4) = [1,2,3,4]
  2ṗ                                                   - Cartesian power with 2 = [[[1],[2]],[[1,1],[1,2],[2,1],[2,2]],...,[...,[2,2,2,2]]]
    ©                                                  - copy to register and yield
      ⁾.-                                              - literal ['.','-']
     ị                                                 - index into (makes all the codes, in four lists by length like reading the output top-bottom, left-right)
         ;€€⁶                                          - concatenate a space to each code
               ¢                                       - call last link (1) as a nilad (get the letters reordered as required)
             ż"                                        - zip left and right with zip dyad
                     ⁺                                 - do this twice:
                    $                                  -   last two links as a monad:
                ;€€⁶                                   -     concatenate a space to each code, letter pair
                      W€€                              - wrap each code, letter pair in a list
                                  ¤                    - nilad follwed by link(s) as a nilad:
                           731                         -   literal 731
                              D                        -   to decimal list = [7,3,1]
                               ẋ@⁶                     -   repeat a space = ["       ","   "," "]
                         j"                            - zip with dyad join
                                   Z                   - transpose
                                    µ              µ€  - for each:
                                     K                 -   join with spaces
                                      F                -   flatten
                                       Ṛ               -   reverse
                                            ¤          -   nilad followed by link(s) as a nilad:
                                         ⁶ẋ³           -     space repeated 100 times
                                        ;              -   concatenate
                                             ḣ29       -   head to 29 (make all "lines" the same length)
                                                ṫ3     -   tail from 3 (trim off two spaces from each line)
                                                  Ṛ    -   reverse
                                                     Y - join with newlines
                                                       - implicit print

7

蟒3.6,201个 197 193 187字节

for i in range(16):print('   '.join(i%k and' '*(2+j)or f'{i//k:0{j}b}'.replace(*'0.').replace(*'1-')+' '+'ETIANMSURWDKGOHVF L PJBXCYZQ  '[2**j-2+i//k]for j,k in zip((1,2,3,4),(8,4,2,1))))

使用一些格式化,解压缩A000918魔术。


顺便说一句,f'{i//k:0{j}b}'.replace(*'0.').replace(*'1-')长度与''.join('.-'[int(x)]for x in f'{i//k:0{j}b}')
Uriel's

5

视网膜,125字节

^
. EISHVUF_ARL_WPJ¶- TNDBXKCYMGZQO__
+m`^((.*?)([-.]+) )(\w)((\w)+?)(((?<-6>)\w)+)$
$2$3 $4   $3. $5¶$.1$*     $3- $7
T`\_`p

在线尝试!应该是121个字节,但是我懒得在开头和结尾处理空白。说明:

[blank line]
. EISHVUF_ARL_WPJ¶- TNDBXKCYMGZQO__

其代码以.和开头的字母-分别被预加载。(从理论上讲,可以避免预加载,.-但是这样可以节省字节。)使用_s代替空格,因为它们被视为字母,这使得它们在下面更容易匹配。

+m`^((.*?)([-.]+) )(\w)((\w)+?)(((?<-6>)\w)+)$
$2$3 $4   $3. $5¶$.1$*     $3- $7

在这里,我们将每一行分成五部分:

  • 前缀字母(如果有)
  • 当前的摩尔斯电码
  • 当前信
  • 其余字母的前半部分(下一个字符为.
  • 其余字母的后半部分(下一个字符是-

然后将这些片段重新组装为两行:

  • 前缀字母,当前摩尔斯电码,当前字母,带.后缀的摩尔斯电码,剩余字母的前半部分
  • 空格替换前三部分,摩尔斯电码-后缀,其余字母的后半部分

新行采用与现有行相同的格式,只是带有一个额外的摩尔斯前缀和剩余一半的待处理字母。然后重复此操作,直到每一行只有一个字母。

_
  [single space]

_然后将s改回空格。


3

的JavaScript(ES6),154个 147 145字节

f=(n=r='',d=i=k=0)=>(r+=n&&' '.repeat([d++&&3,21,13,6][i-(i=d-k)])+n+' '+'EISHVUF ARL WPJTNDBXKCYMGZQO  '[k++],d<4)?f(n+'.',d)&&f(n+'-',d):r+=`
`

o.innerHTML = f()
<pre id=o>


哎呀 我错过了这个……否则就不用打扰了!做得好:-)
颠簸的

2

PHP,208字节

<?=gzinflate(base64_decode("dZDJEQMhDAT/RNEJaHLwfd+38w/EWrRlu6gVnwZpGhWIGSCxqhCXoFgWhpa3jHtpasYtKOaZZwZ9z/OjCnEOim3imX7et2Y8guKYeR5aF+PqB4/tK8Q0KMbDnnWPeZamZmyCYpJ5Pu/V93y7qxCLoHgnXnf5qZnn/iGo9u1/Gf+XDw=="));

在线尝试!

PHP,229字节

<?=strtr("3E0.3I053S0.53H12 2.54V1254U05-3F12 25-4 1.4A0.-3R0.-.3L12 2.-.4 12.-4W0.63P12 2.64J
4T0-3N0-.3D0-53B12 2-54X12-.4K0-.-3C12 2-.-4Y1-4M063G06.3Z12 26.4Q1264O0-63 12 2-64 ",[$a="   ","
$a$a","$a $a",". ","- ","..","--"]);

在线尝试!


2

Perl 5中,158个 156字节

map{$a=sprintf'%04b',$_;map{$a=~/.{$_}/;print(-$'?' 'x$_:$&=~y/01/.-/r,' ',(' EISHVUF ARL WPJTNDBXKCYMGZQO  '=~/./g)[!-$'&&++$i],$_-4?'   ':"\n")}1..4}0..15

2

PHP,184个183 181字节

for(;$y<16;$y++,print str_pad(ltrim("$r
"),28," ",0))for($r="",$c="03231323"[$y&7];$c++<4;)$r.=strtr(sprintf("   %0${c}b ",$y>>4-$c),10,"-.")."EISHVUF ARL WPJTNDBXKCYMGZQO  "[$i++];

运行-nr在线尝试

分解

for(;$y<16;$y++,                                    # loop through rows
    print str_pad(ltrim("$r\n"),28," ",0)               # 4. pad to 28 chars and print
    )
    for($r="",                                          # 1. result=empty
        $c="03231323"[$y&7];                            # 2. $c=bits in 1st code -1
        $c++<4;)                                        # 3. loop through columns
        $r.=strtr(sprintf("   %0${c}b ",$y>>4-$c),10,"-.")  # append morse code
            ."EISHVUF ARL WPJTNDBXKCYMGZQO  "[$i++];            # append letter

-7字节,前导空格:更换ltrim("$r\n")"$r\n"2831

171(= -10)个字节,后跟空格

for(;$y<16;$y++)for(print str_pad("
",[0,7,14,22][$c="03231323"[$y&7]]);$c++<4;)echo strtr(sprintf("%0${c}b %s   ",$y>>4-$c,"EISHVUF ARL WPJTNDBXKCYMGZQO"[$i++]),10,"-.");

故障 在线尝试

for(;$y<16;$y++)                                    # loop through rows
    for(
        print str_pad("\n",[0,7,14,22][             # 2. print left padding
            $c="03231323"[$y&7]                     # 1. $c=bits in 1st code -1
        ]); 
        $c++<4;)                                        # 3. loop through columns
        echo                                                # print ...
            strtr(sprintf("%0${c}b %s   ",                  # 3. delimiting spaces
            $y>>4-$c,                                       # 1. morse code
            "EISHVUF ARL WPJTNDBXKCYMGZQO"[$i++]            # 2. letter
        ),10,"-.");

1
这次没有换行吗?
克里斯多夫(Christoph)

1
for(;$y<16;$y++,print str_pad(ltrim("$r\n"),28," ",0))for($r="",$c="03231323"[$y&7];$c++<4;)$r.=strtr(sprintf(" %0${c}b ",$y>>4-$c),10,"-.")."EISHVUF ARL WPJTNDBXKCYMGZQO "[$i++];应该保存2个字节。
克里斯多夫(Christoph)

1
看来您丢了太多空格:最后一行----与其余部分不匹配。"EISHVUF ARL WPJTNDBXKCYMGZQO "最后应该有2个空格。
克里斯多夫(Christoph)

2

APL(Dyalog),92字节

⎕IO←0在许多系统上默认为需要。

0 3↓¯1⌽⍕{' ',(161↑⍨16÷≢⍵)⍀'.-'[⍉2⊥⍣¯1⍳≢⍵],' ',⍪⍵}¨'ET' 'IANM' 'SURWDKGO' 'HVF L PJBXCYZQ  '

在线尝试!

{... }¨'... ' 应用以下匿名函数到每个字符串:

⍪⍵ 将参数列

' ', 在每行前面加一个空格

'.-'[], 在使用以下索引为字符串加上前缀之后:

  ≢⍵ 参数的长度

   该索引(0、1、2,...,长度 -1)的索引

  2⊥⍣¯1 anti-base-2(使用所需的位数)

   转置(从每一列中的一种表示到每一行中的一种表示)

()⍀ 扩展为(插入由零表示的空白行):

  ≢⍵ 参数的长度

  16÷ 除以十六

  1↑⍨ (超)从1取走(列出一个1,后跟1- n个零)

  16⍴ 回收该模式,直到有十六个元素

' ', 前置一个空格

 格式(将表格列表合并为一个表格,在表格的两边各加一个空格)

¯1⌽ 向右旋转一步(因此将尾随空间移到前面)

0 3↓ 删除零行和三列(从而删除三个前导空格)


嘿,16÷⍨您的代码中出现的位置‽
Zacharý17年

@ZacharyT肯定不会。很好,先生。
亚当

1

SOGL106个 105 102 字节

¹θΞk“r²{r³³a:IA2─l4;- 0*;+Ζ0.ŗΖ1-ŗø4∫BƧ| ⁵±+⁷b<?⁄@*}+;j;@3*+}±kkk≥x}¹±č┐"7ŗ◄∑f^│N≥Χ±⅜g,ιƨΛ.⌡׀¹*ΛβΧκ‘čŗ

如果允许前置空格,则为102 99字节

¹θΞk“r²{r³³a:IA2─l4;- 0*;+Ζ0.ŗΖ1-ŗø4∫BƧ| ⁵±+⁷b<?⁄@*}+;j;@3*+}±≥x}¹±č┐"7ŗ◄∑f^│N≥Χ±⅜g,ιƨΛ.⌡׀¹*ΛβΧκ‘čŗ

141字节,压缩

Πa≤χ≥∫RωθΩ≡⅛QΨ═Λ9⁶Ul¹&╔²‘č"‼¼⁸Ƨ,9█ω½└╗«ωΤC¡ιΝ/RL⌡⁄1↑οπ∞b∑#⁵ø⁶‘č"⁵ ?∙«Σf⁾ƨ╤P1φ‛╤Β«╚Δ≡ΟNa1\÷╬5ŗķ§⁷D◄tFhžZ@š⁾¡M<╔↓u┌⁽7¡?v¦#DΘø⌡ ⁹x≡ō¦;⁵W-S¬⁴‘' n

只是想看看SOGL仅用压缩效果如何(它不仅具有压缩功能,而且还具有97%的压缩字符串)


1

JavaScript(205字节)

for(A='EISHVUF ARL WPJTNDBXKCYMGZQO     ',q=0,i=15;30>i++;){for(x=i.toString(2).replace(/(.)/g,a=>1>a?'.':'-'),o='',j=4;j--;)o+=(i%2**j?A.slice(-6+j):x.slice(1,5-j)+' '+A.charAt(q++))+'   ';console.log(o)}

for(A='EISHVUF ARL WPJTNDBXKCYMGZQO     ',q=0,i=15;30>i++;){for(x=i.toString(2).replace(/(.)/g,a=>1>a?'.':'-'),o='',j=4;j--;)o+=(i%2**j?A.slice(-6+j):x.slice(1,5-j)+' '+A.charAt(q++))+'   ';console.log(o)}


1

红宝石,144个143 141字节

k=0
16.times{|i|4.times{|j|$><<("%0#{j+1}b 9   "%(i>>3-j)).tr('109',(i+8&-i-8)>>3-j>0?'-.'+'  OQZGMYCKXBDNTJPW LRA FUVHSIE'[k-=1]:" ")}
puts}

不打高尔夫球

k=0                                                     #setup a counter for the letters
16.times{|i|                                            #16 rows    
  4.times{|j|                                           #4 columns
    $><<("%0#{j+1}b 9   "%(i>>3-j)).                    #send to stdout a binary number of j+1 digits, representing i>>3-j, followed by a 9, substituted as follows.
      tr('109',(i+8&-i-8)>>3-j>0?                       #(i&-i) clears all but the least significant 1's bit of i. the 8's ensure a positive result even if i=0.
      '-.'+'  OQZGMYCKXBDNTJPW LRA FUVHSIE'[k-=1]:      #if the expression righshifted appropriately is positive, substitute 1and0 for -and. Substitute 9 for a letter and update counter.
      " ")}                                             #else substiture 1,0 and 9 for spaces.
puts}                                                   #carriage return after each row.

1

Pyth,106个字节

DhNR.n.e+]++.[\.sllN::.Bk\0\.\1\-\ b*]*\ +2sllNt/16lNNjmj*3\ d.t[h"ET"h"IANM"h"SURWDKGO"h"HVF L PJBXCYZQ  

在线测试!

说明

简而言之,我在这里要做的是逐列生成表格,然后在打印之前转置表格。我们注意到,在一列中,字母莫尔斯电码可以表示为二进制字符串(替换.0-通过1)时,从零到列的最后一个字母的指数计算。

该算法依赖于一个函数,下面从中给出一个示例(第二列):

1. Takes "IANM" as input
2. Generates the binary representations of zero up to len("IANM"): ["0", "1", "10", "11"]
3. Replace with dots and hyphens: [".", "-", "-.", "--"]
4. Pad with dots up to floor(log2(len("IANM"))): ["..", ".-", "-.", "--"]
5. Add the corresponding letters: [".. I", ".- A", "-. N", "-- M"]
6. After each element, insert a list of 16 / len("IANM") - 1 (= 3) strings containing only spaces of length floor(log2(len("IANM"))) + 2 (= 4):
    [".. I", ["    ", "    ", "    "], ".- A", ["    ", "    ", "    "], "-. N", ["    ", "    ", "    "], "-- M", ["    ", "    ", "    "]]
7. Flatten that list:
    [".. I", "    ", "    ", "    ", ".- A", "    ", "    ", "    ", "-. N", "    ", "    ", "    ", "-- M", "    ", "    ", "    "]
8. That's it, we have our second column!

代码说明

我将代码切成两半。第一部分是上述功能,第二部分是我如何使用该功能:

DhNR.n.e+]++.[\.sllN::.Bk\0\.\1\-\ b*]*\ +2sllNt/16lNN

DhNR                                                      # Define a function h taking N returning the rest of the code. N will be a string
      .e                                             N    # For each character b in N, let k be its index
                      .Bk                                 # Convert k to binary
                     :   \0\.                             # Replace zeros with dots (0 -> .)
                    :        \1\-                         # Replace ones with hyphens (1 -> -)
            .[\.sllN                                      # Pad to the left with dots up to floor(log2(len(N))) which is the num of bits required to represent len(N) in binary
          ++                     \ b                      # Append a space and b
         ]                                                # Make a list containing only this string. At this point we have something like [". E"] or [".. I"] or ...
        +                           *]*\ +2sllNt/16lN     # (1) Append as many strings of spaces as there are newlines separating each element vertically in the table
    .n                                                    # At this point the for each is ended. Flatten the resulting list and return it

(1):在莫尔斯表中的第一列中,在每行之后包含字母(“ E”和“ T”)的七行。在第二栏中,是三行。然后是第一列(第三列),然后是零列(最后一列)。即16 / n - 1,其中n是在列字母数(这是N在上面的代码中)。那第(1)行的代码是什么 :

*]*\ +2sllNt/16lN

       sllN          # Computes the num of bits required to represent len(N) in binary
     +2              # To that, add two. We now have the length of a element of the current column
  *\                 # Make a string of spaces of that length (note the trailing space)
           t/16lN    # Computes 16 / len(N) - 1
*]                   # Make a list of that length with the string of spaces (something like ["    ", "    ", ...])

好了,现在我们有了一个很好的有用函数h,该函数基本上是根据字符序列生成表的列的。让我们使用它(注意下面的代码中的两个尾随空格):

jmj*3\ d.t[h"ET"h"IANM"h"SURWDKGO"h"HVF L PJBXCYZQ  

           h"ET"                                        # Generate the first column
                h"IANM"                                 # Generate the second column
                       h"SURWDKGO"                      # Generate the third column
                                  h"HVF L PJBXCYZQ      # Generate the last column (note the two trailing spaces)
          [                                             # Make a list out of those columns
        .t                                              # Transpose, because we can print line by line, but not column by column
 mj*3\ d                                                # For each line, join the elements in that line on "   " (that is, concatenate the elements of the lines but insert "   " between each one)
j                                                       # Join all lines on newline

代码仍然可以缩短;也许以后再说。


1

C,199195字节

#define P putchar
m;p(i,v){printf("%*s",i&1|!v?v*(v+11)/2:3,"");for(m=1<<v;m;m/=2)P(45+!(i&m));P(32);P("  ETIANMSURWDKGOHVF L PJBXCYZQ  "[i]);v<3?p(2*i,v+1):P(10);++i&1&&p(i,v);}main(){p(2,0);}

在coliru上直播(使用#include以避免出现警告消息。)

更新:通过移动m函数外部的“声明”来保存四个字符,如@zacharyT所建议

用途似乎是一个标准的策略:保持字母的排列编码的二进制树,所以元素的孩子i2*i2*i+1。我认为这棵树的根是2而不是1,因为我认为算术要短一些。剩下的就是打高尔夫球。

取消高尔夫:

// Golfed version omits the include
#include <stdio.h>
// Golfed version uses the string rather than a variable.
char* tree = "  ETIANMSURWDKGOHVF L PJBXCYZQ  ";
/* i is the index into tree; v is the number of bits to print (-1) */
void p(int i, int v) {
  /* Golfed version omits all types, so the return type is int.
   * Nothing is returned, but on most architectures that still works although
   * it's UB.
   */
  printf("%*s", i&1 || !v ? v*(v+11)/2 : 3, "");
  /* v*(v+11)/2 is v*(v+1)/2 + 3*v, which is the number of spaces before the odd
   * element at level v. For even elements, we just print the three spaces which
   * separate adjacent elements. (If v is zero, we're at the margin so we
   * suppress the three spaces; with v == 0, the indent will be 0, too.
   *
   * Golfed version uses | instead of || since it makes no semantic difference.
   */

  /* Iterate over the useful bits at this level */
  for (int m=1<<v; m; m/=2) {
    /* Ascii '-' is 45 and '.' is 46, so we invert the tested bit to create the
     * correct ascii code.
     */
    putchar('-' + !(i&m));
  }
  /* Output the character */
  putchar(' ');
  putchar(tree[i]);
  /* Either recurse to finish the line or print a newline */
  if (v<3)
    p(2*i,v+1);
  else
    putchar('\n');
  /* For nodes which have a sibling, recurse to print the sibling */
  if (!(i&1))
    p(i+1, v);
}

int main(void) {
  p(2,0);
}

您可以将其int m移到m;该功能之外吗?
扎卡里

这项工作repl.it/Iqma吗?
扎卡里

@ZacharyT:我想它会起作用,但是它的长度要长一个字符(#define中的空心括号),所以似乎没有什么意义。
rici

我用那个版本计算了194个字节,我丢失了什么吗?
扎卡里

1

泡泡糖,133字节

000000: e0 01 be 00   7d 5d 00 17   08 05 23 e4   96 22 00 5d │ à.¾.}]....#ä.".]
000010: e5 e9 94 d3   78 24 16 ec   c1 c4 ad d8   6e 4d 41 e8 │ åé.Óx$.ìÁÄ.ØnMAè
000020: a3 a1 82 e6   f4 88 d9 85   6f ae 6b 93   aa 44 c8 e3 │ £¡.æô.Ù.o®k.ªDÈã
000030: 29 6f df 65   aa 4a f8 06   f5 63 1a 73   a7 e4 4d 19 │ )oßeªJø.õc.s§äM.
000040: 03 2c 87 59   7b df 27 41   4b b6 12 dd   7c e5 78 27 │ .,.Y{ß'AK¶.Ý|åx'
000050: 9c 9f 99 db   f6 8e 42 fd   43 68 48 46   37 da d7 21 │ ...Ûö.BýChHF7Ú×!
000060: a9 ca ea be   f4 57 e0 da   c1 16 97 ef   7a 0c e9 3c │ ©Êê¾ôWàÚÁ..ïz.é<
000070: 8e c2 b6 22   ca e4 e5 53   57 f0 f4 fb   a4 fb c0 a7 │ .¶"ÊäåSWðôû¤ûÀ§
000080: ec cd 6e 00   00                                      │ ìÍn..

压缩为LZMA流。


0

C,291字节

在线尝试

char*i,*t=".aEc..aIc...aSc....aH/u...-aV/m..-aUc..-.aF/u..--/f.-aAc.-.aRc.-..aL/u.-.-/m.--aWc.--.aP/u.---aJ/-aTc-.aNc-..aDc-...aB/u-..-aX/m-.-aKc-.-.aC/u-.--aY/f--aMc--.aGc--..aZ/u--.-aQ/m---aOc---./u----";
s(n){while(n--)putchar(32);}f(){for(i=t;*i;i++)*i<97?putchar(*i-'/'?*i:10):s(*i-96);}

怎么运行的

首先,我用C解析字符串,计算出小于26的空格,因此我a, b, .. z这个小程序将它们编码为小写字母

for(char*i=t; *i; i++)
{
    if(*i == ' ') c++;
    else c = 0;

    if(i[1] != ' ' && c > 0) putchar('a'+c-1);
    else if(*i =='\n') putchar('/');
    else if(*i != ' ') putchar(*i);
}

然后,我为该编码编写了一个解析器,其中/有一行换行,并且小写字母表示t[i] - 'a'空格

int s(int n)
{
    while(n--) putchar(32);
}

f()
{
    for(char*i=t; *i; i++)
        if(*i < 'a')
            if(*i == '/') putchar('\n');
            else putchar(*i);
        else s(*i-'a'+1);
}


0

Bash(带有实用程序),254个字节

tail -n+2 $0|uudecode|bzip2 -d;exit
begin 644 -
M0EIH.3%!6293631+'LX``&UV`%`P(`!``S____`@`(@:2!H#:@!ZFU'H@T](
MJ>H`'J``;4L>\%)R2H9TS-4WY[M(`"`@=((AJ")8HR^QFK?8RQO2B+W47&@`
M!"@$(!%Q,$'X:#+&>BI<RAC5.J53,S(%FFB!%A-*SM9TY&I8RFZJ9<D0H_B[
)DBG"A(&B6/9P
`
end

0

Dyalog APL,159 字节(无竞争)

↑{X←⍵-1⋄Y←2*⍳4⋄R←Y+(Y÷16)×⍵-1⋄3↓∊{C←R[⍵]⋄'   ',(⍵⍴(1+0=1|C)⊃'    '({⍵⊃'.-'}¨1+(4⍴2)⊤X)),' ',((1+0=1|C)⊃' '((C-1|C)⊃' ETIANMSURWDKGOHVF L PJBXCYZQ  '))}¨⍳4}¨⍳16

为什么这种不竞争?
阿达姆(Adám)'17

我认为您可以通过设置⎕IO←0(许多系统上的默认设置)和使用(通勤)来节省很多。
阿达姆(Adám)'17年

0

JavaScript(ES7), 242 240 238个字节

console.log([...'EISH000V00UF000 0ARL000 00WP000JTNDB000X00KC000Y0MGZ000Q00O 000 '].map((a,k)=>(n=>(a!='0'?(2**n+(k>>2)/2**(4-n)).toString(2).slice(-n).replace(/./g,c=>'.-'[c])+' '+a:'      '.slice(-n-2))+(n<4?'   ':'\n'))(k%4+1)).join``)

在线尝试!

–2个字节,感谢Zachary


尝试更改a!='0'a!=0
Cyoce '17

您可以替换.join('').join<insert backtick here><insert backtick here>?(<insert backtick here>被实际反引号替换)
扎卡里

正如Cyoce所说,尝试更改a!='0'a!=0,应该可以。
扎卡里

@ZacharyT 不,不是,但再次感谢。
eush77

对不起,忘了这''件事。
扎卡里
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.