まず、私が課題を解くにあたって使用した言語は Javascript である。 理由としては、
- ブラウザで動作すること
- ある程度慣れている言語であること
が挙げられる。
使用したツールは特にないが、スクリプトを書くにあたり、以下の StackOverflow の回答例を参考にした。
https://stackoverflow.com/questions/10834796/validate-that-a-string-is-a-positive-integer
まず最初のヒントである、"a0b1d3f5 : aaaa"を見た時には単純なシーザー暗号だと考え、それに沿うように設計を考えた。
しかし、二番目のヒントが違うロジックで暗号化されていることに気づき、また、程なくして英字の次の数字が偶数の場合は正の値、奇数の場合は負の値で文字がスライドしていることに気づいたため、そのようにコードを実装した。
ロジックのわかり易さを優先し、また他のシーザー暗号にも使用できるように caesar 関数を実装した。
この部分では
"const alphabet = "abc..."
とし、それをスライドさせる、という解法も思いついたが、記述ミスをへらすためにも charCodeAt()を使用した。
またエンジニア向けの課題ということで、英語部分とスライドさせる数字部分を自動的に判別するような実装が必要だと考え、一度 array に入れるような処理にしている。
その他の部分の実装に関しては、以下のコードにコメントとして記載した。