type case = Lower | Upper | Other let case_of_char c = if 'a' <= c && c <= 'z' then Lower else if 'A' <= c && c <= 'Z' then Upper else Other let solve s = let buf = Bytes.of_string s in let blen = Bytes.length buf in let rec solve' idx = if idx < blen then ( let c = buf.[idx] in let cc = match case_of_char c with | Lower -> Char.uppercase c | Upper -> Char.lowercase c | Other -> failwith "hoge" in Bytes.set buf idx cc; solve' (idx + 1) ) in solve' 0; Bytes.to_string buf let () = let s = read_line () in solve s |> print_endline