Are You Up to the Challenge?

I was very happy with the turnout at the third annual Olympics lab/game I sponsored at Summit this past May, and it appears that our customers who attended (I mean competed) enjoyed themselves, too. So I would like to offer the same game scenario to all of our TFC readers:

A virus has attacked your mainframe (heaven forbid!) and has alphabetized all of the syntax in your FOCEXECs. That is, what used to be a FOCEXEC that generated a nice report is now just a list of words and numbers (and some punctuation) in alphabetical order! For example, if your original FOCEXEC read:

TABLE FILE CAR
PRINT CAR AS ‘MY AUTO’
BY COUNTRY
END

Now it looks like:

AUTO
BY
CAR
CAR
COUNTRY
END
FILE
MY
PRINT 
TABLE

Note that CAR appears twice, and the quotes were removed by the virus. This is only an example; read on for the real report.

Given an output of the last report it generated and the database master and raw data, your mission is to recreate the FOCEXEC into its original syntax.

On the report below, note that the data is sorted on the last column, and note the column spacing and column heading alignments. In the alphabetized syntax list, note that some punctuation is retained but some of the punctuation required to make the report work (like quotes and double quotes) were selectively omitted by the virus; you should know where they are needed. Frankly, it is possible to generate the report with slightly different syntax than that provided, but for purposes of the game, avoid gross differences like inserting DEFINEs where there are none in the sorted syntax. Don’t worry about the report date.

The proof of completion is that every word and symbol in the list is used – no more and no less (except for adding the appropriate punctuation) and the FOCEXEC generates exactly the same report. I will publish the solution in the next issue of TFC. Good luck!

By the way, the data itself contains some names and statistics of several less-known cities and locations around the world. The square-miles and population-growth statistics, particularly for Antarctica, are very interesting. The source of this census data is www.citypopulation.de (1990 and 2000 are rounded +/- 2 years of the actual data to simplify this exercise).

The blocks of text below represent the following report elements (just cut and paste them where they can be appropriately accessed in your FOCUS session):
Olympics Report – Actual report that you have to duplicate
Olympics Master – Database master
Raw Data – Columnar description of the raw data that feeds the report
Load Focexec – Program to load the raw data into a FOCUS database
Olympics Master – Database master

Olympics Report
MAY 17, 2005                 10-YEAR POPULATION GROWTH              PAGE    1
                                                               CHANGE        
   COUNTRY    CAPITAL        SQ-KM      POP 2000   POP 1990     /1000 %CHANGE
------------- -------        -----      --------   --------    ------ -------
SUDAN         AL-KHARTUM     22142     4,740,290  1,802,299    2,937   163.0%
               (ABOVE CITY INCREASED >100)                                   
PAKISTAN      ISLAMABAD        906       805,235    340,286      464   136.6%
               (ABOVE CITY INCREASED >100)                                   
MONGOLIA      ULAANBAATAR     4700       760,077    548,400      211    38.6%
SURINAME      PARAMARIBO       183       222,800    169,798       53    31.2%
MADAGASCAR    ANTANANAVIRO   58283     4,580,788  3,601,128      979    27.2%
OMAN          MASQAT          3000       632,073    549,150       82    15.1%
FINLAND       HELSINKI        6767     1,304,595  1,147,173      157    13.7%
NEW ZEALAND   WELLINGTON      8056       423,765    400,283       23     5.9%
INDONESIA     JAKARTA          664     8,389,443  8,252,660      136     1.7%
URUGUAY       MONTEVIDEO       530     1,326,064  1,344,839      (18)   -1.4%
               (ABOVE CITY DECREASED IN POPULATION)                          
USA           WASHINGTON       178       563,384    606,900      (43)   -7.2%
               (ABOVE CITY DECREASED IN POPULATION)

Olympics Master
FILENAME=OLYMPICS,SUFFIX=XFOCUS            
                                           
SEGNAME=CONT,SEGTYPE=S1                    
 FIELDNAME=CONTINENT,   CONT,    A13,$     
                                           
SEGNAME=COUNTRY,SEGTYPE=S1,PARENT=CONT     
 FIELDNAME=COUNTRY,     CNTY,    A13,$     
 FIELDNAME=CAPITAL,     CAP,     A25,$     
 FIELDNAME=AREA,        AREA,    I6, $     
 FIELDNAME=MAIN_EXPORT, EXPORT,  A13,$     
 FIELDNAME=POP1990,     POP1990, D8 ,$     
 FIELDNAME=POP2000,     POP2000, D8 ,$

