function decrypted = mono_decrypt ( code, crypt )

%*****************************************************************************80
%
%% mono_decrypt() decrypts a string using a monoalphabetic substitution code.
%
%  Discussion:
%
%    Only the alphabetic characters A-Z will be encrypted.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 October 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string CODE(26), lists the substitutes for 'A' through 'Z'.
%
%    string CRYPT(*), the encrypted version of the string.
%
%  Output:
%
%    string DECRYPTED(*), the decrypted string.
%

%
%  The decrypted letter set.
%
  abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
%
%  How long is the string?
%
  n = length ( crypt ); 
%
%  Characters that don't match are left alone.
%
  decrypted = crypt;
%
%  Copy the encrypted text.
%
  copy = crypt;
%
%  Each encrypted character that matches symbol J in the code
%  should be replaced by the alphabetic character J.
%
  for i = 1 : n
    for j = 1 : 26
      if ( crypt(i) == code(j) )
        decrypted(i) = abc(j);
        break;
      end
    end
  end
      
  return
end

