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

Home > General > Word Problems
Left/Right side story (Posted on 2021-10-25) Difficulty: 3 of 5
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).

Now, answer this:
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?

No Solution Yet Submitted by Ady TZIDON    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution 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  3
AK  2  2
AZ  3  3
AR  3  2
CA  4  4
CO  4  2
CT  2  4
DE  5  1
FL  4  3
GA  3  3
HI  2  2
ID  2  3
IL  1  4
IN  2  2
IA  2  2
KS  2  2
KY  2  4
LA  2  5
ME  2  3
MD  3  4
MA  5  3
MI  2  5
MN  3  4
MS  1  3
MO  2  4
MT  1  3
NE  4  3
NV  4  1
NH  5  5
NJ  4  3
NM  4  4
NY  3  4
NC  3  5
ND  3  4
OH  0  3
OK  1  5
OR  2  3
PA  4  5
RI  6  5
SC  4  6
SD  3  4
TN  2  1
TX  4  0
UT  1  2
VT  3  3
VA  3  3
WA  3  5
WV  6  3
WI  3  3
WY  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
Dacca, Bangladesh                
     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
Linkoping, Sweden                
     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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (16)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information