# Programming

### Globals Breaks And Returns, oh my

Never use global variables Never break out of a loop These are two "best practices" that are frequently touted in early CS classes both at the high school and college level. They came up a couple of times yesterday. Once in the Facebook APCS-A teachers group and once on Alfred Thompson's blog. Alfred post was topically on global variables. Actually it was deeper than just global variables. It's also about how students progress - what they can figure out at various stages of progress and how what seems like a good idea early on the path to computer science doesn't seem so great later on.

### Rite Of Passage Projects

JCS's post on Irreal today brought me back. It was about Brief which was the editing hotness back in the day. I played with it a little really mostly used Emacs clones for real work when I was stuck on MS-DOS systems. Usually either JOVE or Epsilon In the comments Jon reminded me about the MKS Toolkit which brought most everyday Unix tools to DOS along with a shell and a version of Vi.

### Advent of Code 2017 - Day 1

It's once again time for Advent of Code. That one a day programming competition that's been running now for three years. Here are some thoughts on day 1. The core of the problem is that you have a large string of digits and you have to calculate a checksum. This is done by adding the sum of a subset of the digits. Only the ones that are identical to the digit to their right.

### Motivating and understanding quicksort

Thks question was posed the other day - how can one get students to truly understand the quicksort algorithm? I've written a few posts about quicksort. The last time I did a lesson writeup on the subject I wrote about first looking and quickselect and then moving to the quicksort. The class was first faced with the problem of writing a routine to find the Kth smallest item in an unsorted data set.

### Programming Idioms

I just read Jeff Yearout's recent post titled The Beginner's Garden of Concepts. Not directly related but it got me thinking about programming idioms. I've been using the phrase "programming idiom" for years to describe a short useful recurring code construct. I didn't realize that it was officially "a thing" until doing a web search on the phrase years later. As our students grow from newbies on I think it's helpful for them to see recurring and related patterns and programming idioms gives us a name to apply to many beginner patterns.

### A* is born

Over on the CS Educator StachExchange, which is in private beta for a few more days, I saw a post asking about how to introduce the A* search algorithm. I taught A* as part of the APCS class at Stuy so I thought I'd talk about what I did here. Some time around mid year, we get to intermediate recursion. This is about the time, give or take, when we talk about the nlogn sorts.

I'm spending the weekend up in Michigan. Visiting my brother and is family. We're here to see the UMGASS production of Gilbert and Sullivan's The Sorcerer. Batya also came up from Cornell to join us so the two families are all togehter for the first time in about 10 years. This hasn't left much time for Advent of Code but I did manage to finish yesterday's challenge this morning. What took me so long?

### A Teacher looks at Advent of Code 2016 #2

Today we're looking at Advent of Code 2016 number 2. To change things up, I thought I'd do a video where I live code a solution. The solution I present is pretty straightforward - use a 2D array (or technically, an array of strings) to represent the keypad, parse the input, and follow the input instructions to build the code. One of the things I really like about Advent of Code is that every problem has two parts and depending on how you solved part 1, you may or may not have extra work to do for part 2.