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 द्वारा प्रदान की गई । मेरा जवाब में जोड़कर कि Quine का एक संशोधित संस्करण का उपयोग करता है ...यहां: 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 रूपांतरण बिल्डिंग्स नहीं है, इसलिए मुझे इन चीजों को मैन्युअल रूप से करना होगा। मैंने इस स्रोत का उपयोग कैसे करें के संदर्भ के रूप में किया है: यूनिकोड कोडपॉइंट्स को मैन्युअल रूप से यूटीएफ -8 और यूटीएफ -16 में परिवर्तित करना । यहाँ यूटीएफ -8 में यूनिकोड वर्णों के रूपांतरण के बारे में संक्षिप्त सारांश दिया गया है:
- यूनिकोड वर्णों को उनके यूनिकोड मानों में बदलें (अर्थात
"dЖ丽"बन जाता है [100,1046,20029])
- इन यूनिकोड मानों को बाइनरी में परिवर्तित करें (अर्थात
[100,1046,20029]बन जाता है ["1100100","10000010110","100111000111101"])
- निम्न में से किस श्रेणी में वर्ण देखें:
0x00000000 - 0x0000007F (0-127): 0xxxxxxx
0x00000080 - 0x000007FF (128-2047): 110xxxxx 10xxxxxx
0x00000800 - 0x0000FFFF (2,048-65,535): 1110xxxx 10xxxxxx 10xxxxxx
0x00010000 - 0x001FFFFF (65536-2097151): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
5 या 6 बाइट्स के लिए रेंज भी हैं, लेकिन चलो उन्हें अभी के लिए छोड़ दें।
चरित्र dपहली श्रेणी में होगा, इसलिए UTF-8 में 1 बाइट; चरित्र Жदूसरी श्रेणी में है, इसलिए UTF-8 में 2 बाइट्स; और चरित्र 丽तीसरी श्रेणी में है, इसलिए 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]।