Finding the Must-pass, Shortest Path Nodes in a Graph

The following is a problem given as a lab assignment for my Graph Algorithms course that I’m currently taking. It’s a pretty interesting problem and I enjoyed coming up with the solution. Problem Fatima commutes from KTH to home by subway every day. Today Robert decided to surprise Fatima by baking cookies and bringing them…

Find the middle element in an int list (SML/NJ)

The following is a function that I wrote as an assignment for my Language Design class that returns the middle element of an integer list. fun middle lst = let fun reduceByTwo ([],onelst) = hd(onelst) (*When our twolst is empty we are at the middle*) | reduceByTwo (twolst,[]) = 0 (*This should never happen*) |…

Project Euler | Problem 4 (Palindrome Product) Solution

As a part of my Discrete math class this quarter, my teacher has assigned us a few of the problems from Project Euler. If you are unfamiliar with this project, it is a “series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve.” Being a much bigger fan of…