13

The 1974 Texas Regional Programming Contest (a predecessor of the ICPC) describes an input format:

A room description will be contained on a single card with the format: (1X, I2, 2X, 12 (A1, I2, 2X)).

The "number of corners" will be contained in columns 2 and 3 of the card and successive direction-distance pairs will be contained in columns 5-7, 10-12, 15-17, etc.

(I assume that the 12 is a typo and should be another I2.)

What does the format mean? What do 1X etc. and I2 denote?

23
  • 9
    No, 12 is 12. It's a repeat factor. Nov 17 '21 at 11:25
  • 5
    See page 41 onwards in this IBM FORTRAN II manual.A 1974 programmer would likely be using FORTRAN IV, but the particular format in your question looks valid for FORTRAN II as well. Nov 17 '21 at 13:06
  • 7
    @RBarryYoung - you don't need to be in CS to program, and many would say real CS has little to do with writing a program.
    – Jon Custer
    Nov 17 '21 at 14:54
  • 3
    @RBarryYoung - fair enough, but there was lots of computer programming going on at universities whether there was an official Computer Science degree or not. Lots of science and engineering courses used programming to solve their problems.
    – Jon Custer
    Nov 17 '21 at 14:57
  • 3
    The ICPC traces its roots to a competition held at Texas A&M in 1970 hosted by the Alpha Chapter of the UPE Computer Science Honor SocietyICPC Fact Sheet Nov 17 '21 at 15:13
32

The symbols are as follows:

  • () are used for grouping.
  • X → Value doesn't matter
  • I → Numeric (integer)
  • A → Alphabetic (in this case one of N, S, E, or W)
  • , → Used to separate each column or group definition

The numbers indicate how many columns the field takes up or how many times the group is repeated.

Given the desciption (1X, I2, 2X, 12 (A1, I2, 2X)) here's how it breaks down:

Column Description Contents
1 1X (don't care)
2 – 3 I2 Corner count (2-digit integer)
4 – 5 2X (don't care)
6 A1 Direction #1 (single letter)
7 – 8 I2 Length #1 (2-digit integer)
9 – 10 2X (don't care)
11 A1 Direction #2 (single letter)
12 – 13 I2 Length #2 (2-digit integer)
14 – 15 2X (don't care)
... ... ...
60 A1 Direction #12 (single letter)
61 – 62 I2 Length #12 (2-digit integer)
63 – 64 2X (don't care)

(The outer parentheses represent the entire card.)


The 12 that you premise is a typo is actually the repeat count for the definition of the list of corners. In other words there is space allocated for 12 corner points on a card. The actual number of corner points present on a given card is given in the first field (I2 → a 2-digit integer stored in columns 2 – 3).

5
  • 12
    This answer is thorough. It's worth adding that this format description comes from FORTRAN. Nov 17 '21 at 12:41
  • Interestingly, there is a typo/mistake in the original document: "in columns 5-7, 10-12, 15-17, etc." should be "in columns 6-8, 11-13, 16-18, etc." as the above table shows.
    – TripeHound
    Nov 18 '21 at 7:14
  • 1
    @TripeHound typical "do we start counting at 0 or 1" error...
    – Arsenal
    Nov 18 '21 at 14:53
  • @Arsenal Seems unlikey... punched cards were always columns 1..80, and they say the corner count is in columns 2 and 3 (which would be 1and 2 if counting from zero). I think it's "just an error".
    – TripeHound
    Nov 18 '21 at 16:09
  • "Premise" should be "surmise."
    – JRE
    Nov 19 '21 at 15:02
4

X is "space", prefixed by count, I is "integer", postfixed by the number of digits, A is "character", postfixed by character count, parentheses group items, a number before the parentheses indicates a repeat count. There is no typo.

Therefore, a line satisfying the format will be, for example,

 12  A23  B34  C45  D56  E67  F78  G89  H90  I01  J13  K24  L35
3
  • 1
    X is space on output, but skip on input. Nov 20 '21 at 13:52
  • 1
    @another-dave Skipped positions are typically filled with spaces in actual input for clarity.
    – Leo B.
    Nov 20 '21 at 17:11
  • 2
    Or "it's on the data card but this particular program doesn't care about it". Nov 20 '21 at 23:47
2

Using the example measurements, a data card would look like:

floor corners punched card data

or as a line of text (with ruler added to help with column count):

000000000111111111122222222223333333333444444444455555555556666666666777
123456789012345678901234567890123456789012345678901234567890123456789012
  6  N 9  E16  N 4  E 7  S13  W23  N 0  N 0  N 0  N 0  N 0  N 0

This line was generated from the FORTRAN code

      PROGRAM corners
      INTEGER LENGTHS(12), KOUNT
      CHARACTER*1 DIR(12)
      DATA KOUNT/6/
      DATA LENGTHS/9, 16, 4, 7, 13, 23, 0, 0, 0, 0, 0, 0/
      DATA DIR/'N', 'E', 'N', 'E', 'S', 'W', 
     *         'N', 'N', 'N', 'N', 'N', 'N'/
      WRITE(UNIT=*, FMT=100) KOUNT, (DIR(I), LENGTHS(I), I=1,12)
      STOP
  100 FORMAT (1X, I2, 2X, 12 (A1, I2, 2X))
      END

Format line 100 is the format you asked about.

(card image generated by Virtual Card Read-Punch)

2
  • Just for my curiosity, what version of FORTRAN is that? Specifically, with the keywords in the WRITE. (I stopped using FORTRAN in the mid-70s, so 66 was the last standard I cared about) Nov 20 '21 at 13:54
  • Fortran 77, though IBM 7030 FORTRAN IV had that feature in 1963. DEC even managed to squeeze it into the PDP-8 FORTRAN-IV
    – scruss
    Nov 20 '21 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.