<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>e168f08 - Latest Comments in Assignment 2</title><link>http://e168f08.disqus.com/</link><description></description><atom:link href="https://e168f08.disqus.com/assignment_2/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 19 Oct 2008 17:58:45 -0000</lastBuildDate><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3161595</link><description>&lt;p&gt;I know!  I can't call @hand.thismethod and have that method call @hand.method1!  I just call method1.  Thanks for looking!&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">xtine78</dc:creator><pubDate>Sun, 19 Oct 2008 17:58:45 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3161439</link><description>&lt;p&gt;What you have posted has this line:&lt;/p&gt;&lt;p&gt;@hand.method1()&lt;/p&gt;&lt;p&gt;Does @hand have a method called "method1" on it?&lt;/p&gt;&lt;p&gt;The error message (did you read it?) says: undefined method `method1' for []:Array&lt;/p&gt;&lt;p&gt;So it would seem that when @hand.method1() is executed, @hand is an Array, perhaps; is it? You can find out what class it is before this statement is run by adding:&lt;/p&gt;&lt;p&gt;puts @hand.class&lt;/p&gt;&lt;p&gt;John&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 19 Oct 2008 17:39:24 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3161112</link><description>&lt;p&gt;Here is an error I cannot resolve.&lt;/p&gt;&lt;p&gt;The error is:&lt;br&gt;NoMethodError: undefined method `method1' for []:Array&lt;/p&gt;&lt;p&gt;I get the error when I run the case statement.  Any idea what's happening?&lt;/p&gt;&lt;p&gt;def thismethod()&lt;br&gt;    myvariable =  case &lt;br&gt;          when @hand.method1() == true&lt;br&gt;             something&lt;br&gt;          when @hand.method2() == true&lt;br&gt;             something!&lt;br&gt;          else&lt;br&gt;            nothing&lt;br&gt;          end&lt;br&gt;  end&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">xtine78</dc:creator><pubDate>Sun, 19 Oct 2008 17:01:30 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3158416</link><description>&lt;p&gt;Thanks for reminding me. I must send an e-mail on this.&lt;/p&gt;&lt;p&gt;The requirements and the tests say that hand#accept should accept a single card or an array into the hand.&lt;/p&gt;&lt;p&gt;Unfortunately, the reference implement will accept a single card, an array of cards, OR a list of more than one argument where each argument is interpreted as a card.&lt;/p&gt;&lt;p&gt;So . . . if you implemented it as required, and passed the tests, demo.rb should work fine if you just pass in an Array of the cards -- e.g., change from:&lt;/p&gt;&lt;p&gt;h.accept( &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('S3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('D3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('H3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('D2'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('S2') )&lt;/p&gt;&lt;p&gt;to&lt;/p&gt;&lt;p&gt;h.accept( [ &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('S3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('D3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('H3'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('D2'), &lt;a href="http://Card.new" rel="nofollow noopener" target="_blank" title="Card.new"&gt;Card.new&lt;/a&gt;('S2') ])&lt;/p&gt;&lt;p&gt;John&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 19 Oct 2008 14:06:20 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3157838</link><description>&lt;p&gt;What was the resolution on the demo.rb?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">akv</dc:creator><pubDate>Sun, 19 Oct 2008 13:22:47 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3155391</link><description>&lt;p&gt;Josh--You're making it WAY too complex. Who said you need to mixin anything?&lt;/p&gt;&lt;p&gt;Simply write your own shuffle method. The shuffle could be as simple as exchanging the cards many, many times by random switches.&lt;/p&gt;&lt;p&gt;Regarding the undefined method card_number : Have you defined an ordinary instance method or accessor called card_number ?&lt;/p&gt;&lt;p&gt;It's truly not asking for anything fancy. This assignments requires not one jot of metaprogramming jujitsu.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 19 Oct 2008 08:56:57 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3155295</link><description>&lt;p&gt;On "test_0072_deck_shuffle_020" I am encountering two tough problems.&lt;/p&gt;&lt;p&gt;1) I cannot mixin "shuffle" due to its not being part of "Enumerable". Do I have to use "srand" or require "SecureRandom" to return integers between 0 and 52? I am having trouble imagining how to use such random number generators in a one-liner to shuffle the array.&lt;/p&gt;&lt;p&gt;2) I get the error "undefined method 'card_number' for 51:Fixnum". Does this mean that I have to use a Metaprogramming Singleton to create a class for the already dynamic "51"? I tried it unsuccessfully. I will try again, but just want to know if I am headed in a good direction.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">swithin</dc:creator><pubDate>Sun, 19 Oct 2008 08:43:26 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3151335</link><description>&lt;p&gt;submission:assignment2 - ideal&lt;/p&gt;&lt;p&gt;But we certainly won't refuse a submission that says submission:assignment3 !!!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sat, 18 Oct 2008 19:22:10 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3150609</link><description>&lt;p&gt;In the instruction for submission, it states:&lt;/p&gt;&lt;p&gt;E-mail the ZIP in pkg/ to your section leader. Remember to include E168 in the subject, and submission:assignment3 in the body.&lt;/p&gt;&lt;p&gt;Should we do submission:assignment3 in the body or submission:assignment2 in the body since it is referenced as assignment 2 everywhere else?&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">plu</dc:creator><pubDate>Sat, 18 Oct 2008 18:13:39 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3143208</link><description>&lt;p&gt;Very interesting.&lt;/p&gt;&lt;p&gt;Maybe next time we'll blend profiling into the rake script.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sat, 18 Oct 2008 07:14:38 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3139038</link><description>&lt;p&gt;Hmmm. I got my rake test down to 2.05 seconds, but my rake spot is .03 seconds.  Consistently.  I am looking for more ways to better the code within the spec.  I think this exercise has taught me some huge lessons about assumptions I have made about what goes on under the hood without actually knowing. Not there yet, but progressing :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Fri, 17 Oct 2008 21:39:00 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3139006</link><description>&lt;p&gt;Thanks for the tip.  ruby-prof got me there quicker than without, I believe.  I have a tendency to "make things work", then go back and make improvements.  I see how this is not always a good thing.  Also, I find that the terseness of Ruby compared to say, C# or Java, is not only a different mindset, but some functions of Ruby are vastly more efficient than others that have the same return value.  In some languages, using regex is faster(?), but in Ruby, using what I presume is regex based, the split function, is a huge cycle hog, particularly if you just mindlessly throw a str.split('') into a looping array.each.&lt;/p&gt;&lt;p&gt;I can only assume that learning the traditional Ruby will help me in this regard.  Simply finding a function that works isn't good enough.  Bad habits I have, I guess.&lt;/p&gt;&lt;p&gt;Rambling further, I think I'm just surprised that similar functionality in Ruby has such vast performance differences.  I obviously don't know what I thought I knew about programming.  I would think I would have had a more obvious confrontation with these issues in my past (I do C# and Java).  I am now feeling humbled. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Fri, 17 Oct 2008 21:36:02 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3135403</link><description>&lt;p&gt;What you might do is write your own include? method, and then redefine the existing method in range. Something like:&lt;/p&gt;&lt;p&gt;class Range&lt;br&gt;  def include?(val)&lt;br&gt;    if val.is_a? Array&lt;br&gt;      # do your check&lt;br&gt;    else&lt;br&gt;      super(val)&lt;br&gt;    end&lt;br&gt;  end&lt;br&gt;end&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 17 Oct 2008 16:25:48 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3135220</link><description>&lt;p&gt;"Is every value in this array between 0...10"     , please&lt;/p&gt;&lt;p&gt;I'm sure I could write my own function to do this quickly, but in the spirit of code reuse...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rajatbaner</dc:creator><pubDate>Fri, 17 Oct 2008 16:13:14 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3134853</link><description>&lt;p&gt;Something like "is this Array within this range"?&lt;/p&gt;&lt;p&gt;Or: Is this point value within this Array?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 17 Oct 2008 15:50:41 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3134775</link><description>&lt;p&gt;In Lecture 5a, the prof showed us some code like this:&lt;br&gt;points = 82&lt;br&gt;grade = case points&lt;br&gt;      when 90..100&lt;br&gt;        'A'&lt;br&gt;      when 80..89&lt;br&gt;        'B'&lt;br&gt;.....&lt;br&gt;      else&lt;br&gt;        'E'&lt;br&gt;      end&lt;br&gt;puts "Points: #{points}; Grade: #{grade}"&lt;/p&gt;&lt;p&gt;How can this be extended to take in an Array instead of a single FixNum ? I've tried a couple of things including === but can't get the syntax quite right. any hints would be much appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rajatbaner</dc:creator><pubDate>Fri, 17 Oct 2008 15:45:49 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3105528</link><description>&lt;p&gt;For the "reference" implementation on my Mac, rake spot takes 0.2 seconds, and rake test takes 0.5 seconds.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 17 Oct 2008 00:58:19 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3105276</link><description>&lt;p&gt;Look at the test again --- the method being tested is not accept (and it is not related to the splat operator).  Also, a proper Ruby variable would be my_hand, not myHand.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Keith</dc:creator><pubDate>Fri, 17 Oct 2008 00:47:49 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3105118</link><description>&lt;p&gt;If I run tc_hand.rb, it executes in about 3/10 of a second.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Keith</dc:creator><pubDate>Fri, 17 Oct 2008 00:39:12 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3103108</link><description>&lt;p&gt;When accepting a card in hand, isn't this ok to do the below - provided that if we initialize our array in the initialie method.&lt;/p&gt;&lt;p&gt;if (dealt_cards.length == 1)&lt;br&gt;    @myHand.push(dealt_cards[0])&lt;br&gt;  else&lt;/p&gt;&lt;p&gt;Similar logic works in card when trying to create a new card and parsing input.  This code does not pass the unit test test_0100_hand_at_020.  The array is initialized and passes the unit test before.  The error I get is that &amp;lt;nil&amp;gt; not expected to be nil. Is there some more information regarding the splat operator in the pickaxe?  I tried looking in there, but couldn;t find anything, maybe I misse it.&lt;/p&gt;&lt;p&gt;Thanks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">akv</dc:creator><pubDate>Thu, 16 Oct 2008 21:28:58 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3103081</link><description>&lt;p&gt;What does "very fast" mean? Is this 5 seconds?  2 seconds?  15 seconds?  Some dependency on the computer, but I am curious to know a ballpark figure so I don't spend more time than necessary on this issue.&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Thu, 16 Oct 2008 21:25:23 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3102478</link><description>&lt;p&gt;I have narrowed it down a bit to my strength algorithm.  Probably rebuilding an array inside a loop rather than just once at initialization.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Thu, 16 Oct 2008 20:19:31 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3100603</link><description>&lt;p&gt;There are tools like ruby-prof that you can use to profile code.&lt;/p&gt;&lt;p&gt;That said, I think you probably have something in accept_and_check that is slowing things down.  These tests should run very fast.  I'd send the code to your TA and see if they can spot something that might be causing your execution time to rise.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Keith</dc:creator><pubDate>Thu, 16 Oct 2008 17:48:15 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3096692</link><description>&lt;p&gt;I note that my tc_hand.rb takes up to 65 seconds to run.  I removed the three longest loops (the three tests loop 1..100) and got it down to 16 seconds to execute.&lt;/p&gt;&lt;p&gt;So.  Is this because my code is, ahem, un-optimized, or does everyone have the same execution time?&lt;/p&gt;&lt;p&gt;Also, I am used to stepping through a debugger to see where the clogs happen.  Is there a recommended method of doing something similar in Ruby to see where my code could be improved?&lt;/p&gt;&lt;p&gt;EDIT:  I see that test_0195_hand_strength_025, test_0193_hand_strength_023 take the longest.  I put a "puts self" in the test code functions to see what was running at execution.  So I took them out and ran them separately, they are all fine.  The difference is I ran them without the "accept_and_check" function.&lt;/p&gt;&lt;p&gt;So....I wonder if accept_and_check is slowing thing down...&lt;/p&gt;&lt;p&gt;Removing "accept_and_check" from the two function reduced execution time for the entire script from over 60 sec to 23 sec.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Thu, 16 Oct 2008 13:58:45 -0000</pubDate></item><item><title>Re: Assignment 2</title><link>http://e168f08.plugh.org/assignments/assignment-2/#comment-3096659</link><description>&lt;p&gt;Thanks! Who knew that searching wikipedia would be the thing to do :)  &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MaureenB</dc:creator><pubDate>Thu, 16 Oct 2008 13:56:09 -0000</pubDate></item></channel></rss>