Programming Puzzle 2: Airline Routes

by Mike Gleicher on October 16, 2015

in Assignments,News

Edit 10/18/2015 – I am giving you my solution from the start, since it may make the instructions less confusing. But try to do it yourself before looking at my code.

Warning – this is a lot bigger than the previous puzzle.

Write a program that…

  1. Allows the user to add a pair of cities (that are connected by a flight). Note: it doesn’t make a difference what order the flight is specified in. (so if I say “MSN <-> NYC” or “NYC <-> MSN” it doesn’t matter – there is an assumption that routes are bi-directional). (better feature: You should prevent the user from adding redundant route.)
  2. Shows a list of all of the direct routes.
  3. Creates a list of cities for which there are routes – as buttons (or some widget).
  4. When you click on the button for a city, it shows all of the places that connect to that city. For example, it could light up everything on the list of routes that was a destination you could reach from the city.
  5. Fancier feature – also show all the things that are two hops. For example, you could use one color to show the directly accessible cities, and two colors to do the two hop cities, …

A few ground rules…

  1. Don’t use jQuery. If you know jQuery already, this will be a good lesson for why things like jQuery are more useful. If you’re able to use jQuery, use your JavaScript prowess in a manner that will be good demonstrations for others.
  2. Simple first, fancy later.
  3. Try first, but then seek help before you get too stuck. This time I will post a (not so great, but functioning) solution before the deadline (but after you had a chance to think about it), so you’ll have at least something to look at.
  4. If you’re stuck – post a question, not broken code. If your bug was easy, you would have found it. Finding someone else’s hard bug is hard. It’s a worthwhile skill to have. But you can’t count on that much generosity from people.
  5. It’s a team effort – the goal is that everyone learns to do it. Just because you got it easily doesn’t mean the “team” has succeeded. I don’t know how to put this into mechanism (I was thinking that your grade requires everyone in your group to succeed, but that doesn’t quite work).
  6. Use good development tools. I was going to say “don’t use JSBin” – but JSBin actually has some advantages (it has syntax and style checking, allows for rapid feedback). I think it’s better to start using some pro-level tools (go see that posting for ideas). I recommend investing some time in learning the tools.
  7. You are encouraged to submit improved versions of your program! If you submit a version that works on the first Monday, submit a better version later. Please don’t delete the posting with your initial submission (although, if you want to edit it to say “this is an old version, look below for the newer one” that might be helpful. If you submit a broken version, submit a better one later. We probably need some better mechanism for turning in multiple versions. But for now, we’ll try to just use postings in the Canvas discussion.
  8. I will post my solution – to each of the group discussions – sometime after Monday (maybe Tuesday after class). So you’ll have at least one to look at. I have posted my solution. Use it to see what is intended. You can look at the code if you get stuck, but my code is ugly. My program is in “my handin directory” https://pages.cs.wisc.edu/~cs638-1/handin2015/Puzzle2/gleicher/airroutes.html (note, like all handin directories, you must authenticate to the CS servers in order to see stuff).

The mechanisms:

  1. I will provide a place for you to host your solutions on the CS web server. We ran into a snag, so I can’t tell you about it yet. Hopefully we’ll have it soon. In your posting, you can post a link to your assignment in this space. Or (for this assignment at least) you can turn things in via JSBin.
  2. Once again, we’ll use a discussion forum on Canvas. It’s not perfect, but it seems to work again. There will be a time by which everyone must have made an initial posting. Then another round of time for help. Hopefully, everyone won’t wait until the last minute before asking for help (or going to provide it).
  3. When we “grade” we will check to see that people really did interact with others. You must make more than 2-3 (good) postings. Asking a good question is a good posting. Answering a good question is a good posting. Giving someone constructive feedback on their program is a good posting. (of course it’s pass fail, so we have little in terms of rewards – but the gratitude of your classmates and the extra learning you get should be its own reward).

The schedule:

  • Initial posting due – Monday, October 19th. By Midnight. Yes, I realize lots of people will do it at the last minute, so not a lot of dialog will happen before class on Tuesday. But, since this assignment is going out late, … The most important thing is that everyone at least looks at the assignment enough that we can play the index-card game again on Tuesday.
  • At least 1-2 iterations after the original – Friday, October 23rd. By Friday, everyone should have “gotten it” – if you got it originally on Monday, you should have ideas on how to make it better – so have an improved version.
  • At least 2-3 comments on other people’s assignments – Monday, October 26th.

For the initial hand-in, I suspect that some people will get it and turn that in. Many people will get stuck – which is OK. When you get stuck, post a question. And come to class with an idea of a question to either ask or write on an index card. Over the course of the week, I hope that the collaborative learning thing will work, and by Friday, everyone will have a solution to the problem. And then over the weekend, you can give each other feedback.

The Canvas discussion thread is: here. Some commentary about how programming puzzles should work is here.

Print Friendly, PDF & Email

{ 1 trackback }

Previous post:

Next post: