Instruções

Tabuleiro de damas escarranchado

Implemente funções para criptografar e descriptografar uma mensagem usando o método straddling checkerboard. Cada função receberá dois argumentos, uma string de message e um array alphabet. O array alphabet conterá 3 strings representando as 3 linhas do tabuleiro de verificação. A saída da função straddle() deve ser uma série de algarismos decimais. Números devem ser criptografados inserindo o caractere de escape antes de cada dígito, depois incluindo o dígito <em>não criptografado</em>. Isso deve ser revertido para descriptografar com a função unstraddle().

O que fazer:

Testes:

  • `straddle` deve ser uma função.
  • `straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` deve retornar uma string.
  • `straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` deve retornar `"34045747525284613427502840425027537379697175891898898898584619028294547488"`.
  • `straddle("One night-it was on the twentieth of March, 1888-I was returning",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])` deve retornar `"139539363509369743061399059745399365901344308320791798798798367430685972839363935"`.
  • `straddle("Thecheckerboardcakerecipespecifies3largeeggsand2.25cupsofflour.",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])` deve retornar `"125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769"`.
  • `unstraddle` deve ser uma função.
  • `unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` deve retornar uma string.
  • `unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` deve retornar `"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING."`.
  • `unstraddle("139539363509369743061399059745399365901344308320791798798798367430685972839363935",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])` deve retornar `"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING"`.
  • `unstraddle("125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])` deve retornar `"THECHECKERBOARDCAKERECIPESPECIFIES3LARGEEGGSAND2.25CUPSOFFLOUR."`.

Console