Category Archives: Programming

Too many languages…

Well, I completely fell apart on that promise… Oh well. Just a quick recap: I graduated, but only one of my degrees has so far been approved (Physics, my secondary degree), so I’ll have a fun meeting later this week in East Lansing to sort that out. Why will I be in East Lansing? I’ll be swinging through on my way down to South Bend to begin my trek for a PhD at Notre Dame. I’ve also spent my few weeks off doing nothing and something at the same time: pounding through episodes of Doctor Who, preparing to move, playing disc golf, and programming.

Yep, programming. I haven’t forgot about you yet! A month ago, I knew the following languages: Python, C/C++, Fortran, and shell scripting (if it’s kosher to include that last one), in roughly that order of fluency. But hey, you can never have enough languages, right? Plus, I might as well start programming for a purpose and not just for fun (although I’m still going to program for fun, of course!). With that in mind, I’m venturing out into a few new fields.

While technically I have already learned some HTML and CSS, it was never really in a structured manner. I just looked at source code from websites I liked and tried to piece it all together. In general, it worked for what I needed, but it doesn’t hold a candle to what’s out there. So, I’m going to actually sit down and learn the new standard, update my website (but at my fancy, new ND webspace!), and officially add it to my list.

ObjectiveC with Cocoa
For all you Mac-philes out there, this is the language for applications on your lovely Macbook Pro, as well as on the various iDevices that Apple sells. This is the language I’ve worked with the most so far, mostly because I figured that my knowledge of C/C++ would help out on the coding side of things. Plus, making my own applications has been in the back of my mind for a while…

Again, another useful language, only this time for Android devices. Right now, I’m still deciding between what phone to get once I leave AT&T, and since Verizon has both the iPhone and various Droids, I might as well learn both. Plus, since I’m pretty equal opportunity myself, I’d probably write an app in both languages and release it simultaneously for when I get to that point. And hey, another language is another language, especially when I can use this for other things as well. I haven’t even started working with this one yet, though, since the download of the Android SDK took longer than I would’ve liked, plus I’m doing other things with my time too…

Aside from that, I’m still writing a lot of Python (I got bored the other day and started writing a UNIX-like shell in python), since for me it’s the most fun. Plus, the only “learning” I have to do for it is looking up different function calls that I can use for the various modules; I get to focus more on the coding than anything else! Of course, in two weeks, I’ll be starting my summer course down at ND, so programming will again slow down for a bit, but I would mind, given what I’ll be working on!

EDIT | After reading a few articles and posts online, I’ve decided to refocus on just a few of my languages for now. I’ve decided that my first “real” phone will be a droid, but I’m not really keen to start programming for it until I see what’s out there. I’m still slowing going through the ObjC+Cocoa book, but I’m guessing that at the end of it I will be left with very little direction and only a cursory understanding of the language. Not good when a two-month hiatus is upon me. So, I’ve decided to get really fluent in Python and C; the Python portion will just be trying to learn those little things that I never encountered (like generators when discussing the Collatz conjecture HERE and HERE) or simply just different things to do with the language (like Google webapps…). Anyway, hopefully this will help save my brain while I relearn all of undergrad physics in two months!

Grad School Visits

This past week for Spring Break, I spent time with my family and visited the two grad schools I have currently been accepted to: the University of Notre Dame and the University of Connecticut, Storrs. While I’m still waiting to hear back from one school and a job opportunity, both of them were relative long shots, so it looks like my summer and fall (and the next five or so years…) has boiled down to a binary choice: ND or UConn?

This was the first school I visited, and man did things go well! Ms. Shari Herman, the “Second Mom” to everyone pursuing a physics Ph.D. at ND, took out all of the stops in setting up a stellar visit for me. I drove down Monday afternoon, right after picking my little brother up from school and visiting with my high school physics teacher, and it went fine. No traffic, I had money for the tolls, and I found my way to the hotel (the Morris Inn, right on ND’s campus) relatively fine. Once I checked in, I hung out in my hotel room, watching TV and lamenting the fact that I could not yet play Pokémon Black.

