<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Lazy Evaluation</title><link>http://srtsolutions.com/blogs/marinafedner/default.aspx</link><description>Marina&amp;#39;s coding (mis)adventures</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/LazyEvaluation" type="application/rss+xml" /><item><title>Computational Thinking for Everyone</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/5yhAjuBln9c/computational-thinking-for-everyone.aspx</link><pubDate>Fri, 19 Jun 2009 22:00:17 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11571</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=11571</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=11571</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2009/06/19/computational-thinking-for-everyone.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;As part of Jon Udell&amp;#39;s &lt;a href="http://itc.conversationsnetwork.org/series/innovators.html"&gt;Interviews with Innovators&lt;/a&gt; series, he talks to Joan Peckham about Computational Thinking for Everyone. She is a involved in an NSF project that&amp;#39;s evaluating computational thinking in the context of K-12 education.&amp;nbsp; I love thinking about computer science education, and this adds a new twist: in the modern world, should we be focusing on educating kids about computing concepts way before college? If so, how?&amp;nbsp; A few interesting points from the interview:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;With the growing importance of technology in every aspect of life these days, should computational thinking be one of the &amp;quot;three R&amp;quot;s -- taught at every level in school, and considered crucial to being an educated citizen?&amp;nbsp; &lt;/li&gt; &lt;li&gt;If so, how should kids be taught these concepts?&amp;nbsp; When they say computational thinking, the NSF project has way more than just using computers in mind: from the ability to organize one&amp;#39;s thoughts in a systematic manner, to applying &amp;quot;debugging&amp;quot; skills to non-software problems, to approaching complicated systems by breaking them down into components with interfaces.&amp;nbsp; Curricula will need to be developed for different classroom levels, and teachers and parents need to understand this new subject.&lt;/li&gt; &lt;li&gt;A topic of much debate in the computer science education world is whether a college-level computer science program must start with an in-depth programming class.&amp;nbsp; On one hand, there&amp;#39;s a lot more to computer science than just writing code, and you don&amp;#39;t want to immediately bore and discourage new students with dry coding exercises.&amp;nbsp; Instead, they should get a foundation in the important mathematical and social concepts of computing first.&amp;nbsp; But wait! On the other hand, you don&amp;#39;t want these students to get any farther into their major without truly understanding what they&amp;#39;re getting into: writing and understanding software will likely be a key aspect of the rest of their education, and of course of any job a computer science graduate later takes.&amp;nbsp; The idea of teaching computational thinking way before college helps clear up this debate: teach all kids what computers can be good for and how to think about them way before college, and then computer science freshmen will be ready for nitty-gritty programming details right away.&lt;/li&gt; &lt;li&gt;Right now, while most kids and young adults say that they use technology every day and enjoy it, most think that majoring in computer science is something that only boring nerds do; they&amp;#39;re not considering it. Perhaps by teaching computing in holistic way and relating it to other fields, we could engage many different types of students.&amp;nbsp; If kids with diverse interests understand the potential of software to create beautiful things and solve the world&amp;#39;s social problems, they will hopefully go on to contribute to and truly enrich the software world.&amp;nbsp; And that&amp;#39;s a worthy goal if I&amp;#39;ve ever heard one.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Next up for the NSF project: coming up with a PR-worthy name for the concepts they&amp;#39;re discussing.&amp;nbsp; &amp;quot;Computational thinking&amp;quot; seems to have the connotation of teaching kids to think mechanically instead of creatively, and other alternatives have so far been too long or complex.&lt;/p&gt; &lt;p&gt;Check out the full interview &lt;a href="http://itc.conversationsnetwork.org/shows/detail4094.html"&gt;here&lt;/a&gt;, and also interesting are &lt;a href="http://blog.jonudell.net/2009/05/04/talking-with-joan-peckham-about-computational-thinking/"&gt;Jon Udell&amp;#39;s notes&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11571" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/5yhAjuBln9c" height="1" width="1"/&gt;</description><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2009/06/19/computational-thinking-for-everyone.aspx</feedburner:origLink></item><item><title>Learning a new language: quizzes, games, koans, and kata</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/6SNUup22Qg8/learning-a-new-language-quizzes-games-koans-and-kata.aspx</link><pubDate>Wed, 29 Apr 2009 21:35:30 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:9478</guid><dc:creator>mfedner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=9478</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=9478</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2009/04/29/learning-a-new-language-quizzes-games-koans-and-kata.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;At &lt;a href="http://www.codemash.org/"&gt;CodeMash 2009&lt;/a&gt; in January, I was lucky enough to end up in &lt;a href="http://onestepback.org/"&gt;Jim Weirich&lt;/a&gt; and &lt;a href="http://objo.com/"&gt;Joe O&amp;#39;Brien&lt;/a&gt;&amp;#39;s Ruby 101 session.&amp;nbsp; These guys are smart and creative, so instead of just talking a lot, they came up with a set of &lt;a href="http://github.com/edgecase/ruby_koans/tree/master"&gt;Ruby Koans&lt;/a&gt; for the participants to work on during the session.&amp;nbsp; Koans were short ruby tests that we had to make pass,&amp;nbsp; each test actively teaching us a new ruby feature or concept.&lt;/p&gt; &lt;p&gt;For me, this is a great way to start learning a programming language. There&amp;#39;s the competitive &amp;quot;game&amp;quot; aspect, but also the &amp;quot;hmm, I should look into this!&amp;quot; insights that, if one&amp;#39;s paying attention, inevitably come from some of the tasks. So I&amp;#39;ve started looking for more of them:&amp;nbsp; small puzzles that are fun and challenging to solve, that can get my feet wet with a new programming language.&amp;nbsp; Here&amp;#39;s a list I&amp;#39;ve compiled of highly-recommended quizzes, games, koans or kata.&amp;nbsp; Let me know if your favorite is missing, and I&amp;#39;ll add it!&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://github.com/edgecase/ruby_koans/tree/master"&gt;Ruby Koans&lt;/a&gt; - test-driven learning&lt;/p&gt; &lt;p&gt;&lt;a href="http://codekata.pragprog.com/"&gt;Code Kata&lt;/a&gt; -&amp;nbsp; coding exercises, of Pragmatic Programmers fame&lt;/p&gt; &lt;p&gt;&lt;a href="http://rubyquiz.com/"&gt;Ruby Quiz&lt;/a&gt; - weekly programming challenge for rubyists.&amp;nbsp; No longer updated, but lots of great ones in the archive&lt;/p&gt; &lt;p&gt;&lt;a href="http://perl.plover.com/qotw/"&gt;Perl Quiz of the Week&lt;/a&gt; - same idea, but for perl.&amp;nbsp; Check the archive.&lt;/p&gt; &lt;p&gt;&lt;a href="http://haskell.org/haskellwiki/Haskell_Quiz"&gt;Haskell Quiz&lt;/a&gt; - for those of us that long to write functional code in our free time&lt;/p&gt; &lt;p&gt;&lt;a href="http://robocode.sourceforge.net/"&gt;Robocode&lt;/a&gt; - Open-source java coding game: test your robot against the competition!&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.pythonchallenge.com"&gt;Python Challenge&lt;/a&gt; - It&amp;#39;s a challenge, and it uses python.&amp;nbsp; Need I say more?&lt;/p&gt; &lt;p&gt;And of course, our SRT favorite, &lt;a href="http://projecteuler.net/"&gt;Project Euler&lt;/a&gt;.&amp;nbsp; Interesting and challenging math and computer science puzzles that can be solved using code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=9478" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/6SNUup22Qg8" height="1" width="1"/&gt;</description><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2009/04/29/learning-a-new-language-quizzes-games-koans-and-kata.aspx</feedburner:origLink></item><item><title>Good Business, Flow, and Software Development</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/aXEXDDKgm4w/good-business-flow-and-software-development.aspx</link><pubDate>Tue, 06 Jan 2009 03:26:57 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:5861</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=5861</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=5861</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2009/01/05/good-business-flow-and-software-development.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I&amp;#39;ve been reading an interesting book called &lt;u&gt;&lt;a href="http://www.amazon.com/Good-Business-Leadership-Making-Meaning/dp/014200409X/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1231088659&amp;amp;sr=8-1"&gt;Good Business&lt;/a&gt;&lt;/u&gt; by Mihaly Csikzentmihalyi.&amp;nbsp; The author is a psychology professor who is known for his work in the study of happiness and creativity, and in particular, a state of concentration he calls &lt;em&gt;flow.&amp;nbsp; &lt;/em&gt;Most software developers have felt this from time to time, perhaps when working on a particularly challenging and consuming piece of code.&amp;nbsp; We might call this being &lt;em&gt;in the zone&lt;/em&gt;.&amp;nbsp; In this book he applies his research to business, claiming that today&amp;#39;s workplace, instead of contributing to human happiness, has often become a source of drudgery and dissatisfaction to the employee.&amp;nbsp; Though we spend much of our lives at work, for various reasons, the typical job today is unlikely to cause the employee to experience flow in his work.&amp;nbsp; This, Csikzentmihalyi claims, is a true disappointment, because a business that contributes to the happiness and well-being of its employees by maximizing the flow they experience is not only benefiting society, but also likely being successful in the marketplace.&lt;/p&gt; &lt;p&gt;Keep in mind that flow is not necessarily connected to work, but can occur in anything humans do: playing music or sports, reading, conversation, religion, etc.&amp;nbsp; Csikzentmihalyi&amp;#39;s research has gathered examples from rock climbers, surgeons, dancers, housewives and any number of other people who report similar experiences while engaged in very different activities.&amp;nbsp; However, since we do spend a good chunk of our lives at work, it&amp;#39;s worthwhile to think about how we can experience flow in our jobs, not just in our favorite hobbies, where it&amp;#39;s typically felt by most people.&amp;nbsp; Based on his research, these are the components of flow, although not all are necessary to experience it:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1. The goals are clear:&lt;/strong&gt; precise tasks to accomplish are clear in any moment, but one savors each step along the way instead of focusing only on the end goal&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2.&amp;nbsp; Feedback is immediate:&lt;/strong&gt; others involved, or usually the activity itself provides feedback about progress&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3.&amp;nbsp; There&amp;#39;s a balance between opportunity and capacity&lt;/strong&gt;:&amp;nbsp; the task is neither too challenging, causing anxiety, nor too easy, causing boredom.&amp;nbsp; Skills are matched.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4. Concentration deepens:&lt;/strong&gt; an almost meditation-like concentration, undistracted by the outside world&lt;/p&gt; &lt;p&gt;&lt;strong&gt;5. The present is what matters:&lt;/strong&gt; everyday worries or problems don&amp;#39;t register in the mind; attention is fully focused on the present task&lt;/p&gt; &lt;p&gt;&lt;strong&gt;6.&amp;nbsp; Control is no problem:&lt;/strong&gt; unlike everyday life, whose events are often beyond our control, the situation seems fully within one&amp;#39;s power to control&lt;/p&gt; &lt;p&gt;&lt;strong&gt;7.&amp;nbsp; The sense of time is altered:&lt;/strong&gt; time seems to fly, or stands nearly still.&amp;nbsp; The speed at which time passes depends on mental &amp;quot;absorption&amp;quot;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;8. The loss of ego:&lt;/strong&gt; one tends to forget not only one&amp;#39;s problems, but one&amp;#39;s very self, getting lost in the action&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The author concludes that to be effective in leading a &amp;quot;Good Business&amp;quot; (by creating an atmosphere and culture conducive to flow), the essential components are:&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1 - Clear Goals &lt;/strong&gt;(for the company, from executives and management, and individually)&lt;br /&gt;&lt;strong&gt;2 - Good &amp;amp; Immediate Feedback &lt;/strong&gt;(from one&amp;#39;s superiors, but also one&amp;#39;s colleagues)&lt;br /&gt;&lt;strong&gt;3 - Incremental Challenges&lt;/strong&gt; (both from management to employees, and individually -- employees find ways to challenge themselves at work)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So what does this have to do with software development?&amp;nbsp; We can all agree that our most productive and most interesting times as a developer are when we manage to reach this elusive state.&amp;nbsp;&amp;nbsp; By adjusting our environment and work culture to encourage flow experiences, we can both be more successful and find more enjoyment at work.&amp;nbsp; While the the author&amp;#39;s research and interviews for Good Business focused on what a company&amp;#39;s leadership could do to run a business with flow in mind, I&amp;#39;ve used them as a base to come up with ideas for us software developers to implement in our jobs ourselves.&amp;nbsp; Most of us lucky to have jobs that allow us plenty of freedom, so we should take advantage of this.&amp;nbsp; Here are my ideas:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Don&amp;#39;t allow yourself to be a cog in the wheel: find ways to use your unique skills at work.&amp;nbsp; If you&amp;#39;re a developer but have a talent for writing, volunteer to help with client proposals or documentation; if you have a good eye for UI and design, help out on that component of projects.&lt;/li&gt; &lt;li&gt;Know your company&amp;#39;s goals, and work for one whose goals you agree with.&amp;nbsp; Is the goal to expand the company, or to work on as much cool technology as possible, or to create and sell something new? It&amp;#39;s hard to be focused at work if you aren&amp;#39;t on board with the goals.&lt;/li&gt; &lt;li&gt;Speaking of goals: if your manager doesn&amp;#39;t set them for you, set your own.&amp;nbsp; If your workplace doesn&amp;#39;t do agile, you can still set up your own iteration plan and measure whether you&amp;#39;ve accomplished it at the end.&amp;nbsp;&amp;nbsp; Or track your own bugs, if there&amp;#39;s no system in place.&amp;nbsp; You may not be rewarded or recognized, but you&amp;#39;ll have the satisfaction of reaching your goals.&lt;/li&gt; &lt;li&gt;Challenge:&amp;nbsp; Same thing.&amp;nbsp; While it&amp;#39;d be nice if our bosses knew the progression of all of our skills and exactly when we&amp;#39;re ready to move on to more challenging projects, that&amp;#39;s not realistic.&amp;nbsp; Find ways to challenge yourself, perhaps by learning a new technique or technology and applying it to your current project.&lt;/li&gt; &lt;li&gt;Environment matters: if your office isn&amp;#39;t comfortable, clean, and relatively calming, think about what you can do to change this.&amp;nbsp; &lt;/li&gt; &lt;li&gt;Communication:&amp;nbsp; ask your colleagues and your manager for feedback.&amp;nbsp; Not just twice a year at your review, but talk all the time.&amp;nbsp; Ask for help and ideas.&lt;/li&gt; &lt;li&gt;Finally, and perhaps most importantly, attitude: nothing external can guarantee that a developer finds intrinsic satisfaction in writing code.&amp;nbsp; Look beyond just technical skills for the right attitude when hiring.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;These small changes can help you experience flow at work, even in an ordinary and occasionally mundane job.&amp;nbsp;&amp;nbsp; A related question on my mind is whether and how independent software projects (open source, or anything else we work on outside of our jobs for fun) differ in the flow we feel from software we write at work.&amp;nbsp; What do you think?&amp;nbsp; What am I missing that&amp;#39;s been effective for you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=5861" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/aXEXDDKgm4w" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/books/default.aspx">books</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2009/01/05/good-business-flow-and-software-development.aspx</feedburner:origLink></item><item><title>Ruby's method_missing: a simple example</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/wabUt44dXVE/ruby-s-method-missing-a-simple-example.aspx</link><pubDate>Wed, 24 Dec 2008 05:21:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:5798</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=5798</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=5798</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/12/24/ruby-s-method-missing-a-simple-example.aspx#comments</comments><description>&lt;p&gt;In ruby, when you call a method that doesn&amp;#39;t actually exist on that object, the object always invokes the &lt;span style="font-family:Lucida Console;"&gt;method_missing&lt;/span&gt; method instead.&amp;nbsp; This is one of ruby&amp;#39;s cool metaprogramming features: it lets you decide yourself how to handle what would have otherwise been an error.&amp;nbsp; This feature is used in lots of interesting ways, such as dynamically finding and generating methods, dispatching method or system calls, and generating custom XML with method calls.&amp;nbsp; But let&amp;#39;s start with something simple: using method_missing to implement basic tracing functionality.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div id="content"&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; MyClass&lt;br /&gt;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;def&lt;/span&gt; foo(bar)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17&lt;br /&gt;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;def &lt;/span&gt;do_something(what, ntimes)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; puts &amp;quot;Something happened!&amp;quot;&lt;br /&gt;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;end&lt;br /&gt;end&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s my class.&amp;nbsp; It has some methods!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div id="content"&gt;
&lt;p&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Tracer&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;def&lt;/span&gt; initialize(obj)&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @obj = obj&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;def&lt;/span&gt; method_missing(method_name, *args)&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; puts &amp;quot;Called #{method_name} with args: #{args * &amp;#39;, &amp;#39;}&amp;quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @obj.send(method_name,*args)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&amp;nbsp; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;  &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This is a wrapper class: it will be initialized with my class as a parameter.&amp;nbsp; Notice it has no methods defined except method_missing.&amp;nbsp; That means any method calls will just invoke method_missing.&amp;nbsp; method_missing outputs a trace message and then invokes the method (with the given parameters) on the wrapped object. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To use the Tracer, we create a new MyClass object and pass it to a new Tracer, and we&amp;#39;re good to go!&lt;/p&gt;
&lt;div id="content"&gt;
&lt;p&gt;myclass = MyClass.new&lt;br /&gt;wrapped_class = Tracer.new(myclass)&lt;br /&gt;wrapped_class.do_something(&amp;quot;blah&amp;quot;, 5)&lt;br /&gt;wrapped_class.foo(89)&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Running this code yields the output:&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Called do_something with args: blah, 5&lt;br /&gt;Something happened!  &lt;/p&gt;
&lt;p&gt;Called foo with args: 89&lt;br /&gt;17&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To keep it simple, this example doesn&amp;#39;t get the return value of the invoked method, or account for stacked method calls.&amp;nbsp; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=5798" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/wabUt44dXVE" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/12/24/ruby-s-method-missing-a-simple-example.aspx</feedburner:origLink></item><item><title>Euler problem #6</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/d_F7lj8UDs4/euler-problem-6.aspx</link><pubDate>Mon, 27 Oct 2008 16:11:07 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:5114</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=5114</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=5114</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/10/27/euler-problem-6.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;----&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;We don&amp;#39;t actually need a computer to solve this problem, but why not?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The formula for the sum of the squares of the first n natural numbers is:&amp;#160; &lt;font color="#ff0000"&gt;n*(n+1)*(2n+1)/6&lt;/font&gt; .&lt;/p&gt;  &lt;p&gt;The formula for the sum of the first n natural numbers is:&amp;#160; &lt;font color="#ff0000"&gt;n(n+1)/2&lt;/font&gt; .&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;We can write this in ruby:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div id="content"&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;def&lt;/font&gt; &lt;strong&gt;sumToN&lt;/strong&gt;(n) &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160; (n*(n+1))/2 &lt;/p&gt;    &lt;p&gt;&lt;font color="#0000ff"&gt;end &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0000ff"&gt;def &lt;/font&gt;&lt;strong&gt;sumOfSquares&lt;/strong&gt;(n) &lt;/p&gt;    &lt;p&gt;&amp;#160; (n*(n+1)*(2*n+1))/6 &lt;/p&gt;    &lt;p&gt;&lt;font color="#0000ff"&gt;end &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;puts&lt;/strong&gt; sumToN(100)**2 - sumOfSquares(100)&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Note that you don&amp;#39;t need an explicit return statement.&amp;#160; The last expression in any function will be returned by default. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=5114" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/d_F7lj8UDs4" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/10/27/euler-problem-6.aspx</feedburner:origLink></item><item><title>Interview questions for junior software developers</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/do9jrSS9G6w/interview-questions-for-junior-software-developers.aspx</link><pubDate>Sat, 18 Oct 2008 02:34:37 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4851</guid><dc:creator>mfedner</dc:creator><slash:comments>499</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=4851</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=4851</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/10/17/interview-questions-for-junior-software-developers.aspx#comments</comments><description>&lt;p&gt;Every interview is difficult, because on both sides, you know you&amp;#39;re about to make an important decision based on very little information.&amp;nbsp; But it seems to me that interviewing a recent college grad can be especially difficult for an industry veteran.&amp;nbsp; There typically isn&amp;#39;t much to say about the candidate&amp;#39;s past software experience or framework knowledge, so the interviewer is left evaluating the candidate only on intelligence and personal qualities, rather than on real-world software development competence.&amp;nbsp; So what are the most useful questions to ask in this scenario?&amp;nbsp; &lt;p&gt;Here are some of the memorable questions I&amp;#39;ve been asked in interviews for an intern or junior software developer role: the good, the bad, and the ugly.&amp;nbsp; &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Q: A Microsoft puzzle, such as: How many gas stations are there in the USA?, or How many golf balls fit into a school bus?&lt;/strong&gt;  &lt;p&gt;My verdict: Bad. If the candidate doesn&amp;#39;t display her cluelessness by being flabbergasted, how exactly do you judge the creativity or accuracy of her reasoning?&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Q: Write a function to reverse a string.&lt;/strong&gt; &lt;p&gt;My verdict: Good.&amp;nbsp; Discussing solutions that optimize for space or speed can show a candidate&amp;#39;s understanding of the basics (or lack thereof). &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Q: There is a room with a door (closed) and three light bulbs. Outside the room there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you can&amp;#39;t change them. Identify each switch with its bulb.&lt;/strong&gt; &lt;p&gt;My verdict: Bad.&amp;nbsp; Either the candidate has heard this question before, or he hasn&amp;#39;t.&amp;nbsp; Even the unlikely case where he comes up with the solution on the spot doesn&amp;#39;t tell you much about his prowess with a compiler or a customer. &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Q: Does object-oriented Square extend Rectangle?&lt;/strong&gt; &lt;p&gt;My verdict: Good.&amp;nbsp; What does resize(3,5) do to a Square : Rectangle?&amp;nbsp;&amp;nbsp; If a brand-new developer can see this pitfall to the naive approach to object-oriented design from CS 101, that&amp;#39;s pretty good. &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Q: The typical HR-type questions: What is your weakness; Where do you want to be in five years?&lt;/strong&gt; &lt;p&gt;My verdict: Ugly.&amp;nbsp; Unless the candidate, instead of reciting the typical canned answer, admits a fondness for underage girls, or his plan to take over your business and become your boss.&amp;nbsp; &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Q: Design an elevator system for a 100-story office building.&lt;/strong&gt; &lt;p&gt;My verdict: Good. Opens the discussion to technical and UI factors, and&amp;nbsp; lets you assess your candidate&amp;#39;s creative and problem solving skills.&amp;nbsp; Can he see the big picture? &lt;p&gt;&amp;nbsp; &lt;p&gt;Next time: more ideas for effectively interviewing entry-level developers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4851" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/do9jrSS9G6w" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/incompetence/default.aspx">incompetence</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/interviews/default.aspx">interviews</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/10/17/interview-questions-for-junior-software-developers.aspx</feedburner:origLink></item><item><title>How should I spend my free book money?</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/xwsCQWHEieI/how-should-i-spend-my-free-book-money.aspx</link><pubDate>Thu, 14 Aug 2008 22:41:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4258</guid><dc:creator>mfedner</dc:creator><slash:comments>682</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=4258</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=4258</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/08/14/how-should-i-spend-my-free-book-money.aspx#comments</comments><description>&lt;p&gt;Last week, I went to Eric Ivancich&amp;#39;s awesome &lt;a href="http://www.computersociety.org/portal/"&gt;AACS&lt;/a&gt; talk on Using Ruby to Create Domain-Specific Languages here at the SRT Solutions office.&amp;nbsp; I&amp;#39;d been lazy before, but that day I decided to finally pay my $20 AACS dues and become an official member.&amp;nbsp;&amp;nbsp; As more validation for the fact that I&amp;#39;m the luckiest girl in the world*, I ended up more than recouping my loss when I won the Borders gift card in the members-only drawing at the end of the night!&amp;nbsp; Now I&amp;#39;m faced with a serious dilemma... what to spend it on, from my mile-long Books To Read list?&amp;nbsp; My educational options:&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;A new ruby book, maybe &lt;a href="http://oreilly.com/catalog/9780976694076/"&gt;The Best of Ruby Quiz&lt;/a&gt;?&amp;nbsp; Inspiration after learning more about ruby&amp;#39;s metaprogramming features&lt;/p&gt;  &lt;p&gt;or:&lt;/p&gt;  &lt;p&gt;The software engineering book everyone&amp;#39;s been talking about: &lt;a href="http://oreilly.com/catalog/9780596510046/"&gt;Beautiful Code&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;I&amp;#39;m earmarking this hard-earned money for tech, and making myself stay away from the fiction section (&lt;a href="http://www.borders.com/online/store/TitleDetail?sku=0307278735"&gt;mmm&lt;/a&gt;, very tempting).&amp;nbsp; What does everyone think?&amp;nbsp; I love reading recommendations.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;* Other evidence: I get to work with not just one, but &lt;a href="http://srtsolutions.com/blogs/billwagner/"&gt;three&lt;/a&gt; &lt;a href="http://srtsolutions.com/blogs/patricksteele/default.aspx"&gt;Microsoft&lt;/a&gt; &lt;a href="http://srtsolutions.com/blogs/jaywren/"&gt;MVPs&lt;/a&gt;!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4258" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/xwsCQWHEieI" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/books/default.aspx">books</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/08/14/how-should-i-spend-my-free-book-money.aspx</feedburner:origLink></item><item><title>euler problem #5</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/vnt1Nh4l68c/euler-problem-5.aspx</link><pubDate>Fri, 02 May 2008 01:40:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:3050</guid><dc:creator>mfedner</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=3050</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=3050</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/05/01/euler-problem-5.aspx#comments</comments><description>&lt;p&gt;&lt;i&gt;&amp;nbsp;What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?&lt;/i&gt;&lt;/p&gt;&lt;p&gt;----&lt;/p&gt;&lt;p&gt;To solve this problem easily, we need to remember that the smallest number that is evenly divisible by two numbers is their least common multiple.&amp;nbsp; Armed with this knowledge (and the fact that ruby already has a least common multiple function!), we can write:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;numbers=(1..20).to_a&lt;br /&gt;puts numbers.inject{ |x,n| x.lcm(n) } 
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;So for those of you at SRT (or elsewhere) that still harbor any doubts about ruby, can you beat that?!&amp;nbsp; Fine, ok, so you might say that using a built-in lcm function is kind of lame.&amp;nbsp; So as a bonus, here&amp;#39;s how I implemented lcm myself in a cute way using the greatest common divisor:&lt;/p&gt;

