Skip to content

Instantly share code, notes, and snippets.

@papinianus
Created October 4, 2016 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papinianus/7586332fb4623035d969b4760140f4a7 to your computer and use it in GitHub Desktop.
Save papinianus/7586332fb4623035d969b4760140f4a7 to your computer and use it in GitHub Desktop.
<?php
$strs = str_split(trim(fgets(STDIN)));
$alpha = 'ZABCDEFGHIJKLMNOPQRSTUVWXY'; //アルファベットを数値化するためのベース。文字のコード値が分からなかったので。
foreach($strs as $i => $char) { //i番目の文字について
$coded = strpos($alpha, $char); // 暗号化された文字を数値化。
$decod = (26+$coded-($i%26)-1)%26; // 暗号文字のから文字の場所をひく。マイナスにならないように26を足し、iも26の剰余にする
echo $alpha[$decod];
}
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment