What US States (defined by a single word) contain each within its name a four letter palindromic sequence, like ABBA)?
fid=fopen('c:\VB5 Projects\flooble\STATES~1.TXT','r');
while ~feof(fid)
state=fgetl(fid);
state=lower(strtrim(state(1:21)));
if ~contains(state,' ')
for a=1:length(state)-3
if isPalin(state(a:a+3))
disp(state)
break
end
end
end
end
fclose('all');
function t=isPalin(x)
t=true;
for i=1:floor(length(x)/2)
if x(i)~=x(length(x)+1-i)
t=false;
break
end
end
end
finds
>> someSpecialStates
illinois
massachusetts
mississippi
tennessee
>>
|
Posted by Charlie
on 2024-02-06 19:09:16 |