Think of this problem as an extension to
Countries of the World.
The nine country names below (spelled out in upper case) have been encoded in the following manner:
C = CMNRSVWXZ
B = BDFHKLT
G = GJPQ
A = AEIOU
Y = Y
What are the nine countries?
- acabcaa
- bacacacac cagabbac
- gacagaay
- bacaab
- ccabcacbacb
- bacbacac
- babacac
- acbabacbac
- bgabaaba
clearvars,clc
fid=fopen("c:\vb5 projects\flooble\country list.txt");
i=0; country=string.empty;
while ~feof(fid)
l=fgetl(fid);
if length(l)>4 && ~isequal('Top of Page',l )
i=i+1;
country(i)=lower(string(l));
end
end
fclose(fid);
coded={};
for i=1:length(country)
coded{end+1}=char(country(i));
end
for i=1:length(coded)
for j=1:length(coded{i})
l=coded{i}(j);
if ismember(l, 'cmnrsvwxz')
coded{i}(j)='c';
elseif ismember(l , 'bdfhklt')
coded{i}(j)='b';
elseif ismember(l , 'gjpq')
coded{i}(j)='g';
elseif ismember(l , 'aeiou')
coded{i}(j)='a';
elseif l=='y'
coded{i}(j)='y';
end
end
end
for i=1:length(coded)
coded{i} = string(coded{i});
end
codes= {"acabcaa",
"bacacacac cagabbac"
"gacagaay"
"bacaab"
"ccabcacbacb"
"bacbacac"
"acbabacbac"
"bgabaaba"
};
for i=1:length(codes)
disp(i)
for j=1:length(coded)
if codes{i}==coded{j}
disp(country(j))
end
end
end
1
eritrea
2
dominican republic
3
paraguay
4
kuwait
5
switzerland
6
honduras
7
uzbekistan
8
djibouti
|
Posted by Charlie
on 2023-01-11 09:12:16 |