Tools can shape how we think

I've been having fun with this years Advent of Code competition. So far, I've been able to keep up but with I expect that to change in another couple of days since I'll be traveling for the weekend.

After solving a problem, I like looking over some of the other solutions on the Advent of Code subreddit. Even with similar agorithmic solutions there's a decent amount of variation in the actual code and solutions in different languages can look radically different.

That got me thinking about how the tools we know and use both shape the ways we approach solving problems and creating things and either limit or empower us to go from a mental model of a solution or creation to an actual artifact.

Relating to this are the common themes that come up in the CS Education world. The idea that it's computer science not programming and certainly not merely coding. That's true but the tools and languages we use shape the whole thinking part and can also give the students a valuable practical tool that they can leverage to great advantage in both future classes and work and life endeavors.

I decided to do this rant as a video. I hope you enjoy it:

<iframe width="560" height="315" src="" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>

Thoughts On A Hackathon

Yesterday I was one of the judges at StuyHacks. A one day hackathon at Stuyvesant run by and organized by the students. I don't have attendee stats but there were kids from all over the city and at least one team from New Jersey. The youngest student that I met was in sixth grade and the oldest were high school seniors. The judging was at the end but I decided to stop by earlier to see how the hackers were doing.

There was an incredible variety of projects using a wide array of tools. There were projects built with:

  • Java
  • Processing
  • C#
  • Scratch
  • A-Frame
  • Python / Flask
  • and more

A personal highlight for me was running into Sophie - the daughter of two of my students from #Stuy95. Well, both a highlight and a reminder that I'm getting old.

The StuyHacks team did a terrific job running things and at the end I told them I'd love to help with future events.

I did notice a couple of things at the hackathon that echo things I've learned as a teacher over the years and I thought they were worth sharing.

The first was the a number of the beginner groups needed more direction. This didn't seem to be related to grade level or age as much as CS experience. This isn't a hackathon only issue. It exists in all learning environments. If as teachers we're too prescriptive students end up with a single formula to follow. Sure, that'll get them through a standardized exam like APCS-A but too much of it can hinder them in becoming creative problem solvers.

On the other hand, not enough structure will leave many kids staring at a blank page. I remember I gave a quiz years ago. It had one problem: "You have 20 minutes to prove to me that you learned something about the past unit on Cellular Autmata" or something like that. Some kids absolutely loved it but many hated it. Stuy kids are trained test takers. They're prepared for structure. This threw many for a loop.

I noticed this issue with some of the hackers at StuyHacks. Some beginners really had a hard time figuring out what they could do and what they should do.

A hackathon isn't a classroom so I think the problem is pretty easily remedied. Groups that were able to latch on to a good mentor seemed to get the guidance they needed. A beginners hackathon should make sure they have not only plenty of mentors but they should make sure that the mentors are prepped with a number of project ideas in a number of the standard beginner platforms. A hackathon could also provide an assortment of ideas in a list.

The second thing I noticed was at the end of the day as I was judging. It started with one particular group. They were pretty apologetic about their project. Basically because it wasn't finished. Personally, I thought what they accomplished in essentially 7 hours was pretty impressive. What became clear as we talked is that this group was deathly afraid of failure. Their deepest fear at that moment was that I was going to give them high marks and they might have to show off their incomplete (yet rather impressive) project to a room full of strangers.

This fear of failure was prevalent in groups that ultimately didn't submit their projects for judging and it seemed to be common among students from high performing, high expectation schools where frequently one associates a test score or grade with ones value. I'm not happy to say that Stuy has always had this problem.

This isn't really a problem that a hackathon can or should be able to address. It's just something I noticed. It's a problem for schools and also for a society that's test obsessed.

I hope nobody reads too much into these observations. The day was a tremendous success. A whole bunch of kids had a great day working together to build cool things with technology. Congratulations to the StuyHacks team. They did a terrific job putting it all together. If you're a middle or high school student or know one, keep an eye on the StuyHacks web page and make sure to attend their next event.

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. To make it a little more interesting, the last digit wraps around to the first for checksum purposes.

For example, the input 2234335 leads to the calculate 2 + 3 or 5. The input 234445662 leads to 4+4+6+2 or 16. We add 4 for twice because the first four is adjacent the second and the second the third. We add the 2 at the end because it wraps around to match the one at the front.

We first read in the data and strip off the trailing newline

f = open("input.txt")
origdata = f.readline()

origdata = origdata.strip()
data = origdata

Then, since we can access the elements of the string as a list (or array) it's a simple loop to calculate the sum:

