05AB1E , 28 19 18 바이트
[Ðü+NÌ/‚ζ˜ʒ.ï}DŠQ#
온라인으로 사용해보십시오!
어, 확실히 하드 코어를 향상시킬 수 있습니다. 여전히 리팩토링하기 위해 노력하고 있습니다.
아마도 내가 얻는 것만 큼 좋을 것입니다.
Emigna 외에는 누구에게도 감사합니다! 스왑을 지적하기 위해 레지스터보다 잘 작동했습니다.
[ // Infinite loop.
Ð // Triplicate [p, ..., q]
U // Pop 1 of 3 copies into register X.
ü+ // Pairwise addition.
NÌ/ // Divide by current iteration + 2 (which is d).
‚ // Group original [p, ..., q] with pairwise additives.
ζ˜ // Transpose together and flatten.
ʒ.ï} // Filter out non-integer entities (includes the space added by zip).
DXQ // Dupe result, see if equal to original.
# // If new array is original array, nothing happened, quit & return.
에 대한 디버그 덤프 [p,q] = [1,3]:
Full program: [ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> [ || stack: []
ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð || stack: []
current >> U || stack: [[1, 3], [1, 3], [1, 3]]
current >> ü || stack: [[1, 3], [1, 3]]
Full program: +
current >> + || stack: [1, 3]
stack > [4]
current >> N || stack: [[1, 3], [4]]
current >> Ì || stack: [[1, 3], [4], 0]
current >> / || stack: [[1, 3], [4], 2]
current >> ‚ || stack: [[1, 3], [2.0]]
current >> ζ || stack: [[[1, 3], [2.0]]]
current >> ˜ || stack: [[[1, 2.0], [3, ' ']]]
current >> ʒ || stack: [[1, 2.0, 3, ' ']]
Filter: .ï
Full program: .ï
current >> . || stack: [1]
stack > [1]
Full program: .ï
current >> . || stack: [2.0]
stack > [1]
Full program: .ï
current >> . || stack: [3]
stack > [1]
Full program: .ï
current >> . || stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D || stack: [[1, 2.0, 3]]
current >> X || stack: [[1, 2.0, 3], [1, 2.0, 3]]
current >> Q || stack: [[1, 2.0, 3], [1, 2.0, 3], [1, 3]]
current >> # || stack: [[1, 2.0, 3], 0]
stack > [[1, 2.0, 3]]
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð || stack: [[1, 2.0, 3]]
current >> U || stack: [[1, 2.0, 3], [1, 2.0, 3], [1, 2.0, 3]]
current >> ü || stack: [[1, 2.0, 3], [1, 2.0, 3]]
Full program: +
current >> + || stack: [1, 2.0]
stack > [3.0]
Full program: +
current >> + || stack: [3.0, 2.0, 3]
stack > [3.0, 5.0]
current >> N || stack: [[1, 2.0, 3], [3.0, 5.0]]
current >> Ì || stack: [[1, 2.0, 3], [3.0, 5.0], 1]
current >> / || stack: [[1, 2.0, 3], [3.0, 5.0], 3]
current >> ‚ || stack: [[1, 2.0, 3], [1.0, 1.6666666666666667]]
current >> ζ || stack: [[[1, 2.0, 3], [1.0, 1.6666666666666667]]]
current >> ˜ || stack: [[[1, 1.0], [2.0, 1.6666666666666667], [3, ' ']]]
current >> ʒ || stack: [[1, 1.0, 2.0, 1.6666666666666667, 3, ' ']]
Filter: .ï
Full program: .ï
current >> . || stack: [1]
stack > [1]
Full program: .ï
current >> . || stack: [1.0]
stack > [1]
Full program: .ï
current >> . || stack: [2.0]
stack > [1]
Full program: .ï
current >> . || stack: [1.6666666666666667]
stack > [0]
Full program: .ï
current >> . || stack: [3]
stack > [1]
Full program: .ï
current >> . || stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D || stack: [[1, 1.0, 2.0, 3]]
current >> X || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> Q || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 2.0, 3]]
current >> # || stack: [[1, 1.0, 2.0, 3], 0]
stack > [[1, 1.0, 2.0, 3]]
Full program: ÐUü+NÌ/‚ζ˜ʒ.ï}DXQ#
current >> Ð || stack: [[1, 1.0, 2.0, 3]]
current >> U || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> ü || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
Full program: +
current >> + || stack: [1, 1.0]
stack > [2.0]
Full program: +
current >> + || stack: [2.0, 1.0, 2.0]
stack > [2.0, 3.0]
Full program: +
current >> + || stack: [2.0, 3.0, 2.0, 3]
stack > [2.0, 3.0, 5.0]
current >> N || stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0]]
current >> Ì || stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0], 2]
current >> / || stack: [[1, 1.0, 2.0, 3], [2.0, 3.0, 5.0], 4]
current >> ‚ || stack: [[1, 1.0, 2.0, 3], [0.5, 0.75, 1.25]]
current >> ζ || stack: [[[1, 1.0, 2.0, 3], [0.5, 0.75, 1.25]]]
current >> ˜ || stack: [[[1, 0.5], [1.0, 0.75], [2.0, 1.25], [3, ' ']]]
current >> ʒ || stack: [[1, 0.5, 1.0, 0.75, 2.0, 1.25, 3, ' ']]
Filter: .ï
Full program: .ï
current >> . || stack: [1]
stack > [1]
Full program: .ï
current >> . || stack: [0.5]
stack > [0]
Full program: .ï
current >> . || stack: [1.0]
stack > [1]
Full program: .ï
current >> . || stack: [0.75]
stack > [0]
Full program: .ï
current >> . || stack: [2.0]
stack > [1]
Full program: .ï
current >> . || stack: [1.25]
stack > [0]
Full program: .ï
current >> . || stack: [3]
stack > [1]
Full program: .ï
current >> . || stack: [' ']
invalid literal for int() with base 10: ' '
stack > []
current >> D || stack: [[1, 1.0, 2.0, 3]]
current >> X || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> Q || stack: [[1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3], [1, 1.0, 2.0, 3]]
current >> # || stack: [[1, 1.0, 2.0, 3], 1]
[1, 1.0, 2.0, 3]
stack > [[1, 1.0, 2.0, 3]]
디버그로 온라인으로 사용해보십시오!
ü작동 하는 방법입니다 ... 이것은 내 이전 답변 중 하나를 향상시킬 수있었습니다 :-)