0"D34çýÇbεDg•Xó•18в@ƶà©i7j0ìëR6ôRíć7®-jšTìJ1®<×ì]ð0:J"D34çýÇbεDg•Xó•18в@ƶà©i7j0ìëR6ôRíć7®-jšTìJ1®<×ì]ð0:J
05AB1EにはUTF-8変換が組み込まれていないため、すべてを手動で行う必要があります。
オンラインそれを試してみたり、それはQUINEだことを確認してください。
説明:
QUINE -part:
最短QUINE:05AB1Eため、この一つである0"D34çý"D34çý
(14バイト)によって提供@OliverNi。私の答えは、...
ここに追加することにより、そのクインの修正バージョンを使用します:0"D34çý..."D34çý...
。この羽の簡単な説明:
0 # Push a 0 to the stack (can be any digit)
"D34çý" # Push the string "D34çý" to the stack
D # Duplicate this string
34ç # Push 34 converted to an ASCII character to the stack: '"'
ý # Join everything on the stack (the 0 and both strings) by '"'
# (output the result implicitly)
チャレンジパート:
次に、コードのチャレンジ部分について説明します。冒頭で述べたように、05AB1EにはUTF-8変換が組み込まれていないため、これらを手動で行う必要があります。私はこのソースを、それを行う方法の参照として使用しました:手動でUnicodeコードポイントをUTF-8およびUTF-16に変換します。Unicode文字からUTF-8への変換に関する概要を次に示します。
- Unicode文字をUnicode値に変換します(つまり、に
"dЖ丽"
なります[100,1046,20029]
)
- これらのユニコード値をバイナリに変換します(つまり、に
[100,1046,20029]
なります["1100100","10000010110","100111000111101"]
)
- 文字が次の範囲のどれであるかを確認します。
0x00000000 - 0x0000007F
(0-127): 0xxxxxxx
0x00000080 - 0x000007FF
(128-2047): 110xxxxx 10xxxxxx
0x00000800 - 0x0000FFFF
(2048-65535): 1110xxxx 10xxxxxx 10xxxxxx
0x00010000 - 0x001FFFFF
(65536-2097151): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
5バイトまたは6バイトの範囲もありますが、ここでは省略します。
文字d
は最初の範囲になるため、UTF-8では1バイトです。文字Ж
は2番目の範囲にあるため、UTF-8では2バイトです。文字丽
は3番目の範囲にあるため、UTF-8では3バイトです。
そのx
後ろのパターンのは、これらの文字のバイナリで右から左に埋められます。したがって、d
(1100100
)のパターンはに0xxxxxxx
なり01100100
ます。Ж
(10000010110
)パターンと110xxxxx 10xxxxxx
なります11010000 10010110
。及び丽
(100111000111101
パターン)が1110xxxx 10xxxxxx 10xxxxxx
なる1110x100 10111000 10111101
た後、残りは、x
で置換されています0
:11100100 10111000 10111101
。
だから、私も私のコードで使用したアプローチ。実際の範囲をチェックする代わりに、バイナリの長さを見て、それをx
パターン内の量と比較するだけです。これにより、数バイトが節約されるためです。
Ç # Convert each character in the string to its unicode value
b # Convert each value to binary
ε # Map over these binary strings:
Dg # Duplicate the string, and get its length
•Xó• # Push compressed integer 8657
18в # Converted to Base-18 as list: [1,8,12,17]
@ # Check for each if the length is >= to this value
# (1 if truthy; 0 if falsey)
ƶ # Multiply each by their 1-based index
à # Pop and get its maximum
© # Store it in the register (without popping)
i # If it is exactly 1 (first range):
7j # Add leading spaces to the binary to make it of length 7
0ì # And prepend a "0"
ë # Else (any of the other ranges):
R # Reverse the binary
6ô # Split it into parts of size 6
Rí # Reverse it (and each individual part) back
ć # Pop, and push the remainder and the head separated to the stack
7®- # Calculate 7 minus the value from the register
j # Add leading spaces to the head binary to make it of that length
š # Add it at the start of the remainder-list again
Tì # Prepend "10" before each part
J # Join the list together
1®<× # Repeat "1" the value from the register - 1 amount of times
ì # Prepend that at the front
] # Close both the if-else statement and map
ð0: # Replace all spaces with "0"
J # And join all modified binary strings together
# (which is output implicitly - with trailing newline)
(セクション鉱山のこの05AB1Eの答えを参照してください?大きな整数を圧縮する方法とどのように圧縮整数リストへ?)理由を理解すること•Xó•18в
です[1,8,12,17]
。