s = 0
l = len(data)
for i in range(l-1):
    if data[i]==data[i+1]:
	s = s + int(data[i]) # Don't forget to turn the string into an int

# data[-1] is the python way of getting the last element - here we check the wraparound
if data[0] == data[-1]:
    s = s + int(data[0])
print("Checksum: ",s)

Pretty straightforward but I don't like the special case of checking the last element for the wraparound. Sometimes it's possible to get rid of edge cases like this by changing the data. We can do that here by simply appending a copy of the first character to the end of the list.

This leads to a slightly cleaner solution:

data = data + data[0]

s = 0
l = len(data)
for i in range(l-1):
    if data[i]==data[i+1]:
	s = s + int(data[i]) #don't forget to turn the string into an int
print("Checksum: ",s)

This is pretty much what I'd expect from a Python programmer that's just starting out. We can use a couple of more advanced Python features to make what I consider a more elegant solution.

Python's zip function takes two lists and interleaves them. zip("abc","def") will yield [ (a,d), (b,e), (c,f)]. If the lists are of different length, it just zips up until the shorter list is exhausted. We can use array slicing to zip the input string with it's neighbor by using new_list = zip(data,data[1:]). For the string "122344' zipping gives us [(1,2),(2,2),(2,3),(3,4),(4,4)]. We can put this in a list comprehension that only keeps the tuples representing an element with an identical neighbor and also converts it to an int: new_list = [int(a) for a,b in new_list if a==b].

Finally, we can just calculate the sum. This leads to the following complete solution:

f = open("input.txt")
data = f.readline().strip()
data = data + data[0]

checksum= sum([ int(a) for a,b in zip(data,data[1:]) if a==b])


List comprehensions for the win!!!!

Each Advent of Code problem has two parts. You unlock the second by solving the first. Here, the wrinkle is that instead of checking each digit with it's neighbor to the right, you check it with the one that's halfway around the list.

With loops, the solution is just a quick modification of part 1. We just add half the length and use mod to find the digit to compare with:

f = open("input.txt")
data = f.readline().strip()
data = data + data[0]

