%% From Williams' text, 2.4 # 41
% Intelligence sources give the  information that the message 
% BOSTON CAFE AT TWO was sent as
%
% 32,47,59,79,43,57,33,36,13,18,59,86,41,61,67,87,53,68
%
% (a) Find the encoding matrix (3 x 3)
% (b) Decode the messge 43,64,49,70,59,79,39,45,45,63,59,79

%% Set variables
	%Scramble = [ [32 47 59]' [79 43 57]' [33 36 13]' [18 59 86]' [41 61 67]' [87 53 68]']
	%Message = [ [2 15 19]' [20 15 14]' [27 3 1]' [6 5 27]' [1 20 27]' [20 23 15]']
	Message = [ [16 5]' [1 3]' [5 27]' ]
	Scramble = [ [49 38]' [-5 -3]'  [-61 -39]']

%% The Scramble is create by
	disp(['A * Message = Scramble']);

%% A is a 3x3 matrix with entries A = a,b,c,d,e,f,g,h,i
%
%      [ a b c ]
%  A = [ d e f ]
%      [ g h i ]

	%syms a b c d e f g h i;
	%A_vectorized = [a b c d e f g h i]

%% The setup gives us 18 equations in nine variables, a, b, ... i.
%  Set up the linear equation:
	%B(1:6,:) = [Message' zeros(size(Message')) zeros(size(Message'))]
	%B(7:12,:) = [zeros(size(Message')) Message'  zeros(size(Message'))]
	%B(13:18,:) = [zeros(size(Message')) zeros(size(Message')) Message']

	%S = reshape(Scramble,18,1);

	%B*S

	%NewMessage = [[43 64 49]' [70 59 79]' [39 45 45]' [63 59  79]']
