Back when I was still attending Oakland University (and still trying to cope with the calculus and physics requirements necessary for a CSE degree) I needed to fill in a class period. Money was tight so I was looking at 1 and 2 credit options that would help fulfill my major requirements.

I’d had a CSE110 class with professor Marsh and liked his teaching style and I noticed that he was doing one of the ‘language labs’ for that semester, in of all things, Fortran programming language.

For those of you that are not CSE geeks, a language lab is just that – a one credit lab to help students learn various programming languages. As a lab, it wasn’t necessarily a requirement to show up during the scheduled time for the class. In fact, most professors (including Mr. Marsh) wouldn’t even show up in the computer lab during that time period but would just make themselves available for questions during their class period. It was pretty much up to the students to pose questions and learn the material on their own, the professor only making themselves available to help them through any trouble spots.

Professor Marsh wasn’t the type to post grades or leave graded papers on his door, but he would place the weekly assignment with a reference to what pages in the text book were relevant to completing it in a slot outside his door. There were 10 assignments total for the whole semester.

Now I say that he didn’t show up in lab and I had already talked to him about it prior to the semester starting. But he did apparently show up in the lab briefly on the first day. As a student employee of the computing department, I was in the lab much of the day anyway so I didn’t bother to go to the scheduled time period. Not even on the first day.

The assignments themselves were a cinch. I wasn’t aware of it at the time, because I never once went to Mr. Marsh’s office during the first five weeks of class other than to pick up the new assignment and turn the previous one in via a slot in his door, but most of the other students apparently were frequent visitors. As a result, some of them found out that I was a good reference for assignments and thus I was getting feedback on any visits Mr. Marsh did make and any special instructions on assignments because inevitably, another student would come to ask me what I was doing for assignment #x.

About 6 weeks in he gave us an assignment for something called a magic box. I can’t remember the particulars, but recall it was something like a bizarre sudoku. A different number in every box but with each row and column adding up to the same integer. There was apparently a formula to build these at any size using consecutive integers from 1 to the product of the X times the Y dimensions minus one – so long as the grid was a square (X = Y). He included the formula on the assignment and wanted us to write a program to make one of any size and then print out various examples based on specific dimensions. (something like 5×5, 10×10 and 25×25)

I ran into my first problem and needed to go see Mr. Marsh for the first time that semester. My problem was not programming the formula. That was a breeze. My problem resulted from the fact that Fortran was built to be a math/number intensive language and not a text formatting language. I (and all the other students) found that when trying to display your output for any boxes greater than 3×3, the differences between the 1 digit and multi digit numbers quickly caused your columns to go all out of whack! The output looked horrible. I didn’t like my output to look horrible.

So I went to see Professor Marsh and he told me basically what I’d already discovered. Fortran wasn’t built for text formatting. While I was there, he remembered that he had my first 5 assignments. I knew that they were all correct so I hadn’t bothered to pick them up. But when he handed them to me, I quickly noticed that on every single one of them I had scored a 9 out of 10. I was like, wtf????

So I asked him about it. He told me that on the first day of the lab, he’d explained to everyone that you need to write out manually the solution to the problem to show that your program works. Since I wasn’t in the lab on the first day, I was never made privy to this fact. I was irked.

I said, “Come on Mr. Marsh! If I had any reason to believe that my program wasn’t doing what the assignment required it to do, I would have been down in your office just like I am now to find out how to make it do what it’s supposed to do!”

Mr. Marsh started to laugh and pointed out, “Don’t panic, I grade my labs on a curve and right now you’re the top of it.”

This fact this surprised the hell out of me because I knew there to be a number of other proficient programmers in the class – and that the only way I could be on the top was if they were consistently getting more than 1 point worth of ‘wrong’ programming in their assignments since they all ‘knew’ to include a manual proof and thus weren’t loosing the 1 point per assignment that I had. (Fortran is not complex and the problems he gave were easy – at least to me)

So I left with my 5×9-point papers, still irked that no one had told me about the manual proof requirement, but even more irked that the output of that particular lab was going to look like crap. I would not be outdone by a programming language!!!!

I can’t remember the exact specifics, but it was something akin to this that I came to as a solution. I figured out that I could, in fact, get Fortran to draw a single space. And of course, Fortran could do great math and like most programming language, had simple control structures. I was able to build a little subroutine that would divide numbers by incrementing powers of ten, incrementing a counter each time if the result of the division was greater than 1 and exiting the loop the first time that it wasn’t greater than 1. For non-programming types, this in essence counts the digits in a base 10 number system.

I could then take the dimensions I was using for a given execution of the program and square them (X*Y)-1 and run it through my subroutine as this would give me the ‘maximum’ number of digits. Then for each square, I run the value in the square across the subroutine again to get the number of digits going into that square. By subtracting that number of digits from the maximum number of digits, I could get the number of ‘leading’ spaces I would need to get the columns to properly line up on the print-out. In essence, writing my own little sprintf for inserting leading spaces on shorter numbers.

I also learned that I could send a command to the printer to make it go landscape and use a much smaller font when sending my output. So for chuckles and giggles, I not only did a 5×5, 10×10 and 25×25 but then also output a 50×50 and a 100×100 just to show I could!

He did give us a break that all we had to show manually on that assignment was a written out version of the 5×5 so I submitted that with my program and got 10 points on it (and on each additional program until the end of the semester).

## Leave a Reply