<?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 1</title><link>http://e168f08.disqus.com/</link><description></description><atom:link href="https://e168f08.disqus.com/assignment_1/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 05 Oct 2008 16:22:47 -0000</lastBuildDate><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2882655</link><description>&lt;p&gt;Review your code again. If you have to, try commenting out methods until it doesn't show the error.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 05 Oct 2008 16:22:47 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2882255</link><description>&lt;p&gt;I've lookded into that. Apparently all blocks are ended fine and I tried changing the location of solution to the 'other' folder, but the same error.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sa</dc:creator><pubDate>Sun, 05 Oct 2008 15:32:21 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2882061</link><description>&lt;p&gt;"syntax error, unexpected $end, expecting kEND"&lt;/p&gt;&lt;p&gt;Look at your code and verify that all blocks are ended correctly.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 05 Oct 2008 15:09:10 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2881956</link><description>&lt;p&gt;I am having this output when i run the solution test.&lt;/p&gt;&lt;p&gt;C:\assn1-1.0.0\test\other&amp;gt;ruby solution_set_test.rb&lt;br&gt;C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_re&lt;br&gt;quire': C:/assn1-1.0.0/student_solution_set.rb:244: syntax error, unexpected $en&lt;br&gt;d, expecting kEND (SyntaxError)&lt;br&gt;        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re&lt;br&gt;quire'&lt;br&gt;        from solution_set_test.rb:4&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sa</dc:creator><pubDate>Sun, 05 Oct 2008 14:55:40 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2824806</link><description>&lt;p&gt;1. No. You cannot assume that if you pass all tests, you'll get 100%. Two reasons:&lt;/p&gt;&lt;p&gt;a. You may write a solution that ONLY passes the tests. You need to write code that satisfies the requirements, which we stated in words and sentences. The tests may help, but it is entirely possible that the data we use in the tests misses an edge case.&lt;/p&gt;&lt;p&gt;b. Code that passes the tests may be grossly inefficient, inelegant, relying on regular expressions, etc.&lt;/p&gt;&lt;p&gt;2. No. Pick your ten best and submit those. Comment out the solutions for the ones you don't want to submit.&lt;/p&gt;&lt;p&gt;If you solve all twelve, we will pick 10 according to any rule that pops into our heads at the moment (randomly; first 10; easiest to grade; whatever).&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 03 Oct 2008 13:48:48 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2824630</link><description>&lt;p&gt;Regarding Grading,&lt;br&gt;- If our code passes all the tests in the solution_set_test.rb, can we assume we'll get 100% ?&lt;br&gt;- if  there are extra tests with some weird cases we have not accounted for, we'll lose points. If so, can we turn in all 12, and the grader will drop the lowest two problems?&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rajatbaner</dc:creator><pubDate>Fri, 03 Oct 2008 13:41:20 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2824296</link><description>&lt;p&gt;Excellent.  That is exactly what I was looking for!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">LanceB</dc:creator><pubDate>Fri, 03 Oct 2008 13:28:47 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2824106</link><description>&lt;p&gt;collect means: Invokes block once for each element&lt;/p&gt;&lt;p&gt;So ONE element should get passed into the block. You have two block parameters, so that is not right.&lt;/p&gt;&lt;p&gt;The classic way to have some value "accrue" is with inject. E.g.,&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt; [ 1, 2, 3 ].inject(5) { |m, e| m += e }&lt;br&gt;=&amp;gt; 11&lt;/p&gt;&lt;p&gt;Here I'm starting the memo (m) off at 5, and am adding each element (1, 2, 3) to the memo successively.&lt;/p&gt;&lt;p&gt;This might provide more clarity:&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt; [ 1, 2, 3 ].inject(5) { |m, e| m += e; puts "total so far: #{m}"; m }&lt;br&gt;total so far: 6&lt;br&gt;total so far: 8&lt;br&gt;total so far: 11&lt;br&gt;=&amp;gt; 11&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 03 Oct 2008 13:16:18 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2824018</link><description>&lt;p&gt;I am sure this is probably ridiculously obvious but I am having a terrible time trying to get a counter started in a block so that I can execute an if statement based upon its value.  Is there a way to pass the initial value without the inject method?  I have tried something like this but the values never increase even though an array shows that it did indeed loop through the array:&lt;/p&gt;&lt;p&gt;a.collect {|val, counter| counter += 1; print counter.to_s}&lt;/p&gt;&lt;p&gt;Help!&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">LanceB</dc:creator><pubDate>Fri, 03 Oct 2008 13:09:08 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2823646</link><description>&lt;p&gt;I am not sure what you mean by "swallowed up."&lt;/p&gt;&lt;p&gt;Notice:&lt;/p&gt;&lt;p&gt;h = {"hither"=&amp;gt;2, "baz"=&amp;gt;1, "foo"=&amp;gt;500}&lt;br&gt;p h.sort {|a,b| puts b; a[1]&amp;lt;=&amp;gt;b[1]}&lt;/p&gt;&lt;p&gt;results in:&lt;/p&gt;&lt;p&gt;[["baz", 1], ["hither", 2], ["foo", 500]]&lt;/p&gt;&lt;p&gt;OK? I don't see anything getting "swallowed up."&lt;/p&gt;&lt;p&gt;If you like, e-mail your implementation of problem 6 to your TA/grader.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 03 Oct 2008 12:44:19 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2822409</link><description>&lt;p&gt;Ok, I was trying to sort an array by val, then flatten it and to a diff with the hash values but my hash keeps getting re-written.  Does that maake sense or should I rethink my strategy.  I guess either way could you exmplain what  the line is doing h.sort {|a,b| a[1]&amp;lt;=&amp;gt;b[1]}  and why my pieces of my hash are getting gobbled up?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">akv</dc:creator><pubDate>Fri, 03 Oct 2008 11:21:18 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2820455</link><description>&lt;p&gt;you should think very, very hard about what you are trying to do. What do you think "sorting a hash" means? Note that a hash has keys and values. Do you want to sort by the keys or the values? Also note that a hash is unordered. The result of "sorting" a hash is an array of arrays. Is that what you want?&lt;/p&gt;&lt;p&gt;I would recommend reassessing your basic strategy in light of the problem.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Fri, 03 Oct 2008 09:16:20 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2815801</link><description>&lt;p&gt;sorry, i am looking for a little frther clarification with the line h.sort {|a,b| a[1]&amp;lt;=&amp;gt;b[1]}&lt;/p&gt;&lt;p&gt;Also, if I use the following hash - h = { "a" =&amp;gt; 20, "b" =&amp;gt; 30, "c" =&amp;gt; 10 } - then the hash does not get modified when I run the sort on the line above, but if I use the has in the hw problem, then 2 of the elements get dropped?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">akv</dc:creator><pubDate>Thu, 02 Oct 2008 23:06:55 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2815763</link><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;When I replace the code int he pixaxe f&lt;/p&gt;&lt;p&gt;h = { "a" =&amp;gt; 20, "b" =&amp;gt; 30, "c" =&amp;gt; 10 }&lt;br&gt;h.sort {|a,b| a[1]&amp;lt;=&amp;gt;b[1]}&lt;/p&gt;&lt;p&gt;h.sort {|a,b| a[1]&amp;lt;=&amp;gt;b[1]} &lt;br&gt;with code pertinent to problem 6, then some of the values in the hash get dropped?  Can someone explain a little more what the folowing line does&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">akv</dc:creator><pubDate>Thu, 02 Oct 2008 23:05:00 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2787522</link><description>&lt;p&gt;There may be an over-the-counter medication that can help with that.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Wed, 01 Oct 2008 17:11:51 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2787426</link><description>&lt;p&gt;I think I just had an epiphany.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">vaughanatworld</dc:creator><pubDate>Wed, 01 Oct 2008 17:06:34 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2787183</link><description>&lt;p&gt;If you think you need more block parameters, then you should be writing the code that does the enumeration yourself -- you are probably no longer in the realm of using utility methods such as .inject, .map, etc.&lt;/p&gt;&lt;p&gt;I.e., write the method that does the yield.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Wed, 01 Oct 2008 16:50:29 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2787126</link><description>&lt;p&gt;On block parameters, for Enumerable#inject there is |memo, obj| . From the context of what you are saying above, is it possible to get memo1, memo2 ... ? I can force it with array of arrays etc but it would be nice to short circuit this with user created block parameters. Is this possible?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">vaughanatworld</dc:creator><pubDate>Wed, 01 Oct 2008 16:46:28 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2722461</link><description>&lt;p&gt;We can definite correlate the "@" one, so use that.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 28 Sep 2008 23:09:34 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2720926</link><description>&lt;p&gt;Harvard has assigned me two ID #s, neither of which are named "student id number".&lt;/p&gt;&lt;p&gt;One is named "Harvard ID (HUID)", and the other is named just plain "ID Number", which starts with an "@" sign.&lt;/p&gt;&lt;p&gt;Which one should we use for the "student id number" on homework assignment 1?&lt;/p&gt;&lt;p&gt;def info_student_id&lt;br&gt;  ""&lt;br&gt;end&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">swithin</dc:creator><pubDate>Sun, 28 Sep 2008 22:08:27 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2715373</link><description>&lt;p&gt;Yes.  I know that.  :)&lt;/p&gt;&lt;p&gt;I am just going through irb and trying out all the methods to see if my understandings of each method is valid - it was just part of the exercise that I came across these two methods.&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>Sun, 28 Sep 2008 11:38:51 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2713418</link><description>&lt;p&gt;Just FYI: Good solutions can be expressed for all of the assigned problems without using each_sice and each_cons.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jgn</dc:creator><pubDate>Sun, 28 Sep 2008 07:56:30 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2667065</link><description>&lt;p&gt;Found my own answer at &lt;a href="http://codesnippets.joyent.com/user/deckard/tag/ruby" rel="nofollow noopener" target="_blank" title="http://codesnippets.joyent.com/user/deckard/tag/ruby"&gt;http://codesnippets.joyent....&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Quotes from the website:&lt;br&gt;"Rdoc is causing some serious confusion with libraries.&lt;/p&gt;&lt;p&gt;In core documentation, Enumerable defines each_slice method.&lt;/p&gt;&lt;p&gt;Extend this module into your class and each_slice is not defined.&lt;/p&gt;&lt;p&gt;Reason? each_slice is NOT in the core Enumerable module, but rather the Standard Library Enumerable::Enumerator class, even though the ruby-doc core class documents say otherwise.&lt;/p&gt;&lt;p&gt;You must&lt;/p&gt;&lt;p&gt;require 'enumerator'&lt;/p&gt;&lt;p&gt;to have each_slice is available as a method to your class."&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">plu</dc:creator><pubDate>Sun, 28 Sep 2008 00:50:54 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2667029</link><description>&lt;p&gt;Hmm.  I actually got it to work when typing in&lt;/p&gt;&lt;p&gt;require 'enumerator'&lt;/p&gt;&lt;p&gt;within irb.  Why is this the case?  Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">plu</dc:creator><pubDate>Sun, 28 Sep 2008 00:44:03 -0000</pubDate></item><item><title>Re: Assignment 1</title><link>http://e168f08.plugh.org/assignments/assignment-1/#comment-2667008</link><description>&lt;p&gt;The method each_slice and each_cons seem to be defined within the Enumerable.  However, when I am invoking it, it tells me "NoMethodError: undefined method' - this occurs for both Array and Range.  Even if I use the sample line from the documentation&lt;/p&gt;&lt;p&gt;e.g.&lt;br&gt;(1..10).each_slice(3) {|a| p a}&lt;/p&gt;&lt;p&gt;It still throws an error.  Are these methods not valid?  Thanks!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">plu</dc:creator><pubDate>Sun, 28 Sep 2008 00:37:41 -0000</pubDate></item></channel></rss>