twelvefootboy wrote: ↑Thu Dec 14, 2017 1:23 am
apologies for old fortran exponentiation format, just a habit of an old goat
Ooh, story time!
I taught Fortran in college to students who generally had little programming experience and needed one computer science class to graduate. Technically, I was a TA, but most of the learning of Fortran actually happened in the lab, which I taught. My favorite thing was when the professor offered an automatic A in the class to anyone who could write a Sudoku solver in Fortran. Hearing about this challenge and being pretty good at coding, I gave it a shot, reading the puzzle through a text file, putting it into some 4-D arrays and running it through a recursive subroutine, and I actually got pretty close, writing about 200 lines of code during my spare time over the course of a week or so. If I worked on it for a semester, I might have finished it.
The topic of our first lab lesson, naturally, was read(*,*) and write(*,*) statements, so that the students could make their programs write "hello world" to the screen, and take in some user input. We introduced the concept of variables here. The topic of our second lecture was if-then-else statements and boolean logic.
This genius in my class decides, at that point, that this is enough for him to write the Sudoku solver, and that he'd rather stake his grade on one challenge of an assignment than hedge his bets and do the rest of the work in the class to earn whatever grade that would earn him.
Three quarters of the way through the semester, he calls me over to his workstation, asking for help. I assumed that he was working on that week's assignment (we were probably working on modules or functions or subroutines at that point). Nope. I look at his screen, and he has a monstrous set of if-statements in his editor. He had about 3000 lines of code at that time. He had 81 variables, called A1, A2, A3, ..., A9, B1, ..., B9, and so on, and the first section of his program was 81 prompts and read statements to read in the values of each of the cells individually. After that, it was all if-statements. His if-statements each took up about 8 lines on the screen (which was technically one line of code). What he was doing was, for each cell, manually checking, for example, if any of the other 20 squares in its row, column, or sub-square were equal to 2, 3, 4, etc., all the way to 9. If all of those were true, then he'd know that the square being checked must be a 1. He did that for every square, for every number 1-9. No loops. No arrays. No functions. No subroutines.
To his credit, his program somehow got all but 2 squares of an example input correct, but that wasn't good enough. His final grade in the class was about a 20%.