&lt;div id="content"&gt;
&lt;p&gt;def gcd(a,b)&lt;br /&gt;&amp;nbsp; if b==0 : a&lt;br /&gt;&amp;nbsp; else &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gcd(b, a % b )&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def lcm(a,b)&lt;br /&gt;&amp;nbsp; (a*b)/gcd(a,b)&lt;br /&gt;end &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=3050" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/vnt1Nh4l68c" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/05/01/euler-problem-5.aspx</feedburner:origLink></item><item><title>Geeky gear</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/bq0TKHVs_ME/geeky-gear.aspx</link><pubDate>Sun, 13 Apr 2008 03:51:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2760</guid><dc:creator>mfedner</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2760</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2760</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/12/geeky-gear.aspx#comments</comments><description>&lt;p&gt;A while ago, we had a discussion here at the office about nerdy t-shirts.&amp;nbsp; We all know what I&amp;#39;m talking about: usually worn by a male geek/programmer with a neckbeard, a black shirt with a &amp;quot;witty&amp;quot; technical reference.&amp;nbsp; Opinions about these shirts vary among SRT employees: some of us find them funny and even wear them on dates [no report on the results, though], some are skeptical.&amp;nbsp; You might guess that I fall into the second camp.&amp;nbsp; Here are the worst offenders in my book:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.thinkgeek.com/images/products/front/geek_love_poem.jpg" alt="geek love poem" align="" border="" height="286" hspace="" width="220" /&gt;&lt;/p&gt;&lt;p&gt;The geek love poem...&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.thinkgeek.com/images/products/front/noplace.jpg" alt="No place like home" align="middle" border="" height="286" hspace="" width="220" /&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;It&amp;#39;s so bad it&amp;#39;s good. &lt;/p&gt;&lt;p&gt;&lt;img src="http://www.thinkgeek.com/images/products/front/binary-people.jpg" alt="2 types of people" align="middle" border="" height="283" hspace="" width="220" /&gt;&lt;/p&gt;&lt;p&gt;The worst one of all.&amp;nbsp; Nearly ubiquitous in computer science buildings on campuses nationwide, but yet still considered brilliant and unique by the wearer.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;And of course, I can&amp;#39;t leave out geeky women&amp;#39;s gear -- in some ways even more horrifying than the men&amp;#39;s stuff.&amp;nbsp; Evidence presented:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://image0.etsy.com/il_430xN.8181328.jpg" alt="html earrings" align="middle" border="" height="346" hspace="" width="430" /&gt; &lt;/p&gt;&lt;p&gt;HTML tags -- get it?! &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.thinkgeek.com/images/products/front/httppanties_4up.jpg" alt="HTTPanties" align="middle" border="" height="363" hspace="" width="250" /&gt;&lt;/p&gt;&lt;p&gt;I have no words.&amp;nbsp; Instead I&amp;#39;ll leave you with ThinkGeek&amp;#39;s description of these: &amp;quot;... we bring you &lt;b&gt;HTTPanties&lt;/b&gt;
for the discriminating woman who would prefer a web-savvy and somewhat-direct 
approach in the romance department.&amp;nbsp; Feeling frisky? Well then don the black &amp;quot;200 OK&amp;quot; panties and see where they take 
you. Alternatively, the white &amp;quot;403 Forbidden&amp;quot; style sends a very different 
and hopefully clear message. We think &amp;quot;411 Length Required&amp;quot; and &amp;quot;413 Requested Entity Too Large&amp;quot; are pretty self-explanatory.&amp;quot;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2760" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/bq0TKHVs_ME" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/nerd/default.aspx">nerd</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/12/geeky-gear.aspx</feedburner:origLink></item><item><title>Euler Problem 4</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/c-hYIb-aPvY/euler-problem-4.aspx</link><pubDate>Wed, 09 Apr 2008 00:35:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2699</guid><dc:creator>mfedner</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2699</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2699</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/08/euler-problem-4.aspx#comments</comments><description>&lt;p&gt;&lt;i&gt;&amp;nbsp;Find the largest palindrome made from the product of two 3-digit numbers.&lt;/i&gt;&lt;/p&gt;&lt;p&gt;-----&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;First, I defined a palindrome recursively: a number is one if its first and last digits are the same, and if the inside is also a palindrome.&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;def palindrome?(digitArr)&lt;br /&gt;&amp;nbsp; if digitArr.empty?&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; true&lt;br /&gt;&amp;nbsp; elsif digitArr.length == 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; true &lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (digitArr.first == digitArr.last &amp;amp;&amp;amp; palindrome?(digitArr[1..-2]))&amp;nbsp; &lt;br /&gt;&amp;nbsp; end&lt;br /&gt;end&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;Note that in Ruby, methods can end with a question mark, a convention that really helps readability.&amp;nbsp; Also note that the &amp;quot;else if&amp;quot; keyword is &lt;b&gt;elsif&lt;/b&gt;, which is weird and unhelpful to me.&amp;nbsp; I want that 20 minutes of staring at my code like &amp;quot;wtf?!&amp;quot; (before figuring that out) back.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Then we do a search of all the multiples of two three-digit numbers until we find the biggest palindrome:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;def search(i,j)&lt;br /&gt;&amp;nbsp; maxPal=0&lt;br /&gt;&amp;nbsp; while i &amp;gt; 99 do&lt;br /&gt;&amp;nbsp;&amp;nbsp; j=999&lt;br /&gt;&amp;nbsp;&amp;nbsp; while j &amp;gt; 99 do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if palindrome?((i*j).to_s.split(&amp;quot;&amp;quot;)) then &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(i*j)&amp;gt; maxPal then maxPal = i*j&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp;&amp;nbsp; j-=1&lt;br /&gt;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp; i-=1&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;&amp;nbsp; return maxPal&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;puts search(999,999)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;There&amp;#39;s probably a prettier way to do this.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2699" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/c-hYIb-aPvY" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/08/euler-problem-4.aspx</feedburner:origLink></item><item><title>Euler Problem 3</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/Kkz1vIBrEME/euler-problem-3.aspx</link><pubDate>Wed, 09 Apr 2008 00:07:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2698</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2698</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2698</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/08/euler-problem-3.aspx#comments</comments><description>&lt;p&gt;&lt;i&gt;&amp;nbsp;What is the largest prime factor of the number 600851475143 ?&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;-----&lt;/p&gt;&lt;p&gt;&amp;nbsp;I wrote this piece of disgusting, un-Rubylike Ruby to get the answer by creating a list of a number&amp;#39;s prime factors:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;&amp;nbsp;def factor(composite)&lt;br /&gt;&amp;nbsp; i=1&lt;br /&gt;&amp;nbsp; flag=false&lt;br /&gt;&amp;nbsp; primefactors =[]&lt;br /&gt;&amp;nbsp; while (i &amp;lt; composite)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=i+1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; primefactors.each{|p| flag=true if (i%p).zero?}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag then flag=false &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else # if it is a prime&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primefactors.push(i)&amp;nbsp;&amp;nbsp; &amp;nbsp;#add the prime (since it&amp;#39;s a prime factor)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (composite%i).zero?&amp;nbsp;&amp;nbsp; # as long as n is divisbible by the prime&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; composite /=&amp;nbsp; i&amp;nbsp;&amp;nbsp;&amp;nbsp; # divide n by the prime&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;&amp;nbsp; primefactors&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;puts factor(600851475143).last&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;And then I learned that ruby has a prime number generator.&amp;nbsp; All I need to do is:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;require &amp;#39;mathn&amp;#39;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;n = 600851475143&lt;br /&gt;factor = 0&lt;br /&gt;primes = Prime.new&lt;br /&gt;while n &amp;gt; 1&lt;br /&gt;&amp;nbsp; factor = primes.next&lt;br /&gt;&amp;nbsp; while (n % factor).zero? &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n /= factor &lt;br /&gt;&amp;nbsp; end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;puts factor&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;&amp;nbsp;I am slightly ashamed.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2698" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/Kkz1vIBrEME" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/incompetence/default.aspx">incompetence</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/08/euler-problem-3.aspx</feedburner:origLink></item><item><title>Project Euler: Problem 2</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/sHrfk2DhRBA/project-euler-problem-2.aspx</link><pubDate>Sun, 06 Apr 2008 23:55:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2669</guid><dc:creator>mfedner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2669</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2669</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/06/project-euler-problem-2.aspx#comments</comments><description>&lt;p&gt;The problem:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Find the sum of all the even-valued terms in the [Fibonacci] sequence which do not exceed four million.&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s my fibonacci function:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;def fib(limit =nil)&lt;br /&gt;&amp;nbsp; f1 = 0&lt;br /&gt;&amp;nbsp; f2 = 1&lt;br /&gt;&amp;nbsp; while (not limit or f2 &amp;lt;= limit)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield f2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f1,f2 = f2, f1+f2&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;end&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;And here&amp;#39;s how I use it to get the answer:&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;evens=[]&lt;br /&gt;fib { |x| if x%2==0 : evens.push(x) end ; if x&amp;gt;4000000: break end}&lt;br /&gt;puts evens.inject {|sum, n| sum+n} &lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;I learned about the awesomeness of &amp;#39;yield&amp;#39; by doing this problem, so it was totally worth it.&amp;nbsp; yield let me calculate as many fibonacci terms as I needed, but not more, and without having to calculate any term more than once.&amp;nbsp;&amp;nbsp;  &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2669" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/sHrfk2DhRBA" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/06/project-euler-problem-2.aspx</feedburner:origLink></item><item><title>Project Euler in Ruby</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/c2b6I9PAsVs/project-euler-in-ruby.aspx</link><pubDate>Sun, 06 Apr 2008 17:31:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2666</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2666</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2666</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/06/project-euler-in-ruby.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;m taking Bill Wagner up on his &lt;a href="http://srtsolutions.com/blogs/billwagner/archive/2008/03/25/project-euler-problem-1.aspx" title="project euler" target="_blank"&gt;Project Euler challenge&lt;/a&gt;, but in Ruby.&amp;nbsp; I&amp;#39;ve secretly wanted to learn Ruby for a long time, and this looks like the perfect chance.&amp;nbsp; So if my code makes your eyes bleed, it&amp;#39;s cause I&amp;#39;m a total n00b.&amp;nbsp; Without further ado (because the excitement was becoming unbearable... I agree, Ruby &lt;span style="font-style:italic;"&gt;is&lt;/span&gt; sexy!), here&amp;#39;s my code that prints the answer to Problem 1:&lt;/p&gt;


