I finally got around to completing one of these challenges, and though I wasn't really that close to winning, it was fun to mess around with it it was one of the shorter Haskell solutions!
So, the challenge I attempted was Reddit's Tiny Code Challenge #4, asking for the shortest program that finds the longest identical subsequence in a string.
Directly from the challenge page:
For example:So, here was my solution in Haskell:
aaabbbbccc aabccdcdd -> aab, bcc
adeaabbbbccc aabccdedcdd -> aab, bcc
abcdef ghijk -> nothing
abcdef fghijk -> f
Let's break this down into steps, since it probably looks like a bunch of mumbo-jumbo!
And there you have it! 193 characters of Haskell code got us a pretty cool program.
Here's a little bit of output:
Cool! :)>tc04.exe"aaabbbbccc" "aabccdcdd"
>"bcc">tc04.exe "abcdef" "ghijk">tc04.exe "abcdef" "fghijk">"f">tc04.exe "fhqwhgads" "where are all the dragons?">"wh"
-Ben
No comments:
Post a Comment