結果

問題 No.18 うーさー暗号
ユーザー r6ever6eve
提出日時 2017-08-10 11:16:10
言語 OCaml
(5.1.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 420 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 17,280 KB
最終ジャッジ日時 2024-04-27 02:28:48
合計ジャッジ時間 575 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
File "Main.ml", line 9, characters 47-48:
9 |       for i = 0 to l - 1 do Bytes.set r i (f i s.[i]) done;
                                                   ^
Error: This expression has type bytes but an expression was expected of type
         string

ソースコード

diff #

module String = struct
  include String

  (* @since 4.02.0 *)
  let mapi f s =
    let l = Bytes.length s in
    if l = 0 then s else begin
      let r = Bytes.create l in
      for i = 0 to l - 1 do Bytes.set r i (f i s.[i]) done;
      r
    end

end

let () =
  read_line ()
  |> String.mapi (fun i c ->
    (Char.code c - Char.code 'A' - ((i + 1) mod 26) + 26) mod 26 + Char.code 'A' |> Char.chr)
  |> print_endline
0