<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - rtperson</title>
<link>http://snipplr.com/users/rtperson/tags/algorithm</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Tue, 21 May 2013 22:47:43 GMT</pubDate>
<item>
<title>(Java) Quicksort in Java, with Enforced Suckitude</title>
<link>http://snipplr.com/view/64808/quicksort-in-java-with-enforced-suckitude/</link>
<description><![CDATA[ <p>It's no fun implementing QuickSort unless you can force it out of its blister-fast, O(n log n) speed and humiliate it with its worst-case, O(n^2) runtime. So that's what I set out to do.  

My naive partition simply pivots around the low item, but my randomized partition defeats the sucky inputs by choosing a random pivot. (If you're interested in checking out a QuickSort which naively partitions until it hits an attempt to get it to run in quadratic time, check out IntroSort -- which simply  fails over to Merge Sort when it exceeds its optimal recursion depth.)</p> ]]></description>
<pubDate>Tue, 08 May 2012 00:02:25 GMT</pubDate>
<guid>http://snipplr.com/view/64808/quicksort-in-java-with-enforced-suckitude/</guid>
</item>
<item>
<title>(Haskell) Haskell 99 Problems, numbers 1 through 9</title>
<link>http://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9/</link>
<description><![CDATA[ <p>I had originally started these problems from #10 (Run-length encoding). I went back and did 1-8 for completeness.</p> ]]></description>
<pubDate>Thu, 08 Sep 2011 00:23:54 GMT</pubDate>
<guid>http://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9/</guid>
</item>
<item>
<title>(Haskell) Haskell 99 Problems - Number 20,  Arrowed!</title>
<link>http://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed/</link>
<description><![CDATA[ <p>problem 20, (*) Remove the K'th element from a list

    *Main> removeAt 1 "abcd"
        "acd"

Trivial using a pure function. A bit more challenging if you use this problem to work up your Arrow-fu.</p> ]]></description>
<pubDate>Thu, 25 Aug 2011 01:54:30 GMT</pubDate>
<guid>http://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed/</guid>
</item>
<item>
<title>(Haskell) Haskell 99 Problems - Number 18 and 19</title>
<link>http://snipplr.com/view/58064/haskell-99-problems--number-18-and-19/</link>
<description><![CDATA[ <p>Problem 18: Extract a slice from a list.

Given two indices, i and k, the slice is the list containing the elements between the i'th and k'th element of the original list (both limits included). Start counting the elements with 1.

Example:

    *Main> slice ['a','b','c','d','e','f','g','h','i','k'] 3 7
    "cdefg
  
9 Problem 19 - Rotate a list N places to the left.

    *Main> rotate ['a','b','c','d','e','f','g','h'] 3
    "defghabc"
 
    *Main> rotate ['a','b','c','d','e','f','g','h'] (-2)
    "ghabcdef"
(This one is so easy it feels like cheating...)</p> ]]></description>
<pubDate>Sun, 21 Aug 2011 01:58:02 GMT</pubDate>
<guid>http://snipplr.com/view/58064/haskell-99-problems--number-18-and-19/</guid>
</item>
<item>
<title>(Haskell) Haskell 99 Problems - Solutions to 11 and 12</title>
<link>http://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12/</link>
<description><![CDATA[ <p>problem 11, modified run-length encoding
========================================
If an element has no duplicates, mark it as such. 

Example:

    encodeModified "aaaabccaadeeee"

    [Multiple 4 'a',Single 'b',Multiple 2 'c',
        Multiple 2 'a',Single 'd',Multiple 4 'e']

problem 12, Decode a run-length encoded list. 
=============================================
Given a run-length code list generated as specified in problem 11. Construct its uncompressed version. 

Example:

    decodeModified 
       [Multiple 4 'a',Single 'b',Multiple 2 'c',
        Multiple 2 'a',Single 'd',Multiple 4 'e']

    "aaaabccaadeeee"</p> ]]></description>
<pubDate>Fri, 29 Jul 2011 08:03:55 GMT</pubDate>
<guid>http://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12/</guid>
</item>
<item>
<title>(Haskell) Run-Length Encoding in Haskell</title>
<link>http://snipplr.com/view/57300/runlength-encoding-in-haskell/</link>
<description><![CDATA[ <p>Problem 10 of the famous 99 Problems. I got 99 problems, but a Lisp ain't one.</p> ]]></description>
<pubDate>Fri, 29 Jul 2011 06:08:49 GMT</pubDate>
<guid>http://snipplr.com/view/57300/runlength-encoding-in-haskell/</guid>
</item>
<item>
<title>(Haskell) Euler Problem 4 in Haskell</title>
<link>http://snipplr.com/view/54652/euler-problem-4-in-haskell/</link>
<description><![CDATA[ <p>A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.

Find the largest palindrome made from the product of two 3-digit numbers.

 There are shorter ways to do this, and I cheat a bit by counting down to 900 rather than 100, but this one short-circuits when it finds the answer, and so is very efficient.</p> ]]></description>
<pubDate>Wed, 01 Jun 2011 00:11:10 GMT</pubDate>
<guid>http://snipplr.com/view/54652/euler-problem-4-in-haskell/</guid>
</item>
</channel>
</rss>