s = 0
l = len(data)
for i in range(l-1):
    if data[i]==data[(i+l//2)%l]: # check halfway around instead of adjacent
	s = s + int(data[i])
print("part 2loop version: ",s)

I wanted to see if I could do this with a list comprehension though. The trick was to figure out how to make two lists to zip together to get the pairs to check then add. Here's the solution:

f = open("input.txt")
data = f.readline().strip()
l = len(data)
d2 = data[l//2:]+data
checksum = sum([ int(a) for a,b in zip(data,d2)if a==b])

The insight was that we could just make a second list that starts halfway through and then wraps around. I did this by adding data[l//2:] + data. l//2 is the integer division of the length (in Python3). data[l//2:] represents the second half of data (from the midway point to the end). Technically I should have only added the second half of data: data[l//2:] + data[:l//2] where data[:l//2] gives us the first half of the list but since zip will just stop when it exhausts the shorter list, this wasn't necessary.

Day 2 also has a nice list comprehension based solution. Maybe I'll write that up later.

You have to trust the kids

A week or so ago I wrote about the event we had to kick off Hunter College's partnering with the NY tech community to build a Hunter to tech pipeline. Each table had two Hunter students and a group of tech professionals. Each table discussed the Hunter CS experience and how the tech community can help support the students. Towards the end of the event a colleague commented that it was a great idea to have the students essentially run the tables and how effective it was. I didn't see any other way to do it.

You have to trust the students. Put them in situations where they can grow.

In addition to the event being a success overall, I think that for the students it helped to break down barriers. These kids are soon to be joining the tech community. They'll be interviewing for internships and then jobs and the whole process can be rather intimidating. By the end of the event the other week, there weren't tables of students and professionals but rather tables of people all having discussions on equal footing. It seems like a small thing. A minor choice on how to run an event but it can have a subtle but substantial impact in ways that are hard to see unless you look.

I was also reminded of this when reading Alfred Thompson's post on school tech management teams and CS teachers. Alfred wrote about the possible tension between the needs of CS teachers and the needs of the rest of the school and the obligations of the people that actually set up and maintain the technology in a school.

Years ago, at Stuy, I skirted the issue by taking on the obligation of maintaining my own labs. This let me run Linux and basically do whatever I felt we needed. It also meant my labs wouldn't be set up for things like standardized testing. This came at a price. I had to maintain it all myself. This is not to say that the tech people haven't helped over the years. Some of them have been terrific but other than swapping out bad machines it all fell on me.

Of course this wouldn't have been possible if it really all fell to me. It only worked because I was able to enlist the aid of students who wanted to learn about building and running a Linux network. Sure I showed them some things but largely we figured it out together. Basically I trusted the kids with access and control and gave them a safe place to learn and explore.

It worked amazingly well.

Of course there were plenty of headaches. There was the time when we only had one AI/X server for the school and Jon somehow erased all the shared libraries or the time when I think Paul or Ilya took away read and execute access from all the system executables. I lost plenty of sleep and pulled out much hair recovering from these messes and others but I couldn't get too upset. They were learning, no one got hurt, and truthfully they never committed any blunders worse than my own.

Giving up control to the kids can be nerve wracking at times but it's worth it. It's why I always found coaching more stressful than competing back when I fenced. You can do everything to prepare your athletes but when they're out on the strip, there's nothing you can do to help. It's all on them. On the other hand, I've always been more gratified with my athletes or students successes than with my own. There's something special about enabling others.

This is not to say that we just turn our students loose. We have to set our students up to succeed. Set up the environment and the circumstance and give the students the tools to work with. At the event two weeks ago I knew that everyone in the room was a friend or when I have students plan a hackathon and have them cold call a company, maybe the company expects the call. There are all sorts of things we can do behind the scenes to set out students up for success.

We set the stage and if we do it right, the kids won't fail to impress.

Reunion Season

Thanksgiving is reunion season. Stuyvesant and I'm guessing other high schools traditionally hold their reunions, at least the five and ten year ones over the holiday weekend. It makes sense since grads who've moved away might still be coming to town for family celebrations.

This year, I was invited to the Stuy07 ten year reunion. I considered crashing the Stuy97 20 year but it was at the same time and too far away.

I'm always really flattered and honored when I get a reunion invite. I've been to my share but I was never the hip popular teacher that gets invited to these things. On the other hand, I'm sincere, honest, and loyal so when I do connect with students it's meaningful and lasting. As one of my students remarked when I was nominated to be graduation speaker a few years ago and I doubted I would be elected "hey, you lead the most popular cult in the school" and I guess in some way the community is a cult, or as I'd rather say, a family. In any event, whenever I'm invited to a reunion I make my best effort to attend.

I find the role of faculty at reunions as somewhat amusing – we're something of a prop. The grads are there and should be there to reconnect with each other. The teachers are and should be secondary. From my point of view, there are three groups of students. The ones that are now part of my alumni family - now friends who I'm in touch with to varying degrees, the ones that never knew me and the ones that knew me a bit. For the second and third groups, as a faculty member, I'm there to remind them of the glory days as a representative of the institution.

As with all reunions I had plenty of "I was never in your class but …" conversations. I also a number of "I majored in fill-in-the-blank but just found my way back into tech so….. thanks." I love these conversations - it gets someone new into "the family." I also had one conversation that was really a nice ego boost. One of my guys introduced me to his wife. She immediately exclaimed "it's so great to finally meet you, he talks about you all the time!" That was kind of weird until she went on "…every time he talks about Stuy." That made more sense. It's like all those times when me and my buddy Ben would reminisce about our Junior High school days and we'd always get back to talking about Herb, one of our best and favorite teachers and a major influence on me while Devorah looked on confused. Eventually she met and got to know Herb and it all made sense. Another grad added "you think we all forget about you but you come up more than you know" so I take that as a shout out to all of the teachers out there who never get to hear back about how much they are remembered and appreciated.

With tools like email and Facebook it's easier to remain connected to former students but it's always nice to connect in person. For the StuyCS family, we have our periodic meetups but for the rest, I love being included in class reunions and hope to be invited to more in years to come.

Using Emacs 38 - dired

The 38th installment of Using Emacs is about dired, Emacs' built in mode for navigating and working with directories.

I'm not a dired power user and in fact am just now making a real effort to explore it and work it into my daily workflow and with that in mind, I'd love to hear some configuration and use suggestions from people who use it regularly.

Here's the configuration I use:

(use-package dired+
  :ensure t
  :config (require 'dired+)

which merely adds dired+ into the mix.

I also started playing with pcre2el which allows me to use the more usual regex syntax in place of Emacs regex syntax in both dired and other places. This is a big win for me since I never remember all the escaping rules for Emacs regex.

(use-package pcre2el
:ensure t

Finally, abo-abo and jcs have both written about new features in , Ivy/Swiper/Counsel that allow you to use ivy-occur to dump results into a dired buffer (link, link) but to get that to work, I needed to install wgrep and also had to install and setup fzf which looks to be useful.

  (use-package wgrep
    :ensure t

(setq counsel-fzf-cmd "/home/zamansky/.fzf/bin/fzf -f %s")

To help get started here are links to a couple of cheat sheets:

I'll probably use dired more frequently but again, would love to hear how other people are using it.

<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>

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. The first solution was n2 and then refined to a quickselect. This led directly to the quicksort.

I liked the lesson and I think it worked well when I taught it but that was partly due to the overall tenor of that particular group of students.

A similar approach develops the quicksort in a similar way but is both more direct and accessible.

The motivating problem is to put one item in a data set in its proper place. You could select one person in class and arrange the class so that the selected student is in their proper size place, that is everyone shorter on one side, taller on the other. You could also do this for age. A similar exercise could be done with any number of manipulatives.

This operation of arranging the rest of the set around one selected item or person is very easy and in fact it's trivial to show that this can be done in linear time.

Once we've done this arrangement, we can discuss what we can infer from this new arrangement. We can now tell that:

  • everyone to the left of the "pivot" is less than the pivot
  • everyone to the right is greater
  • The pivot element is at its true location if the list were sorted. That is, if we started arranging around item k, then we've moved item k to the kth location in the dataset.

From here it's a small jump to the quicksort algorithm, just repeat the process on the left and right data sets.

This approach not only makes the algorithm and its development clear and simple but it also can be used to illustrate the worst case n2 behavior.

The whole thing, minus the coding, can also be done as an unplugged activity.

In case anyone's interested, I also wrote a post on subtle implementation errors when writing the quicksort (here) and also looking at the qucksort from the point of view of different programming paradigms (here).


Hunter CS and NY Tech - it takes a village


Figure 1: The NY Tech community and Hunter CS at Yext

One of my goals when I came over to Hunter was to help establish Hunter CS as the place to be for CS in the city. Hunter already had a solid CS program before I joined but it isn't well known. It also doesn't have an established tech culture.

It's an ambitious goal but if it can be done, what a game changer. A lot of people talk about equity, diversity, and social justice but if we can establish Hunter as the place to be for CS in NY, what a win. An affordable, accessible institution where you can get a great CS education.

The truth of course is that I can't accomplish this - at least not by myself. I'm just one person. Fortunately, there are so many wonderful people in the New York Tech community that want to help bring opportunities to the kids.

Last Thursday evening we got the ball rolling. Twenty five representatives from the tech community got together at Yext with about a dozen of our Hunter College CS students. The conversation started with a discussion of perceptions of Hunter and the students sharing what their experiences were like. By the end we were all brainstorming as to how we can work together to best prepare Hunter students to become members of the New York Tech community.

I know the students left the evening energized and I did as well. I hope our friends in Tech felt the same.


Figure 2: Max talking about Hunter to Jess and the rest of the table

We had representatives from (in alphabetical order)

  • Animoto
  • Beeswax
  • Bloomberg
  • Civic Hall
  • eBay
  • Genacast Ventures
  • Google
  • JW Player
  • Meetup
  • MongoDB
  • Motivate (Citbike)
  • Quentin Road Ventures
  • Twitter
  • Two Sigma
  • Union Square Ventures
  • Workbench
  • Yext

at the event and then there were plenty of people who want to be part of this who couldn't make it on Thursday.

I told the participants at the event that I can't make this happen. I can merely get the people together who actually can. I'm grateful to all my friends who are now a part of this and I'm looking forward to working with them, my students and my colleagues to create a Hunter CS to Tech Community pipeline that's second to none.

Moocs - High Production value, Bad Questions

Most mornings, I start my day with a workout. Sometimes I run, sometimes I use my bike trainer. Dealing with plantar fasciitis since last June, it's mostly been the bike.

I occupy the time by either watching YouTube videos or catching up on Communications of the ACM or American Scientist. I'm about 6 months behind on both.

Inspired by some talk in one of the CS Ed Facebook groups, I thought I'd use the time to start going through some MOOCs. I started with Udacity's Intro to Information Security.

I'm only in lesson 4 but it's pretty light weight and generally well presented but I keep seeing the same thing that pisses me off about moocs. At the end of the day the video is just a lecture and what's worse, a lecture with no feedback loop.

Don't get me wrong, I love the fact that Udacity and the others have their material up online and that I can get to it free of charge but I don't love the fact there are people that still believe putting a computer in front of a kid is better than a teacher.

I think this quiz question is pretty representative of what I'm talking about.


Figure 1: Typically bad mooc question

It's just a silly inline quiz question and not a particularly important one but it pisses me off.

To start with, it uses the word could not did. That means that every answer is correct. In fact an asnwer choice like "we're more secure because we have this really good engineer named Stanley" could be given and would be a correct answer since the vendor could base their claim on Stanley's awesomness, it would just be a bad idea. Unless you remember the specific ad campaign, you won't know the answer and even if you did, internally, they could use any justification they want.

It reminds me of when my brother was in grade school and he had a test question of:

Can you name all 50 states in the United States of America?

My brother's answer was "no." He was correct. I don't remember if the teacher agreed.

To be fair, I'm just watching the videos and it's possible that the readings clarified the question but even so, this is a very bad question.

Yes, it's just a silly quiz but it is indicative of the problem with any online learning resource and I and I'm sure others find it frustrating.

I don't want to come down hard on the lecturer or whomever made the quiz question. In a class I might ask a question poorly but I have an immediate feedback loop and can fix things right then and there. Frustration doesn't build and in the case of holes in important conceptual material deficiencies don't develop.

I also don't want to come down on free resources that I use and benefit from.

These types of issues seem small and the autodidacts that succeed in using MOOCS work around them but if you look at these materials critically as a teacher it's plain to see that their no substitute for the real thing.

Professional Development beyond Scratch

Today was Election Day. One of the few days each year when students stay home and teachers spend all day attending what is generously known as professional development.

Years ago I was in a room with a few colleagues when my friend Dave - one of the best math teachers I know said "you know, every time we have a PD day in NJ and my wife and I have to scramble to take care of the kids I get a little annoyed but then think I shouldn't get annoyed since they're spending the day doing all sorts of valuable PD." He then said "but then I realize that their PD is probably about as useful as our PD and I get really angry."

There you have it. This is not to say that there is no good PD but it seems that the professional development opportunities provided by our schools have over the years ranged from useless to insulting with maybe a small bright spot here and there. Historically it's been worse for CS teachers because we get lumped in with math teachers and have to spend the day learning about tools and techniques we'll never use or discussing curricula we never teach.

So, when I spoke to JonAlf about rescuing the Stuy teachers for the day and hosting them at Hunter, he and the other CS teachers were pretty excited. It wasn't as though I had the magic PD answer but I was going to provide a space and we'd figure out together what would be productive and valuable for them.

As it turns out, I've been spending a good amount of time these past few weeks visiting high schools to talk about Hunter CS and when I was at Bronx Science the topic of Election Day PD came up and I thought that it would be nice to get the Bronx Science and Stuy teachers together. After thinking about it more, I recalled that there were few good PD opportunities for CS teachers who taught advanced classes as opposed to all the CS PD floating around these days at more of a beginner level.

I thought that we could change this. In the end, I hosted PD today and had teachers from Stuyvesant, Bronx Science, Brooklyn Tech, and the Manhattan Hunter Science High School in attendance. I invited teachers from a few more schools but in the end we had those four schools and seventeen teachers.

The original agenda was:

  • 09:00 - 10:00 : Each school describes it's program and courses
  • 10:00 - 11:00 : An intro to Git and GitHub for the classroom
  • 10:00 - 11:45 : Sharing neat lessons
  • 11:45 - 12:00 : Presentation by ChickTech
  • 12:00 - 01:00 : Lunch
  • 01:00 - End : Small group lesson and curriculum work

Oh boy did I mess up on the timing. The description and discussion of school programs took all morning. It was interesting to hear how each school's program evolved and how they fit into the school's culture. Brooklyn Tech, for instance is a school where students declare majors. This has a big impact on what classes kids have to take and are able to take. This is very different from Stuy or Science where kids programs are more open ended or MHSHS which is a much smaller school and has restrictions related to size. It was also interesting to note Brooklyn Tech's decision to have every student take APCS-P. Interesting because Brooklyn Tech is one of the country's largest high schools and most of them should have done well on the exam. That gave NYC around 1,400 passing AP scores in one shot. On the other hand none of the other schools present today offered APCS-P but did have their own intro CS class that students took prior to APCS-A.

We finished the morning with a visit by Heather from ChickTech. ChickTech is a non-profit dedicated to retaining women in Tech. It works with both girls in K12 and also those in industry. My hope was to get a conversation started and see if there were some potential avenues of partnership between the organization and the schools.

After lunch, the group decided that we should do the Git/GitHub workshop and JonAlf obliged.

Overall I think the day was a success.

My hope is that today's attendees can form a core group of CS teachers who teach more advanced courses and we can form something of a support group for each other.

I plan to try to facilitate future meetings and hopefully we'll be able to attract more teachers to our group.

All in all I'm very happy with how the day went.

Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative