# What does this 1970s punched-card format mean?

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?

• No, 12 is 12. It's a repeat factor. Nov 17 '21 at 11:25
• 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
• @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. Nov 17 '21 at 14:54
• @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. Nov 17 '21 at 14:57
• 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

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).

• 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. Nov 18 '21 at 7:14
• @TripeHound typical "do we start counting at 0 or 1" error... 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". Nov 18 '21 at 16:09
• "Premise" should be "surmise."
– JRE
Nov 19 '21 at 15:02

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
``````
• X is space on output, but skip on input. Nov 20 '21 at 13:52
• @another-dave Skipped positions are typically filled with spaces in actual input for clarity. Nov 20 '21 at 17:11
• Or "it's on the data card but this particular program doesn't care about it". Nov 20 '21 at 23:47

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

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
``````