“Ð/ṃƇ¬þṄẊƙ€,⁽ṙƬ®OṪJ"ɦ3×kf3Ṙç%ġu’b26ịØaṣ”z
e€¢¬T;2Ḷ¤
ḲŒtǦK
TryItOnline!或运行所有测试
怎么样?
带有空格分隔单词的压缩字符串将是47
字节,将其拆分为1
字节,则为48
字节。
两个未分隔的压缩字符串,分别为length 2
和3
(在末尾带有“ a”)两个单词,它们分别是40
字节加号,2
用于拆分每个字节并将1
其连接起来,以获得45
字节。
如下所述,一个以250为基数的数字是32
字节,然后3
转换为以26为基数,3
索引为小写字母,然后3
将其分割为未使用的字符'z'
,以获得41
字节。
因此,查找不大写的单词
“Ð/ṃƇ¬þṄẊƙ€,⁽ṙƬ®OṪJ"ɦ3×kf3Ṙç%ġu’
:
用这些词,并用分隔符将它们加入:
s="a an the at by for in of on to up and as but or nor"
接下来标签'a'
为1
,'b'
作为2
与分离器为0
:
alpha = ' abcdefghijklmnopqrstuvwxyz'
x = [alpha.index(v) for v in s]
x
[1,0,1,14,0,20,8,5,0,1,20,0,2,25,0,6,15,18,0,9,14,0,15,6,0,15,14,0,20,15,0,21,16,0,1,14,4,0,1,19,0,2,21,20,0,15,18,0,14,15,18]
将其转换为基数26
(使用的最后一个字母'y'
加上分隔符的数字,用于此的Python代码为:
n=sum(v*26**i for i,v in enumerate(x[::-1]))
将其转换为基数250
(使用数字列表):
b=[]
while n:
n,d = divmod(n,250)
b=[d]+b
b
[16,48,220,145,8,32,202,209,162,13,45,142,244,153,9,80,207,75,35,161,52,18,108,103,52,205,24,38,237,118]
在jelly的代码页中的那些索引处查找字符:
codepage = '''¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭụṿẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż«»‘’“”'''
r=''.join(codepage[i-1] for i in b)
r
'Ð/ṃƇ¬þṄẊƙ€,⁽ṙƬ®OṪJ"ɦ3×kf3Ṙç%ġu'
(注意:由于实际的实现是双射的,因此如果b
有任何0
数字,则需要先移位)
其余的部分:
ḲŒtǦK - Main link: title string
Ḳ - split on spaces
¦ - apply to indexes
Ç - given by calling the last link (1) as a monad (with the split title string)
Œt - title case (first letter of each (only) word to upper case)
K - join on spaces
e€¢¬T;2Ḷ¤ - Link 1, find indexes to capitalise: split title string
e€ - is an element of, for €ach
¢ - the result of calling the last link (2) as a nilad
¬ - logical not
T - get the truthy indexes (indexes of words that are not in the list)
; - concatenate with
¤ - nilad followed by link(s) as a nilad
2Ḷ - range(2) -> [0,1]
(we always want to capitalise the first index, 1, and the last index, 0)
“Ð/ṃƇ¬þṄẊƙ€,⁽ṙƬ®OṪJ"ɦ3×kf3Ṙç%ġu’b26ịØaṣ”z - Link 2, make the word list: no arguments
“Ð/ṃƇ¬þṄẊƙ€,⁽ṙƬ®OṪJ"ɦ3×kf3Ṙç%ġu’ - the base 250 number
b26 - convert to base 26
ị - index into
Øa - lowercase alphabet
ṣ - split on
”z - literal 'z' (the separator 0 indexes into `z`)