(define (conway n)
(let loop ((result (list 3))
(index n))
(if (= 1 index)
result
(loop (reverse (exchenge result)) (- index 1)))))
(define (exchenge lis)
(let loop ((ls lis)
(result '()))
(if (pair? ls)
(let ((num (car ls)))
(receive (cn restlis) (cunt = num ls)
(set! result (cons cn result))
(set! result (cons num result))
(loop restlis result)))
result)))
(define (cunt pred el lis)
(let1 result 0
(let loop ((ls lis))
(if (and (pair? ls) (pred el (car ls)))
(begin
(inc! result)
(loop (cdr ls)))
(values result ls)))))
KGRlZmluZSAoY29ud2F5IG4pCiAgKGxldCBsb29wICgocmVzdWx0IChsaXN0IDMpKQoJICAgICAgKGluZGV4IG4pKQogICAgKGlmICg9IDEgaW5kZXgpCglyZXN1bHQKCShsb29wIChyZXZlcnNlIChleGNoZW5nZSByZXN1bHQpKSAoLSBpbmRleCAxKSkpKSkKCihkZWZpbmUgKGV4Y2hlbmdlIGxpcykKICAobGV0IGxvb3AgKChscyBsaXMpCgkgICAgIChyZXN1bHQgJygpKSkKICAgIChpZiAocGFpcj8gbHMpCiAgICAgIChsZXQgKChudW0gKGNhciBscykpKQoJKHJlY2VpdmUgKGNuIHJlc3RsaXMpIChjdW50ID0gbnVtIGxzKQoJICAoc2V0ISByZXN1bHQgKGNvbnMgY24gcmVzdWx0KSkKCSAgKHNldCEgcmVzdWx0IChjb25zIG51bSByZXN1bHQpKQoJICAobG9vcCByZXN0bGlzIHJlc3VsdCkpKQogICAgICByZXN1bHQpKSkKCihkZWZpbmUgKGN1bnQgcHJlZCBlbCBsaXMpCiAgKGxldDEgcmVzdWx0IDAKICAgIChsZXQgbG9vcCAoKGxzIGxpcykpCiAgICAgIChpZiAoYW5kIChwYWlyPyBscykgKHByZWQgZWwgKGNhciBscykpKQoJICAoYmVnaW4KCSAgICAoaW5jISByZXN1bHQpCgkgICAgKGxvb3AgKGNkciBscykpKQoJICAodmFsdWVzIHJlc3VsdCBscykpKSkp