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 ดังนั้นฉันต้องทำทุกอย่าง ด้วยตนเอง ..
ลองออนไลน์หรือตรวจสอบว่ามันเป็นควิน
คำอธิบาย:
ควิน :
ใก้ลควินสำหรับ 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 ดังนั้นฉันต้องทำสิ่งเหล่านี้ด้วยตนเอง ผมเคยใช้แหล่งข้อมูลนี้เป็นข้อมูลอ้างอิงในการทำว่าตนเองแปลง codepoints 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จะอยู่ในช่วงแรกดังนั้น 1 ไบต์ใน UTF-8; อักขระЖอยู่ในช่วงที่สองดังนั้น 2 ไบต์ใน UTF-8 และอักขระ丽อยู่ในช่วงที่สามดังนั้น 3 ไบต์ใน UTF-8
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]