&lt;p&gt;&lt;i&gt;If we list all the natural numbers below 10 that are multiples of 3
or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.&amp;nbsp; Find the sum of all the multiples of 3 or 5 below 1000.&lt;/i&gt;&lt;/p&gt;

&lt;div id="content"&gt;&lt;p&gt;answer = (0..999).&lt;b&gt;select&lt;/b&gt; { |a| a%3 ==0 || a%5==0 }&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;puts&lt;/span&gt; answer.&lt;span style="font-weight:bold;"&gt;inject&lt;/span&gt; { |sum, n| sum+n }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;I love the built-in ruby function &lt;b&gt;inject&lt;/b&gt;, which is like foldl in some functional languages.&amp;nbsp; (See a cute demo &lt;a href="http://foldl.com/" title="Foldl"&gt;here&lt;/a&gt;.) &amp;nbsp; Overall the code is very similar to Bill&amp;#39;s C# version.&amp;nbsp; I wonder if that&amp;#39;ll still be the case as we get to the more complex problems.&lt;/p&gt;&lt;p&gt;&amp;nbsp;[4/08/08: correction of a typo in the code] &lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2666" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/c2b6I9PAsVs" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/euler/default.aspx">euler</category><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/ruby/default.aspx">ruby</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/04/06/project-euler-in-ruby.aspx</feedburner:origLink></item><item><title>The Google Data query interface</title><link>http://feedproxy.google.com/~r/LazyEvaluation/~3/Jy03kS3Ww88/the-google-data-query-interface.aspx</link><pubDate>Sun, 30 Mar 2008 00:01:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:2595</guid><dc:creator>mfedner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/marinafedner/rsscomments.aspx?PostID=2595</wfw:commentRss><wfw:comment>http://srtsolutions.com/blogs/marinafedner/commentapi.aspx?PostID=2595</wfw:comment><comments>http://srtsolutions.com/blogs/marinafedner/archive/2008/03/29/the-google-data-query-interface.aspx#comments</comments><description>&lt;p&gt;I know I&amp;#39;m not the only one with tons of my data stored somewhere on Google&amp;#39;s servers these days (frightening, I know.)&amp;nbsp; Luckily, there&amp;#39;s the Google Data API, which lets us access and modify our Google data programmatically, should we decide to, say, display it on our websites or build custom applications to process it. &lt;/p&gt;&lt;p&gt;The API uses HTTP requests to transfer data, building on top of RSS and Atom the ability to send a query and receive a feed of matching results.&amp;nbsp; This is cool, because it means we can access our data easily, just by creating the appropriate HTTP query.&amp;nbsp; Here&amp;#39;s what I mean:&lt;/p&gt;&lt;p&gt;This is the XML feed of our SRT Events Google Calendar:&amp;nbsp; http://www.google.com/calendar/feeds/v2433p4md2226qtd3ja1annifc%40group.calendar.google.com/public/basic&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;We can add query parameters to the end of this URL:&amp;nbsp; http://www.google.com/calendar/feeds/v2433p4md2226qtd3ja1annifc%40group.calendar.google.com/public/basic?max-results=10&amp;amp;orderby=starttime&lt;/p&gt;&lt;p&gt;That new-and-improved feed is the full calendar feed of events, filtered to leave only 10 results and ordered by the start date of the event.&amp;nbsp; Note that in addition to a standard set of parameters for all
Google Data, there are some special ones defined for each app, like
&amp;quot;racy&amp;quot; in YouTube.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s the metadata for the most-viewed YouTube videos:&lt;/p&gt;&lt;p&gt;http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed&lt;/p&gt;&lt;p&gt;and adding these query parameters gives us just the family-friendly ones, ordered by rating.&lt;/p&gt;&lt;p&gt;http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed?orderby=rating&amp;amp;racy=exclude&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Now that we&amp;#39;ve got these custom feeds, we can just use any standard libraries to parse or display them. Pretty cool.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=2595" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/LazyEvaluation/~4/Jy03kS3Ww88" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/marinafedner/archive/tags/google/default.aspx">google</category><feedburner:origLink>http://srtsolutions.com/blogs/marinafedner/archive/2008/03/29/the-google-data-query-interface.aspx</feedburner:origLink></item></channel></rss>