I woke up the next morning, showered, ate breakfast, and read through the packet of material that Ms. Herman had given me, then checked out and waited for the actual visit to start. I met one of the roughly 90 grad students, and we took a quick tour around campus before my meeting with the first professor on my schedule. Since this was my first time ever visiting ND, it was great to walk around and see the campus, especially with the student body still there since they weren’t on spring break. We eventually made our way over to Nieuwland Science Hall, home of the department and where I would be spending the next nine hours or so.

For the rest of the day, I went from visiting one professor to the next, sitting down and talking for half an hour about the research they were doing, different things going on around campus, how they got involved with ND and physics, and a bunch of other things. I also got a tour of the nuclear physics accelerator lab, got to sit in on a cosmology seminar (with a free lunch!), and got a glimpse of what I’d be doing my first year of school in the form of the grad TA first year lounge (alongside the end of my career with a few fourth- and fifth-years). All in all, a very full day that got added to twice while I was still there!

To end it, I went out to dinner with two other grad students to Legends, a local bar/restaurant establishment just off campus, all on the physics department’s tab. The food was great, and I didn’t really have to stop on the way back for any more food (huge surprise, but I did have a detour right at the beginning of my return journey…), and I had a good time just hanging out away from the more structured environment I had been in for much of the day. All in all, I had a great time, met some amazing people, and really enjoyed myself while I was there. I got back home around midnight, played some Pokémon Black, then went to sleep.

The next and final trip (so far…) was out to Connecticut to visit the department at UConn. I flew out from Detroit early Friday morning after delays on the runway from some of the freshly fallen snow from the night before. Once we took off, though, the flight was fine, the landing smooth, and the pick-up of the rental car (a relatively new Jeep Compass!) went perfectly. But I was still a little late due to that delay, so I showed up to the offices slightly out of breath from sprinting up the flights of stairs to the top of the building. Thankfully, Prof. Dunne (the person who had set up this visitation) didn’t seem to mind, and we talked before meeting a few grad students and heading out to lunch. Since UConn was on spring break, we didn’t really run into any students at all, but the campus was flooded with middle- and high-school students for some convention, so we still had to contend with a mass of hormone-infused saplings as we ate our meal.

Once the last of my meatball sub was firmly in my stomach, we took a quick tour around campus, which was beautiful! It reminded me a lot of State, since it was a little more open, a little disjointed, roads crossed through and around the buildings, and a couple places were under construction, so I felt right at home! While the campus was much quieter during this tour than ND had been, that was good since I could just focus on the buildings and the scenery and not look at the the students walking past.

We returned to the physics building, and I sat with a half-dozen professors to talk about their research to see how it would fit with my interests, just like at ND. Once that was over, I met again with Prof. Dunne to finalize a few things, then I was off to return the rental car to the airport and spend time with my relatives. I won’t go into that since this is about my grad school visits, but just know that I had a blast, and that it more than made up for missing last summer’s reunion.

From today, I have thirty days to wait for the last few pieces of information and make a decision, although I’m sure that I will be making a decision earlier than that. Unfortunately, ND lost to Louisville during the Big East tourney, so I couldn’t use the outcome of the ND-UConn championship game to make the decision for me!

Game Redux

Remember when I said that I was creating a video game in my spare time? Well, if eight months of inactivity has told you anything, that hasn’t exactly gone to plan for a number of reasons, some of which are programming related (see my last post).

I am happy to say that I’ve gotten back into writing a video game, although as usual the story is completely different, as is my approach to writing the game. Instead of working on visual mechanics like smooth scrolling of the screen and animation of the character sprite, I’m worrying about inventory interaction and item alterations, all of which are done through a network of interconnected modules and classes. It’s a much cleaner approach, plus it’s much easier to test sets of class methods when that’s all I’m working with.

