All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Left/Right side story (Posted on 2021-10-25)
Imagine a standard QWERTY keyboard on which a vertical line was drawn down, beginning between the digits 5 and 6; thus dividing the keyboard into the left and right sides.
In respect to this division any word can be matched by a couple of integers L and R, specifying the quantity of distinct letters in the left and right side respectively.
Examples: Honolulu >> (0,5); letters >>(4,1); word >>(3,1).

1. List all American one-word states that are matched by a couple, containing 0 either as L or R.
2. Same for world cities (replacing “all” by “two or more”.
3. Chose a certain category ( fruits, animals, famous people et al) and provide at least 3 members of this category for which abs(L-R)=2
4. What one-word names of numbers satisfy (L-R)^2=1? Hint: “one” does. Others?

Comments: ( Back to comment list | You must be logged in to post comments.)
 parts 1, 2 and 4 via computer Comment 1 of 1
Part 1:

clc, clearvars
leftside='qwerasdfzxcv';
rightside='yuiopghijklbnm';
fid=fopen('c:\vb5 projects\flooble\us states.txt','r');
while ~feof(fid)
line=fgetl(fid);
ix=strfind(line,' ');
for i=1:length(ix)
index=ix(i);
tst=extractBetween(string(line),index+1,index+2);
if tst==upper(tst)
state=strtrim(lower(extractBefore(line,index)));
ct=[0 0];
for j=1:length(state)
sf=(strfind( state,state(j)));
if sf(1)==j
if contains(leftside,state(j))==true
ct(1)=ct(1)+1;
end
if contains(rightside,state(j))==true
ct(2)=ct(2)+1;
end
end
end
fprintf('%s %2d %2d\n',tst,ct(1),ct(2))
break
end
end
end
fclose(fid);

The file has records such as

Ohio OH Columbus Columbus March 1, 1803 11,570,808 44,826 (116,099) 40,861 (105,830) 3,965 (10,269) 16

showing state name, postal abbreiation, capital, largest city, date of admission, etc.

T is left out of both the left and right sides and finds Texas and Ohio. When T is included in both, Texas does not exhibit a zero. A complete state list (with T excluded from either side) is:

`AL  1  3AK  2  2AZ  3  3AR  3  2CA  4  4CO  4  2CT  2  4DE  5  1FL  4  3GA  3  3HI  2  2ID  2  3IL  1  4IN  2  2IA  2  2KS  2  2KY  2  4LA  2  5ME  2  3MD  3  4MA  5  3MI  2  5MN  3  4MS  1  3MO  2  4MT  1  3NE  4  3NV  4  1NH  5  5NJ  4  3NM  4  4NY  3  4NC  3  5ND  3  4OH  0  3OK  1  5OR  2  3PA  4  5RI  6  5SC  4  6SD  3  4TN  2  1TX  4  0UT  1  2VT  3  3VA  3  3WA  3  5WV  6  3WI  3  3WY  1  6`

Part 2:

clc, clearvars
leftside='qwertasdfzxcv';
rightside='tyuiopghijklbnm';
fid=fopen('c:\vb5 projects\flooble\city country.txt','r');
while ~feof(fid)
line=fgetl(fid);
ix=strfind(line,',');

city=strtrim(lower(extractBefore(line,ix(1))));
ct=[0 0];
for j=1:length(city)
sf=  (strfind( city,city(j)));

if sf(1)==j
if contains(leftside,city(j))==true
ct(1)=ct(1)+1;
end
if contains(rightside,city(j))==true
ct(2)=ct(2)+1;
end
end
end

if ct(1)*ct(2) == 0
disp(city), disp(ct)
end

end
fclose(fid);

prints only those that meet the criteria:

accra
3     0
caracas
4     0
lomé
0     3
nuuk
0     3
warsaw
4     0

except that lomé is listed erroneously as it's accented é is not on the keyboard, including the right side of the keyboard.

I just realized, that file had only capitals. There are more:

Accra, Ghana
3     0
Bo, Sierra Leone
0     2
Bonn, Germany
0     3
Caracas, Venezuela
4     0
3     0
Fez, Morocco
3     0
Hilo, HI
0     4
Holguin, Cuba
0     7
Holon, Israel
0     4
Hong Kong, Hong Kong
0     5
Honolulu, HI
0     5
Iloilo, Philippines
0     3
Ipoh, Malaysia
0     4
Jonkoping, Sweden
0     7
Kuopio, Finland
0     5
Limon, Costa Rica
0     5
0     7
Lublin, Poland
0     5
Oulu, Finland
0     3
Serres, Greece
3     0
Sfax, Tunisia
4     0
Warsaw, Poland
4     0
Yunghu, Taiwan
0     5
Zarqa, Jordan
4     0

Part 4:

clc,  clearvars
leftside='qwertasdfzxcv';
rightside='tyuiopghijklbnm';
numbers=['zero,one,two,three,four,five,six,seven,eight,nine,'];
numbers=[numbers 'ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,'];
numbers=[numbers 'seventeen,eighteen,nineteen,'];
numbers=[numbers 'twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety,'];
while length(numbers)>1
strfind(numbers,',');
ix=ans(1);
number=extractBefore(numbers,ix);
numbers=extractAfter(numbers,ix);
if length(number)>0
ct=[0 0];
for j=1:length(number)
strfind(number,number(j));
if ans(1)==j
if contains(leftside,number(j))==true
ct(1)=ct(1)+1;
end
if contains(rightside,number(j))==true
ct(2)=ct(2)+1;
end
end
end

if abs(ct(1)-ct(2)) == 1
disp(number), disp(ct)
end
end

end

finds

one
1     2
three
3     2
six
2     1
nine
1     2
thirteen
3     4
sixteen
4     3
nineteen
2     3
fifty
2     3
seventy
4     3

where T counts as both left and right. The same number words come up if T counts for neither left nor right.

 Posted by Charlie on 2021-10-25 16:53:20

 Search: Search body:
Forums (0)