Complete the words given below using three consecutive letters in alphabetic order.
As an example, for: (*)(*)A(*)US, add A, B, and C and it becomes ABACUS.
- CO(*)(*)E(*)
- (*)(*)(*)ORM
- SO(*)E(*)(*)
- (*)A(*)(*)RATE
- (*)U(*)G(*)L
- S(*)O(*)(*)Y
- (*)OBU(*)(*)
- (*)O(*)OT(*)NE
- (*)US(*)E(*)
clearvars,clc
alphabet='abcdefghijklmnopqrstuvwxyz';
word= {'CO**E*'
'***ORM'
'SO*E**'
'*A**RATE'
'*U*G*L'
'S*O**Y'
'*OBU**'
'*O*OT*NE'
'*US*E*' };
word=lower(word);
for i=1:length(word)
disp(' ')
disp(word{i})
for astart=1:24
w=word{i};
lets=alphabet(astart:astart+2);
ix=find(w=='*');
w(ix)=lets;
if isword(w)
w(ix)=upper(w(ix));
disp(w)
end
end
end
where isword is a function already written:
function iw=isword(x)
ws=string(x);
xl=length(x);
fn=['c:\words\words' num2str(xl) '.txt'];
words=fileread(fn);
nwords=length(words)/xl;
first=1; last=nwords;
while first<=last
mid=floor((first+last)/2);
word=string(words(xl*(mid-1)+1:xl*mid));
if word==ws
break
end
if word>ws
last=mid-1;
end
if word<ws
first=mid+1;
end
end
if word==ws
iw=true;
else
iw=false;
end
end
finds
co**e*
coRSeT
***orm
DEForm
so*e**
soLeMN
soReST Two solutions for this one.
*a**rate
SaTUrate
*u*g*l
CuDgEl
s*o**y
sNoOPy
*obu**
RobuST
*o*ot*ne
MoNotOne
*us*e*
RusSeT
|
Posted by Charlie
on 2023-03-15 14:21:58 |