I’m taking a very micro-to-macro approach too, starting with single items, moving onto inventory, moving onto a character shell (which will eventually be greatly inflated, but no need to worry about that now!). Yes, a few important things are missing from the small set of code I have written (items having a special effect on the character or other items, for example), but much of that will flow once I figure out how I want the game to progress. Check out the two (partial) modules I have now:

# Superclass for all in-Game Items
class Item(object):
  def __init__(self, name, amount=1): = name
    self.amount = amount

  def adjust_amount(self, amount):
    self.amount += amount

# Subclass to handle key items
class KeyItem(Item):
  def adjust_amount(self, amount):

# Class to store Items for Player within Game
class Inventory(object):
  def __init__(self):
    self.inventory = []

  def add_item(self, item):

  def remove_item(self, item):

  def adjust_item(self, item, amount):
    changing_item = self.inventory[self.inventory.index(item)]
    if changing_item.amount == 0:

  def order_inventory(self, item, new_position):
    temp = self.inventory[self.inventory.index(item)]
    self.inventory.insert(new_position, temp)
# Creates Player class to be controlled by user
class Player(object):
  def __init__(self, name, inventory): = name = 500
    self.inventory = inventory

  def adjust_money(self, amount): += amount

  # Controls inventory object changes
  def adjust_inventory(self, item, amount=1):
    if item in self.inventory.inventory:
    self.inventory.adjust_item(item, amount)

  def change_inventory(self, item, new_position):
    self.inventory.order_inventory(item, new_position)

Pretty simple, and only 40 lines when you ignore whitespace and comments, but the fact that everything works the way I want it to right now is a big deal. I could throw in a few other necessary variables and function calls right now, but I do have my first exam of the semester in… six hours… so I’ll just leave this here for now.

In bashnews, I fixed a problem with grep where no matter what I did, grep just didn’t work. It ended up being some extraneous commands in my .bash_profile that I must have put in while adding aliases and setting the color scheme for ls -G, since the commands came right after those lines. Now it works, and I’m back to being a happy camper!

Graduation Drawing Near

It’s already February. Not such a scary thought, except when you consider that in two-and-a-half months’ time I’ll know what I’ll be doing for at least the next four years, and in three months’ time I’ll have graduated. Right now, I’m just trying to make it through the semester that’s ahead of me, but with the prospect of the rest of my life looming ahead, it’s a little hard to focus. Here’s a few things that are distracting me:

Yep, the sport from Harry Potter. I joined one of the intramural teams this past fall, which has been great, and spent three hours in the sixteen-some inches of snow for tryouts for the travel team. The game is exceedingly fun to play, and it always garners a barrage of questions whenever it comes up that I play (wherever I may be at the time). It’s also pretty funny to look at the strange looks employees give me when I walk into, say, McDonald’s holding a broom in one hand and cleats in the other. With practices only once a week (or more, depending if my tryouts today went favorably), and games pretty infrequent, it doesn’t take up as much time as that other MSU sport I played, not like these semester grades mean that much anyway…

Here’s a State News article about the team following the World Cup (held in November in New York), and a video of the team playing Syracuse. Since I joined late, I wasn’t there, but hopefully I can go this upcoming fall, depending on what happens in my life.

I’m teaching myself C++! Why, might you ask? Well, I figured that, since I’ll eventually have to learn it anyway, I might as well. That of course was my initial reasoning, but now it’s also because I can get a job programming in C++, which will definitely help me out in the long run. Right now, I have two books on the subject, with one of them arriving earlier today (Programming Embedded Systems in C and C++ by Michael Barr). I haven’t started reading that one yet, since I’m still in the middle of my other book, but most likely I’ll flip back and forth between the two, especially since large sections of my first book were covered in one of my math courses last semester.

