(use scheme.vector) (use gauche.collection) (use util.combinations) (let* ((n (read))) (define vec (vector-map char->integer (string->vector (number->string n)))) (print (apply max (cons n #?=(let loop ((is (combinations (iota (vector-length vec)) 2))) (cond ((null? is) '()) (else (let ((vec-copied (vector-copy vec)) (pair (car is))) (vector-swap! vec-copied (car pair) (cadr pair)) (cons (string->number (list->string (map integer->char vec-copied))) (loop (cdr is)))))))))))