A.rs;ò©n∍9ÝΩ®DnαLʒ®%Ā}<Ωǝ®ô»¹Éi.º.∊ëº∊
+11 바이트 여전히 홀수 입력 염두에 규칙 3을 유지하면서 임의의 위치에 인 자리 고쳐 ..
-2- 덕분 바이트 @MagicOctopusUrn 변경 îï
에 ò
상기 위치를 변경 »
.
더 많은 테스트 사례 를 확인하기 위해 온라인 으로 사용해보십시오 .
Old ( 29 27 bytes )는 숫자가 항상 모퉁이에서 어디에 위치하는지 대답합니다.
A.rs;ò©n∍¦9ÝΩì®ô»¹Éi.º.∊ëº∊
온라인으로 시도 하거나 더 많은 테스트 사례를 확인 하십시오 .
설명:
A # Take the lowercase alphabet
.r # Randomly shuffle it
# i.e. "abcdefghijklmnopqrstuvwxyz" → "uovqxrcijfgyzlbpmhatnkwsed"
s # Swap so the (implicit) input is at the top of the stack
; # Halve the input
# i.e. 7 → 3.5
ò # Bankers rounding to the nearest integer
# i.e. 3.5 → 4
© # And save this number in the register
n # Take its square
# i.e. 4 → 16
∍ # Shorten the shuffled alphabet to that length
# i.e. "uovqxrcijfgyzlbpmhatnkwsed" and 16 → "uovqxrcijfgyzlbp"
9ÝΩ # Take a random digit in the range [0,9]
# i.e. 3
®Dnα # Take the difference between the saved number and its square:
# i.e. 4 and 16 → 12
L # Create a list in the range [1,n]
# i.e. 12 → [1,2,3,4,5,6,7,8,9,10,11,12]
ʒ } # Filter this list by:
®%Ā # Remove any number that's divisible by the number we've saved
# i.e. [1,2,3,4,5,6,7,8,9,10,11,12] and 4 → [1,2,3,5,6,7,9,10,11]
< # Decrease each by 1 (to make it 0-indexed)
# i.e. [1,2,3,5,6,7,9,10,11] → [0,1,2,3,5,6,7,9,10]
Ω # Take a random item from this list
# i.e. [0,1,2,3,5,6,7,9,10] → 6
ǝ # Replace the character at this (0-indexed) position with the digit
# i.e. "uovqxrcijfgyzlbp" and 3 and 6 → "uovqxr3ijfgyzlbp"
®ô # Split the string into parts of length equal to the number we've saved
# i.e. "uovqxr3ijfgyzlbp" and 4 → ["uovq","xr3i","jfgy","zlbp"]
» # Join them by new-lines (this is done implicitly in the legacy version)
# i.e. ["uovq","xr3i","jfgy","zlbp"] → "uovq\nxr3i\njfgy\nzlbp"
¹Éi # If the input is odd:
# i.e. 7 → 1 (truthy)
.º # Intersect mirror the individual items
# i.e. "uovq\nxr3i\njfgy\nzlbp"
# → "uovqvou\nxr3i3rx\njfgygfj\nzlbpblz"
.∊ # And intersect vertically mirror the whole thing
# i.e. "uovqvou\nxr3i3rx\njfgygfj\nzlbpblz"
# → "uovqvou\nxr3i3rx\njfgygfj\nzlbpblz\njfgygfj\nxr3i3rx\nuovqvou"
ë # Else (input was even):
º∊ # Do the same, but with non-intersecting mirrors