To go along with that, I’m still slowly working on my senior thesis. It’s just frustrating when scientific papers don’t include all of the details of their simulation runs, like what initial or final values they’re using for such uncommon variables as time or temperature, so I’ve been busy sifting through about a half-dozen articles trying to piece together some idea of how to move forward. Yes, I’m a little behind, but once I find those magic numbers, I just need to set it up and go and move on. In other words, mostly because of my newfound enjoyment of C/C++, I don’t like Fortran that much any more…

Grad School Applications
While all of my applications have been in for at least a month, that doesn’t mean that they aren’t still at the back of my mind all of the time. This is half of where my life might lead me, so it’s a big deal! I did, however, breathe a sigh of relief earlier this week when I found out that I was accepted into the Notre Dame Physics PhD program, meaning that at the very least I won’t be moving back home upon graduation! It actually kind of surprised me that I got wind of it so soon, but I think that it was just part of their first-round “draft picks,” as at least one of my other friends was also accepted.

Job Opportunities
Well, the last three things all hinted at this, but I may not be going to grad school come summer/fall. Obviously, that won’t be because I didn’t get in anywhere, but more a change in who I am as a person over the past two months (yes, the change was that quick!). You see, I’m not sure if grad school is something that I want to do right away, and what could I get out of it? A lot, in fact, but I’m not sure if I will still want what I get out of it when I get out of it. To that end, I’ve applied to a job that fits with all of my likes and dislikes, strengths and weaknesses, hopes and dreams, etc. that I may take (if accepted) over grad school. I’m not going to mention that job here, but if you’ve talked to me recently you know what it is. I just think that, right now, being a commercial programmer for a growing company involved in one of my biggest interests may be a better prospect than continuing on in school.

Don’t get me wrong, though! I’ll still go to grad school eventually, just further down the road after working, and probably in a different field. I do think that continuing my education is important (hence teaching myself an additional programming language in my spare time), and I don’t plan to ever stop learning.

I’ll just be learning in a different way.

In other news, today is now the one-year anniversary of the end of my Mars Desert Research Station mission. It’s strange to think that a year ago I was leaving the Hab with five other people who had become family for good, after spending two weeks working and laughing and enjoying Carla’s amazing cooking. I wouldn’t trade that experience for anything in the world.

Simple Semester Start

After trudging through my first week of classes, I finally feel like I’m prepped and ready to discuss what has happened to me since the new year and my thoughts on my last semester of study at Michigan State University. I knew that this time would come eventually, but it just feels harder than I had imagined, for numerous reasons that may become known through this post. First, though, let’s talk academics…

AST 410 – Astrophysics Senior Thesis
Work on my thesis went somewhat smoothly over break, with a lot of simulation runs to get a better feel for how long full net calculations would talk, adjusting initial parameters, and writing two auxiliary Python scripts for the projects (a short timing procedure and a data graph creator). I also looked up a handful of articles on the subject of computational nucleosynthesis, primarily to refine my data for densities, temperatures, and times, especially since I have started using non-constant parameters for those quantities. Of course, I still need to talk to my advisor for the first time this semester, but that will most likely come later this week or early next, once I read a few more papers and run some more simulations.

KIN 102K – Tae Kwon Do I
My fabled final credit to get two degrees, this class is my first and only fun course at MSU. Before this, I was taking 16-18 credits a semester of all academics, but as a second semester senior with not much else on my plate (and only having 149 total credits before this), I added it midway through last semester. While we’ve only had one real class (past syllabus day), and we haven’t started doing any actual Tae Kwon Do, I know that I’ll like this class and I know it will be amazing. I’m also glad that this will help kick-start my working out, since that usually falls by the wayside when classes get tough.

MTH 415 – Applied Linear Algebra
Based on what we’ve covered so far, what I remember from Linear Algebra I two years ago, and what was covered in Numerical Analysis last semester, this may be my easiest class this semester. Of course, with the schedule that I happened to wrangle up, that’s not saying much. I’m not worried at all.

