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

Home > General
Geographic entities (Posted on 2015-04-20) Difficulty: 3 of 5
Let’s take a certain word, change one letter in it and rearrange the letters to get another valid word .
Denote this operation by .
Examples: sport trips shirt
or bread dares cards.

Find solutions fitting the following pattern:
Country I Capital I Country II
Capital II Country III Capital III

All the cities and countries above are 5-letter words.

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

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer assisted solution | Comment 1 of 3
Countries with their capitals were downloaded from Wikipeda, brought into a Spreadsheet and saved as a comma-delimited file to be perused by:

DECLARE FUNCTION except1! (a$, b$)
OPEN "cityco~1.txt" FOR INPUT AS #1
OPEN "city5.txt" FOR OUTPUT AS #2
OPEN "country5.txt" FOR OUTPUT AS #3
DO
  LINE INPUT #1, l$
  ix = INSTR(l$, ",")
  IF ix > 5 THEN
     city$ = LTRIM$(RTRIM$(LEFT$(l$, ix - 1)))
     l$ = MID$(l$, ix + 1)
     ix = INSTR(l$, ",")
     IF ix = 0 THEN ix = LEN(l$) + 1
     country$ = LTRIM$(RTRIM$(LEFT$(l$, ix - 1)))
     IF LEN(city$) = 5 THEN PRINT #2, LCASE$(city$)
     IF LEN(country$) = 6 THEN PRINT #3, LCASE$(MID$(country$, 2))
  END IF
LOOP UNTIL EOF(1)
CLOSE

OPEN "city5.txt" FOR INPUT AS #1
OPEN "ccmatch4.txt" FOR OUTPUT AS #3
DO
    INPUT #1, c$
    OPEN "country5.txt" FOR INPUT AS #2
    DO
       INPUT #2, n$
       IF except1(c$, n$) THEN PRINT #3, c$, n$
    LOOP UNTIL EOF(2)
    CLOSE 2
LOOP UNTIL EOF(1)
CLOSE 1

FUNCTION except1 (a$, b$)
  x$ = a$: y$ = b$
  FOR i = 1 TO LEN(y$)
    ix = INSTR(x$, MID$(y$, i, 1))
    IF ix THEN x$ = LEFT$(x$, ix - 1) + MID$(x$, ix + 1)
  NEXT i
  IF LEN(x$) = 1 THEN except1 = 1: EXIT FUNCTION
  except1 = 0
END FUNCTION

finds this list of cities:

abuja
accra
alofi
amman
cairo
dakar
dhaka
hanoi
kabul
minsk
paris
praia
quito
rabat
seoul
sofia
tokyo
tunis
vaduz

and this list of countries:

ghana
china
egypt
syria
sudan
gabon
spain
kenya
burma
india
palau
niger
tonga
aruba
haiti
benin
yemen
chile
japan
libya
malta
nauru

and finds these correlations:

abuja         aruba
hanoi         china
paris         syria
paris         spain
rabat         aruba

As Paris connects to Syria and Spain, and Aruba connects to Abuja and Rabat, the solutions are:

Syria --> Paris --> Spain
Abuja --> Aruba --> Rabat

Of course the direction in each case can be reversed.

  Posted by Charlie on 2015-04-20 15:28:27
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (17)
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