Raw Data
CONTINENT     COUNTRY       CAPITAL           AREA    POP1990    POP2000 
---------     -------       -------           ----    -------    ------- 
AFRICA        MADAGASCAR    ANTANANAVIRO     58283  3,601,128  4,580,788 
AFRICA        OMAN          MASQAT            3000    549,150    632,073 
AFRICA        SUDAN         AL-KHARTUM       22142  1,802,299  4,740,290 
ASIA          INDONESIA     JAKARTA            664  8,252,660  8,389,443 
ASIA          MONGOLIA      ULAANBAATAR       4700    548,400    760,077 
ASIA          PAKISTAN      ISLAMABAD          906    340,286    805,235 
S AMERICA     SURINAME      PARAMARIBO         183    169,798    222,800 
S AMERICA     URUGUAY       MONTEVIDEO         530  1,344,839  1,326,064 
N AMERICA     USA           WASHINGTON         178    606,900    563,384 
AUSTRALIA     NEW ZEALAND   WELLINGTON        8056    400,283    423,765 
EUROPE        FINLAND       HELSINKI          6767  1,147,173  1,304,595 
ANTARCTICA    ANTARCTICA    NONE                 0          0          0

Source of census data: www.citypopulation.de
(1990 and 2000 are rounded +/- 2 years of actual data)

Load FOCEXEC
FILENAME=OLYMPICS,SUFFIX=XFOCUS            
                                           
SEGNAME=CONT,SEGTYPE=S1                    
 FIELDNAME=CONTINENT,   CONT,    A13,$     
                                           
SEGNAME=COUNTRY,SEGTYPE=S1,PARENT=CONT     
 FIELDNAME=COUNTRY,     CNTY,    A13,$     
 FIELDNAME=CAPITAL,     CAP,     A25,$     
 FIELDNAME=AREA,        AREA,    I6, $     
 FIELDNAME=MAIN_EXPORT, EXPORT,  A13,$     
 FIELDNAME=POP1990,     POP1990, D8 ,$     
 FIELDNAME=POP2000,     POP2000, D8 ,$

Olympics FOCEXEC
-* *********************************************************************
-* DEAR PROGRAMMER,                                                     
-*                                                                      
-* I HAVE DESTROYED YOUR FOCEXEC!  I RE-ARRANGED ALL OF YOUR SYNTAX    
-* INTO AN ALPHABETIZED LIST OF WORDS! I DROPPED SOME PUNCTUATION TOO. 
-* LET ME SEE YOU PUT IT BACK TOGETHER!!                              
-*                                                                      
-* SINCERELY,                                                           
-* HOCUS POCUS THE FOCUS VIRUS                                          
-* ********************************************************************* 
-*                                                                      
-* BELOW IS WHAT YOUR FOCEXEC LOOKS LIKE NOW!!                          
-*  <+15          A13            GROWTH         POP             WHEN 
-*  <16           BY             GT             POP             WHEN
-*  <16           BY             HEADING        POPULATION      WHERE   
-*  <69           C              HIGHEST        POPULATION      0       
-*  +4            CAPITAL        IN             POP1990         0       
-*  &DATEMTRDYY   CHANGE         IN             POP1990         10-YEAR
-*  *100          CHANGE         INCREASED      POP1990         100     
-*  /1000         CITY           I6BC           POP1990         1990    
-*  /1000         CITY           LT             POP1990         2000    
-*  %CHANGE       COMPUTE        NE             POP2000                 
-*  >100          COMPUTE        NOPRINT        POP2000                 
-*  ABOVE         COUNTRY        OLYMPICS       POP2000                 
-*  ABOVE         COUNTRY        ON             SQ-KM                   
-*  AREA          COUNTRY        ON             SUBFOOT                 
-*  AS            DECREASED      PAGE           SUBFOOT                 
-*  AS            END            PCTCHANGE      SUM                     
-*  AS            FILE           PCTCHANGE      TABLE                   
-*  AS            F5.1%          PCTCHANGE      TABPAGENO               
-*  AS                           PCTCHANGE      TOTAL                   
-***********************************************************************
-* INSERT LINES BELOW HERE AND CODE YOUR SOLUTION TO THE PROBLEM.       
-***********************************************************************

Back Next