MTH 442 – Partial Differential Equations
While ODEs were covered in Calc II for me, I don’t really remember it. My only exposure to PDEs has been through my two Quantum courses, but there is was basically just knowing which of two memorized solutions to use in the problem. From what we’ve done in class so far, this shouldn’t be too tough, but I’ll definitely need to keep an eye on it to make sure things don’t move forward too quickly.

PHY 451 – Advanced Laboratory
After a small mix-up that I’m rectifying in a few hours, this class will be interesting to say the least. I’ll only be doing two labs the entire semester, with the same partner, with each lab taking about six weeks (for a total of twelve lab sessions each), both culminating in a journal-like paper. So, based on that, it should just be a less monotonous and Physics-related version of my Bio II lab. Again, I haven’t started the actual lab yet since syllabus week was in full swing, so I don’t know how that will go. I do know that I will be consistently ten to fifteen minutes late every Wednesday to the recitation session, since Tae Kwon Do ends ten minutes before it out at IM West.

PHY 492 – Nuclear and Elementary Particle Physics
The other half of my senior Physics requirement, this seminar will be loads better than last semester’s, if only for the different professor. The material is insanely interesting, the book is pretty well written, plus I’m actually going to care about it this time around. A similar structure with exams and papers, this shouldn’t have too much work strapped on to my load. I mean, just look at that awesome cover! How can a class with that book not be completely epic?

I will also, once more, be leading Briggs Physics labs. With the expected shift of schedules right before classes started, I didn’t know exactly where I’d end up, but thankfully I know now. I have one lab on Tuesday at 1500, one on Thursday at 1130, and my office hours retained their same time slot (2000-2200 Wednesdays). Plus, I’ll actually be able to make it to the weekly meetings, which is good enough for me!

I’m still playing Quidditch, which I’m really excited about. If the little time I spent on the team last year was any indication, this is going to be an awesome spring season. I’m going to be trying out for the travel team, since I obviously missed those tryouts in the fall, which will be held in three weeks’ time. I’m a little nervous, but that may just be because I always get nervous before things like that. Hopefully with intramural practices starting back up this week, plus a scrimmage next Sunday, those feelings of nervousness will subside.

I’ve started learning C++, having bought a textbook geared toward giving an overview of the language specifically for computational physics purposes. It’s not that bad so far, but I did hit a rut in chapter nine with a ton of new topics (in the language) that I need to digest individually before I move on. Past that, I’m still using Fortran and Python, so I should be ready for whatever I may need to use in grad school.

Speaking of post-graduation activities, all of my applications are officially done, so now I’m just in the waiting game to see if I get in any where. If I don’t, I’m also in the middle of the application process for Teach for America, having gone through the initial steps. I also have a phone interview this Thursday, plus I need to complete an online writing assignment soon, but past that it will be interesting to see what happens with that. My final application, which right now is just talk, is sending off my information to SpaceX to see if I can get a spot on one of their programming teams. While I don’t have all of the academic credentials for the job, and I may not even know the language that they write their software in, hopefully they see past those superficial measures. Of course, at this point everything is just waiting around for things to fall into place.

I think that should be good for now. In other news, it’s almost been a year since my MDRS mission, I’m still playing guitar, I had a great time at a bar crawl on Saturday, and I did not deserve to lose in Spoons tonight.

netJina and Grad School Applications

This past Monday, I had my most recent meeting with Doc Brown about my Astrophysics senior thesis, which went well for a handful of reasons. From now on, what I’m doing for the research will actually be relevant for the final project. No more will I simply be just reading and learning things to get up to speed; I’ve actually started programming for the final project! But, before I get ahead of myself, let’s go over what happened:

