;;;10進数を2進数にしてそのnotをとって
;;;最後に10進数に戻す
;;;
;;; Scheme
(define foo
(lambda (n)
(2to10 (notbin (10to2 n)))))
(define 2to10
(lambda (lat)
(cond
((null? lat) 0)
((= (car lat) 1)
(+ (expt 2 (1- (length lat)))
(2to10 (cdr lat))))
(else
(2to10 (cdr lat))))))
(define notbin
(lambda (lst)
(cond
((null? lst) '())
((= (car lst) 0)
(cons 1 (notbin (cdr lst))))
(else
(cons 0 (notbin (cdr lst)))))))
(define 10to2
(lambda (n)
(cond
((zero? n) '())
(else
(orbin (cons 1 (fill 0 (log2 n)))
(10to2 (- n
(expt 2 (log2 n)))))))))
(define orbin
(lambda (lat1 lat2)
(reverse (orbin-sub (reverse lat1)
(reverse lat2)))))
(define orbin-sub
(lambda (lat1 lat2)
(cond
((null? lat1) lat2)
((null? lat2) lat1)
((or (= 1 (car lat1))
(= 1 (car lat2)))
(cons 1 (orbin-sub (cdr lat1)
(cdr lat2))))
(else
(cons 0 (orbin-sub (cdr lat1)
(cdr lat2)))))))
(define fill
(lambda (a n)
(cond
((zero? n) '())
(else
(cons a (fill a (1- n)))))))
(define log2
(lambda (a)
(cond
((< a 2) 0)
(else
(1+ (log2 (div a 2)))))))
(define div
(lambda (a b)
(cond
((< a b) 0)
(else
(1+ (div (- a b) b))))))
Ozs7MTDpgLLmlbDjgpLvvJLpgLLmlbDjgavjgZfjgabjgZ3jga5ub3TjgpLjgajjgaPjgaYKOzs75pyA5b6M44GrMTDpgLLmlbDjgavmiLvjgZkKOzs7Cjs7OyBTY2hlbWUKKGRlZmluZSBmb28KICAobGFtYmRhIChuKQogICAgKDJ0bzEwIChub3RiaW4gKDEwdG8yIG4pKSkpKQoKKGRlZmluZSAydG8xMAogIChsYW1iZGEgKGxhdCkKICAgIChjb25kCiAgICAgKChudWxsPyBsYXQpIDApCiAgICAgKCg9IChjYXIgbGF0KSAxKQogICAgICAoKyAoZXhwdCAyICgxLSAobGVuZ3RoIGxhdCkpKQogICAgICAgICAoMnRvMTAgKGNkciBsYXQpKSkpCiAgICAgKGVsc2UKICAgICAgKDJ0bzEwIChjZHIgbGF0KSkpKSkpCgooZGVmaW5lIG5vdGJpbgogIChsYW1iZGEgKGxzdCkKICAgIChjb25kCiAgICAgKChudWxsPyBsc3QpICcoKSkKICAgICAoKD0gKGNhciBsc3QpIDApCiAgICAgIChjb25zIDEgKG5vdGJpbiAoY2RyIGxzdCkpKSkKICAgICAoZWxzZQogICAgICAoY29ucyAwIChub3RiaW4gKGNkciBsc3QpKSkpKSkpCiAgCihkZWZpbmUgMTB0bzIKICAobGFtYmRhIChuKQogICAgKGNvbmQKICAgICAoKHplcm8/IG4pICcoKSkKICAgICAoZWxzZQogICAgICAob3JiaW4gKGNvbnMgMSAoZmlsbCAwIChsb2cyIG4pKSkKICAgICAgICAgICAgICgxMHRvMiAoLSBuCiAgICAgICAgICAgICAgICAgICAgICAgKGV4cHQgMiAobG9nMiBuKSkpKSkpKSkpCgooZGVmaW5lIG9yYmluCiAgKGxhbWJkYSAobGF0MSBsYXQyKQogICAgIChyZXZlcnNlIChvcmJpbi1zdWIgKHJldmVyc2UgbGF0MSkKICAgICAgICAgICAgICAgICAgICAgICAgKHJldmVyc2UgbGF0MikpKSkpCgooZGVmaW5lIG9yYmluLXN1YgogIChsYW1iZGEgKGxhdDEgbGF0MikKICAgIChjb25kCiAgICAgKChudWxsPyBsYXQxKSBsYXQyKQogICAgICgobnVsbD8gbGF0MikgbGF0MSkKICAgICAoKG9yICg9IDEgKGNhciBsYXQxKSkKICAgICAgICAgICg9IDEgKGNhciBsYXQyKSkpCiAgICAgIChjb25zIDEgKG9yYmluLXN1YiAoY2RyIGxhdDEpCiAgICAgICAgICAgICAgICAgICAgICAgICAoY2RyIGxhdDIpKSkpCiAgICAgKGVsc2UKICAgICAgKGNvbnMgMCAob3JiaW4tc3ViIChjZHIgbGF0MSkKICAgICAgICAgICAgICAgICAgICAgICAgIChjZHIgbGF0MikpKSkpKSkKCihkZWZpbmUgZmlsbAogIChsYW1iZGEgKGEgbikKICAgIChjb25kCiAgICAgKCh6ZXJvPyBuKSAnKCkpCiAgICAgKGVsc2UKICAgICAgKGNvbnMgYSAoZmlsbCBhICgxLSBuKSkpKSkpKQoKKGRlZmluZSBsb2cyCiAgKGxhbWJkYSAoYSkKICAgIChjb25kCiAgICAgKCg8IGEgMikgMCkKICAgICAoZWxzZQogICAgICAoMSsgKGxvZzIgKGRpdiBhIDIpKSkpKSkpCgooZGVmaW5lIGRpdgogIChsYW1iZGEgKGEgYikKICAgIChjb25kCiAgICAgKCg8IGEgYikgMCkKICAgICAoZWxzZQogICAgICAoMSsgKGRpdiAoLSBhIGIpIGIpKSkpKSkK