젤리 , 100 91 85 바이트
거의 확실하게 골프를 탈 수 있습니다-91 바이트, 무엇?! 8 개월 6 지혜 바이트!
-1. 더 많은 문자열 압축;
-2. 인덱싱이 모듈 식이므로 사후 감소를 48만큼 줄입니다.
-3. 더 나은 암묵적 체인 사용).
@Lynn이 문자열 압축을 실행하는 데 도움이되는 9 바이트
,“£ɱ~»
Ñ
ṖK,“ and”,Ṫ
LĿK
7RBUT€Uị“ØJƓ“¥Ị£“¤/¡»Ç€“¡*g»ṭ
“ṖŒhJ"ỵd¡»ḲðJ4_⁶ẋ⁸,"j€”:ż⁹Oị¢¤Y
TryItOnline 에서 테스트
방법?
,“£ɱ~» - Link 1: pair with the string "Only"
Ñ - Link 2: call next link
ṖK,“ and”,Ṫ - Link 3: insert " and" between the last two elements of x
Ṗ - x[:-1]
K - join with spaces
“ and” - the string " and"
Ṫ - x[-1]
, , - pair
LĿK - Link 4: call appropriate link and add missing spaces
L - length
Ŀ - call link at that index
K - join the result with spaces
7RBUT€Uị“ØJƓ“¥Ị£“¤/¡»Ç€“¡*g»ṭ - Link 5: construct all 8 cases
7R - range of 7: [1,2,3,4,5,6,7]
B - binary (vectorises): [[1],[1,0],[1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
U - reverse (vectorises): [[1],[0,1],[1,1],[0,0,1],[1,0,1],[0,1,1],[1,1,1]]
T€ - indexes of truthy values for each: [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
U - reverse (vectorises): [[1],[2],[2,1],[3],[3, 1],[3,2],[3,2,1]]
“ØJƓ“¥Ị£“¤/¡» - list of strings: ["Execute","Write","Read"]
ị - item at index (vectorises): [["Execute"],["Write"],["Write","Execute"],["Read"],["Read","Execute",["Read","Write"],["Read","Write","Execute"]]
Ç€ - call the previous link for each
“¡*g» - the string "None"
ṭ - tack (Jelly is 1-based so the 8th item will be indexed as 0)
“ṖŒhJ"ỵd¡»ḲðJṚ⁶ẋ⁸,"j€”:ż⁹Oị¢¤Y - Main Link: parse input and make the result. e.g.: "042"
“ṖŒhJ"ỵd¡» - dictionary compression of "User Group Others"
Ḳ - split at spaces -> ["User","Group","Others"]
ð - dyadic chain separation, call that g (input as right)
J - range of length of g -> [1,2,3]
Ṛ - reverse -> [3,2,1]
⁶ - literal space
ẋ - repeat -> [" "," "," "]
⁸ - chain's left argument, g
" - zip with:
, - pair -> [["User"," "],["Group"," "],["Others"," "]]
”: - literal ':'
j€ - join for €ach -> ["User: ","Group: ","Others: "]
¤ - nilad followed by link(s) as a nilad:
⁹ - chain's right argument, the input string -> "042"
O - cast to ordinal (vectorises) -> [48, 52, 50]
¢ - call last link (5) as a nilad -> ["Execute Only","Write Only","Write and Execute","Read Only","Read and Execute","Read and Write","Read Write and Execute","None"]
ị - index into (1-based & modular) -> ["None","Read Only","Write Only"]
ż - zip together -> [["User: ","None"],["Group: ","Read Only"],["Others: ","Write Only"]]
Y - join with line feeds -> ["User: ","None",'\n',"Group: ","Read Only",'\n',"Others: ","Write Only"]
- implicit print:
>>>User: None
>>>Group: Read Only
>>>Others: Write Only