gfortran was fixed…
After e-mailing my advisor to set up the meeting, he told me to grab the most recently updated files through the svn, read through them quickly, then compile them to make sure things worked right (just a ./clean and ./make_all to do everything). So, that’s what I did, but I got an error return during the make. I e-mailed him back soon after, and he said that I just needed to update my compiler (I think I was using gfortran 4.2 or 4.3), which I then set out to do. Note that this is all happening on Saturday, which I was thankful that he sent responses so quickly. For the next four hours, I scoured the interblags trying to download and install gfortran 4.6, the most recently released version. Nothing worked, and I got so frustrated that I decided to re-use my startup disk and clear out the bad files that had invariably started to litter my laptop. Come Sunday afternoon, I bit the bullet and stuck with gfortran 4.5 and hoped it would be fine. Thankfully, I could compile files again (something I had lost during the fiasco the day before), but I was getting a different error message back.

So, come the meeting on Monday, Doc Brown checked the error return and figured it out (he was actually using gfortran 4.4, so I didn’t necessarily need to waste all of that time on Saturday). The was actually an “error” in the ./clean command, since one of the directories wasn’t getting cleaned properly. I put that in quotes since it wasn’t an error, really; the command just didn’t clean that directory since the programmer didn’t want to have that directory cleaned. With that, frustration number one was gone, and I felt grateful that it both worked and that it wasn’t my fault it wasn’t working before.

…I’m actually writing the driver program now…
Once the world was in order, and the test (right) was successful, we started talking about the meat of the project: programming the driver program to run through the r-process! We went through the test_burn.f file just so he could explain a few weird points, I asked questions and understood what was going on, then we discussed a bunch of things related to the project. I’ll be writing two/three tester programs first, just to include the weaklib routines and try out a few different starting values, but my final project will be largely similar to the programs I’m writing now. He also pointed me toward a paper from a few years back to read during my programming to determine some start values and get an overview of an actual application of what I’m doing.

…and I have one reference letter lined up!
Finally, once things were said and done, and I was well-informed on my next steps in my senior thesis, I asked the question that was in the back of my mind for the last month or two: would you be able to write a reference letter for my grad school applications for me? Almost immediately he responded yes, which was a great confidence boost and an amazing way to start the week off. I just had to send him some files (statement of purpose, c.v., etc.) to help him write it, which I compiled and sent out earlier today. I’m just glad that I have one letter set, so I just need two more (I’ve e-mailed one prospect, and I’m going to try to catch one of the others tomorrow or Monday, but if not he’ll get an e-mail as well).

The meeting couldn’t have gone better, at least for the point I am right now. I’m just glad that one stressor has been removed from my life, so things should go much more smoothly now…

Prime Python Philanthropy

With each passing day, I realize that I love programming more an more. Part of it comes from the fact that every line of code is a little puzzle: how it interacts with other lines, itself, variables, functions elsewhere in the code, etc. Getting everything to work together is such an accomplishment, something akin to (at least for me) finishing a race, winning a game, or doing well on an exam. I take almost any opportunity to program, even if it’s just a few short lines to decide what to eat for dinner.

Recently, I’ve been helping a few of my friends with their Python homework for CSE 231. I never took the course, my roommate took it last semester, but we both just like flexing our programming muscles every now and again. We are both in a programming course right now (him in CSE 232, me in MTH 451), but just going back and writing little Python programs is always fun. Today, I wrote a short bit of code that added two binary numbers via string manipulation: completely unnecessary in the real world, but fun to program in its own right.

Of course, my own programming homework is always more difficult than what the CSE 231 homework is. This week, for instance, we needed to write three functions to solve a system of linear equations using three different Gaussian elimination schemes (no pivoting, partial pivoting, and scaled partial pivoting). My first stab at it did not go well, since I started with the actual numerical solving schemes than tackling the machinery underneath. After fusing around for a while, I scrapped it and started fresh, first writing basic matrix manipulation functions (switch rows, multiply row by a constant, etc.), then gradually moved up to actually solving the equations.

# Matrix manipulation functions
def exchange_rows(A, i, j):
  A[i], A[j] = A[j], A[i]
  return A

def multiply_row(A, i, mult):
  for q in xrange(len(A[i])):
    A[i][q] = A[i][q]*mult
  return A

