<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Google Treasure Hunt 2008, second puzzle in F#</title>
	<atom:link href="http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/</link>
	<description>Functional programming on .Net</description>
	<lastBuildDate>Tue, 23 Feb 2010 22:18:36 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Solving Google Treasure Hunt Problem 4: Prime Numbers - good coders code, great reuse</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-407</link>
		<dc:creator>Solving Google Treasure Hunt Problem 4: Prime Numbers - good coders code, great reuse</dc:creator>
		<pubDate>Sat, 07 Jun 2008 00:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-407</guid>
		<description>[...] I have missed the first three puzzles (first, second and third) but I&#8217;ll give the fourth puzzle a [...]</description>
		<content:encoded><![CDATA[<p>[...] I have missed the first three puzzles (first, second and third) but I&#8217;ll give the fourth puzzle a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simetrical</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-396</link>
		<dc:creator>Simetrical</dc:creator>
		<pubDate>Thu, 29 May 2008 01:44:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-396</guid>
		<description>I don&#039;t know awk, but this bash script was simple enough to cook up with a little trial and error:

for str in zzz aaa; do for file in `find -regex &quot;.*$str.*\.js&quot;`; do if [ `wc -l &lt; $file` -ge 5 ]; then head -n 5 $file &#124; tail -n 1 &#124; tr &quot;\n&quot; &#039;+&#039;; fi; done; echo; done

(-iname is wrong here, we need full paths.  Needless to say, the task for me was the fifth line of *zzz*.js and of *aaa*.js.)  It gave the output 

2594+9005+3949+2058+8393+
2594+1249+8496+4728+

I then copy-pasted that to

$ echo $(((2594+9005+3949+2058+8393)*(2594+1249+8496+4728)))

and got 443724933, which was correct.  My first try was wrong, because I was processing files with less than 4 lines (in that run it was the fourth line for me), despite their explicit hint.  head happily returned less than four lines and tail got the last of those, despite it not being the fourth line.  But with the added conditional it works fine.

People doing this with a real programming language aren&#039;t doing it right, IMO.  :)</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know awk, but this bash script was simple enough to cook up with a little trial and error:</p>
<p>for str in zzz aaa; do for file in `find -regex &#8220;.*$str.*\.js&#8221;`; do if [ `wc -l &lt; $file` -ge 5 ]; then head -n 5 $file | tail -n 1 | tr &#8220;\n&#8221; &#8216;+&#8217;; fi; done; echo; done</p>
<p>(-iname is wrong here, we need full paths.  Needless to say, the task for me was the fifth line of *zzz*.js and of *aaa*.js.)  It gave the output </p>
<p>2594+9005+3949+2058+8393+<br />
2594+1249+8496+4728+</p>
<p>I then copy-pasted that to</p>
<p>$ echo $(((2594+9005+3949+2058+8393)*(2594+1249+8496+4728)))</p>
<p>and got 443724933, which was correct.  My first try was wrong, because I was processing files with less than 4 lines (in that run it was the fourth line for me), despite their explicit hint.  head happily returned less than four lines and tail got the last of those, despite it not being the fourth line.  But with the added conditional it works fine.</p>
<p>People doing this with a real programming language aren&#8217;t doing it right, IMO.  <img src='http://www.fsharp.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hector</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-374</link>
		<dc:creator>hector</dc:creator>
		<pubDate>Fri, 23 May 2008 18:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-374</guid>
		<description>@liesen: this didn&#039;t work with paths.</description>
		<content:encoded><![CDATA[<p>@liesen: this didn&#8217;t work with paths.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bpgergo</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-373</link>
		<dc:creator>bpgergo</dc:creator>
		<pubDate>Fri, 23 May 2008 17:18:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-373</guid>
		<description>java and bash implemetations:
http://bpgergo.blogspot.com/2008/05/treasure-hunt-2.html</description>
		<content:encoded><![CDATA[<p>java and bash implemetations:<br />
<a href="http://bpgergo.blogspot.com/2008/05/treasure-hunt-2.html" rel="nofollow">http://bpgergo.blogspot.com/2008/05/treasure-hunt-2.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: claudio</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-367</link>
		<dc:creator>claudio</dc:creator>
		<pubDate>Thu, 22 May 2008 19:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-367</guid>
		<description>@tulsi: I have to agree with you, solving it with functional programming was harder than it seems.</description>
		<content:encoded><![CDATA[<p>@tulsi: I have to agree with you, solving it with functional programming was harder than it seems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tulsi</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-366</link>
		<dc:creator>Tulsi</dc:creator>
		<pubDate>Thu, 22 May 2008 18:20:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-366</guid>
		<description>It&#039;s a very good exercise to solve those puzzles in different languages, although this last one is much much easier solved with unix tools (awk, grep, etc)</description>
		<content:encoded><![CDATA[<p>It&#8217;s a very good exercise to solve those puzzles in different languages, although this last one is much much easier solved with unix tools (awk, grep, etc)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: liesen</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-365</link>
		<dc:creator>liesen</dc:creator>
		<pubDate>Thu, 22 May 2008 18:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-365</guid>
		<description>find . -iname *jkl*.txt -exec awk &#039;FNR == 5&#039; {} \; &#124; awk &#039;{ sum += $1 } END { print sum }&#039;</description>
		<content:encoded><![CDATA[<p>find . -iname *jkl*.txt -exec awk &#8216;FNR == 5&#8242; {} \; | awk &#8216;{ sum += $1 } END { print sum }&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: claudio</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-362</link>
		<dc:creator>claudio</dc:creator>
		<pubDate>Thu, 22 May 2008 12:29:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-362</guid>
		<description>Hi Diego,
with the overloaded version you mentioned the code becomes shorter and easier to understand, thanks!</description>
		<content:encoded><![CDATA[<p>Hi Diego,<br />
with the overloaded version you mentioned the code becomes shorter and easier to understand, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diegoeche</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-361</link>
		<dc:creator>diegoeche</dc:creator>
		<pubDate>Thu, 22 May 2008 12:15:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-361</guid>
		<description>Hi!

It&#039;s nice to see somebody else using F# for this problems :)

There&#039;s another overloaded version of GetFiles that receives a SearchOption. Here you can specify to get files of subdirectories in the given directory.</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>It&#8217;s nice to see somebody else using F# for this problems <img src='http://www.fsharp.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>There&#8217;s another overloaded version of GetFiles that receives a SearchOption. Here you can specify to get files of subdirectories in the given directory.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larsivi</title>
		<link>http://www.fsharp.it/2008/05/21/google-treasure-hunt-2008-second-puzzle-in-f/comment-page-1/#comment-357</link>
		<dc:creator>larsivi</dc:creator>
		<pubDate>Wed, 21 May 2008 21:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=34#comment-357</guid>
		<description>I noticed this on DZone and figured I&#039;d like to try it in D - http://larsivi.net/node/112</description>
		<content:encoded><![CDATA[<p>I noticed this on DZone and figured I&#8217;d like to try it in D &#8211; <a href="http://larsivi.net/node/112" rel="nofollow">http://larsivi.net/node/112</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
