<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Travis Sorensen on Medium]]></title>
        <description><![CDATA[Stories by Travis Sorensen on Medium]]></description>
        <link>https://medium.com/@travissorensen?source=rss-52ede2f0b33c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pjMyGGqRK0tgNOTf.jpg</url>
            <title>Stories by Travis Sorensen on Medium</title>
            <link>https://medium.com/@travissorensen?source=rss-52ede2f0b33c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:10:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@travissorensen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stable Marriage Algorithm]]></title>
            <link>https://medium.com/@travissorensen/stable-marriage-algorithm-b003baa188d3?source=rss-52ede2f0b33c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b003baa188d3</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[codesmith]]></category>
            <category><![CDATA[marriage]]></category>
            <dc:creator><![CDATA[Travis Sorensen]]></dc:creator>
            <pubDate>Wed, 19 Aug 2015 21:50:24 GMT</pubDate>
            <atom:updated>2015-08-19T21:50:24.295Z</atom:updated>
            <content:encoded><![CDATA[<p>So, matching people up based on preferences, sounds easy right?</p><p>Imagine this scenario: We have two groups, we are going to match them up based on characteristics/preference.</p><p>Group1 = [‘andy’, ‘david’, ‘victoria’];</p><p>Group2 = [‘jae’, ‘jasmine’, ‘travis’] ;</p><p>people’s preferences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*XM6KJudSuNN74PI4xQhfTA.png" /></figure><p>How do we find the highest utility? Andy would prefer to be with jae, but jae prefers victoria, but victoria prefers jasmine, but jasmine prefers david, but david prefers jae, and nobody fancies Travis!</p><p>One option is to use ‘brute force,’ just try all the possible options and pick the one with the highest utility.</p><p>This would work, but the number of possible outcomes explodes as the group gets larger.</p><p>This is a choose k of n permutation problem where k and n are both equal to three.</p><p>number of possible choices = n! / (n-k)! → 3! = 6</p><p>but what about matching 30 students with thirty mentors?</p><p>30! = 2.6 * 10^32</p><p>To give you some perspective, that’s more than the estimated number of stars in the entire observable universe.</p><p>okay, so brute force is out, what else is there?</p><p>Enter the stable marriage algorithm. Forgive the sexism, this algorithm was developed in 1962.</p><p>The two groups are husbands and wives. Husbands and wives want to get the best partner possible. The main points are that the wives are agnostic, they will say yes to whomever asks them as long as the person asking is better than their current partner. Wives are also not shy about dumping their match if something better comes along.</p><p>So code..well pseudo code or is it Sudo Code… it should be Sudo Code</p><pre>While there are unmatched husbands, loop through the husband array</pre><pre>    When you find a husband who isn’t matched, find his best match        who will say yes</pre><pre>         Somebody who is unmatched will always say yes</pre><pre>         Somebody who is matched will say yes to somebody who is a better match</pre><pre>    If the wife is not matched, match the two and move on to the next unmatched husband</pre><pre>    Else If the wife is matched and will say yes, mark her existing match as unmatched and match the wife with the new husband.</pre><p>As long as there at least as many wives as husbands, all the husbands will find a match.</p><p>How would this work in our situation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*Y2Ou_x4AL2JzBRSTmDm-ng.png" /></figure><p>Andy matches with Jae</p><p>David chooses Jae and Jae prefers david</p><p>Andy is no longer matched</p><p>David and Jae are matched</p><p>Victoria matches with jasmine</p><p>Andy matches with jasmine and jasmine prefers andy to victoria</p><p>Victoria is no longer matched and andy and jasmine are matched</p><p>Victoria matches with Travis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*ejjYSF4lPcSiz1FmzX49sw.png" /></figure><p>This isn’t necessarily the optimal outcome, but it is ‘stable’ in that you cannot switch any two people and get a higher overall utility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b003baa188d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does jQuery work?]]></title>
            <link>https://medium.com/@travissorensen/how-does-jquery-work-e2dcbe4a9ac8?source=rss-52ede2f0b33c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2dcbe4a9ac8</guid>
            <dc:creator><![CDATA[Travis Sorensen]]></dc:creator>
            <pubDate>Sun, 28 Jun 2015 00:59:30 GMT</pubDate>
            <atom:updated>2015-06-28T00:59:30.043Z</atom:updated>
            <content:encoded><![CDATA[<p>A discussion between my “friend” and I. Actually, it was between me and I and it happened mostly in my head… mostly.</p><p>Me: jQuery is a function!</p><p>My friend: What’s a function?</p><p>Me: This is a function:</p><pre>function doubleTwice(number){</pre><pre>var my Number = number;</pre><pre>var doubleOnce = myNumber*2;</pre><pre>var doubleAgain = doubleOnce*2;</pre><pre>return doubleAgain;</pre><pre>}</pre><p>Here’s the same function with fewer lines of code:</p><pre>function doubleTwice(num){</pre><pre>return num*2*2;</pre><pre>}</pre><p>My friend: Cool, I know what a function is! jQuery is definitely not a function, it’s magic.</p><p>Me: jQuery is function that returns an object!</p><p>Here’s an example of a function that returns an object:</p><pre>function returnObject(name){</pre><pre>return {name: name};</pre><pre>}</pre><p>My friend: okay, that’s great. I know what an object is and I know how to make a function return an object. jQuery is not a function and it doesn’t return an object. jQuery is magic and it grabs something from my website and does stuff to it.</p><p>For example, I can write:</p><pre>jQuery(‘:button’).on(‘click’, function(){</pre><pre>console.log(“hello”);</pre><pre>}</pre><p>This is jQuery magic and it grabs all the buttons on the website and listens for them to be clicked. If I click one, it runs the function I gave it and logs “hello” to the console.</p><p>Me: You’re right. Except jQuery, or just $ for short, is a function. You are passing in something for it to find. In this case all the buttons on your website. The jQuery function returns an object. That object has a bunch of stuff in it. On of the things it has in it is a function that runs when you click on a button.</p><p>My friend: Prove it.</p><p>Me: Okay, let’s jump over to codeschool.com with our chrome browser. Open up the console by holding option, command, ‘j’</p><p>now in the console type $ or jQuery ad press enter.</p><p>My friend: Whoa, cool! It returns a function!</p><pre>function m(b, a)</pre><p>Me: Now inspect the elements using the magnifying glass. Assuming they haven’t changed the name of the tabs, type:</p><pre>$(‘a.tag.tag’)</pre><p>See, you get an array of tags back. If you write:</p><pre>$(‘a.tag.tag’).first()</pre><p>You just get the first item in the array.</p><p>My friend: I thought you said it returns an object?</p><p>Me: An array is a type of object.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2dcbe4a9ac8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a while loop]]></title>
            <link>https://medium.com/@travissorensen/what-is-a-while-loop-d9567f8fe312?source=rss-52ede2f0b33c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9567f8fe312</guid>
            <category><![CDATA[loop]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Travis Sorensen]]></dc:creator>
            <pubDate>Tue, 16 Jun 2015 00:51:36 GMT</pubDate>
            <atom:updated>2015-06-16T16:02:15.087Z</atom:updated>
            <content:encoded><![CDATA[<p>What is a while loop?</p><p>A while loop is a loop that executes “while” a condition is true.</p><p>What is a condition?</p><p>It’s just a statement. That’s a pretty bad explanation, let’s try some pseudo code instead</p><p>Pseudo code:</p><p>Declare a variable called ‘number’</p><p>Set the variable ’number to equal zero.</p><p>While our variable number is less than 5, I’d like it if you would take the following actions:</p><ol><li>Log the ‘number’ variable to the console.</li><li>Increase the ‘number’ variable by one.</li></ol><p>After you’re finished with the while loop, I’d like you to log the string “I’m finished with the while loop!” to the console.</p><p>Great! If you don’t understand this Pseudo code, read it again or discuss it with a friend or with yourself!</p><p>How would this look in Javascript?</p><pre>//Javascript code:</pre><pre>//declare a variable called number and set it equal to 0</pre><pre>var number = 0;</pre><pre>// while number is less than 5, continue looping</pre><pre>while(number &lt; 5){</pre><pre>//take the following actions: log number to the console and increase number by 1</pre><pre>console.log(number);</pre><pre>number = number + 1;</pre><pre>}</pre><pre>//-after exiting the while loop, log the string “I’m finished with the while loop” to the console</pre><pre>console.log(“I’m finished with the while loop!”);</pre><p>What would this look like to the computer?</p><ol><li>Declare the variable number</li><li>Enter the while loop</li><li>Check if the condition is true</li><li>It is!</li><li>Perform the actions in the while loop</li><li>Repeat the while loop</li><li>Check if the condition is true</li><li>It still it!</li><li>Repeat until number is equal to 5, in which case the while loop is no longer true</li></ol><p>Why are people so scared of while loops? Or why are my while loops crashing my browser?</p><p>Well, because the loop continues until the condition is no longer true it’s possible to have an infinite loop, that is a loop that never ends.</p><p>If we neglected to increase our number variable every time we run our while loop, the condition will never not being true and the computer will just keep running until you close your browser. This happens more often that you think.</p><p>Try out the code at <a href="http://jsbin.com/?js,console">http://jsbin.com/?js,console</a></p><p>Bonus points if you can figure out what will print on your console before pressing run!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9567f8fe312" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>