def add_rows(A, i, j):
  for q in xrange(len(A[i])):
    A[j][q] = A[j][q] + A[i][q]
  return A

# Pivot Checking
def check_pivot(A, i):
  if A[i][i] == 0:
    A = exchange_rows(A, i, i+1)
  return A

# Generic entry elimination functions
def forward_substitution(A, i):
  A = multiply_row(A, i, 1/float(A[i][i]))
  for q in xrange(i+1, len(A)):
    if A[q][i] != 0:
      mult = -1.0*float(A[q][i])
      A = multiply_row(A, i, mult)
      A = add_rows(A, i, q)
      A = multiply_row(A, i, 1.0/mult)
  return A

def backward_substitution(A, i):
  for q in xrange(i, 0, -1):
    if A[q-1][i] != 0:
      mult = -1.0*float(A[q-1][i])
      A = multiply_row(A, i, mult)
      A = add_rows(A, i, q-1)
      A = multiply_row(A, i, 1.0/mult)
  return A

# Three solver methods
def gauss_np(A):
  for index in xrange(len(A)):
    A = check_pivot(A, index)
    A = forward_substitution(A, index)
  for index in xrange(len(A)-1, -1, -1):
    A = backward_substitution(A, index)
  return A

def gauss_pp(A):
  startrow = 0
  for index in xrange(startrow, len(A)):
    maxindex = 0
    maxvalue = 1
    for i in xrange(index, len(A)):
      if A[i][index] > maxvalue:
        maxindex = i
        maxvalue = A[i][index]
    A = exchange_rows(A, index, maxindex)
    A = forward_substitution(A, index)
    startrow += 1
  for index in xrange(len(A)-1, -1, -1):
    A = backward_substitution(A, index)
  return A

def gauss_spp(A):
  list = []
  for j in xrange(len(A)):
    maxvalue = -1000
    for i in xrange(len(A[0])-1):
      if A[j][i] > maxvalue:
        maxvalue = A[j][i]
  for index in xrange(len(A)):
    temp = list
    for i in xrange(len(temp)):
      temp[i] = abs(A[i][index]) / float(temp[i])
    max = 0
    ind = i
    for i in xrange(index, len(temp)):
      if temp[i] > max:
        max = temp[i]
        ind = i
    temp[index], temp[i] = temp[i], temp[index]
    A = exchange_rows(A, index, i)
    A = forward_substitution(A, index)
  for index in xrange(len(A)-1, -1, -1):
    A = backward_substitution(A, index)
  return A

# Main function commands
def grab_input():
  A = input("Input Matrix A: ")
  b = input("Input Vector b: ")
  option = raw_input("(1-Gaussian, no pivot : 2-Gaussian, partial pivot : Gaussian, scaled partial pivot)\nSelect Solving Method: ")
  if len(b) != len(A[0]):
    print "Matrix/Vector dimensions mismatched."
    A = "1"
  return A, b, option

def prep_matrix(A, b):
  for q in xrange(len(A)):
  return A

def solve_function(A, option):
  if option == "1":
    A = gauss_np(A)
  elif option == "2":
    A = gauss_pp(A)
  elif option == "3":
    A = gauss_spp(A)
  return A

def grab_solution(A):
  x = []
  for q in xrange(len(A)):
  return x

def main():
  A, b, option = grab_input()
  A = prep_matrix(A, b)
  A = solve_function(A, option)
  x = grab_solution(A)
  print x

if __name__ == "__main__":

For the solver functions, I wrote gauss_np(), then gauss_pp(), then gauss_spp(). You can kind of tell that order since the latter ones are way less elegant than the rest of the code. I guess that happens after fusing with the program for a few hours straight, but at the same time I enjoyed trying to track down those little bugs and index errors and what-not that crept in while typing the commands.

It’s a scavenger hunt, academic contest, tabletop puzzle, and basketball game all rolled into one!