Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7250
| X-Received | by 10.176.5.165 with SMTP id e34mr6186739uae.0.1463563437602; Wed, 18 May 2016 02:23:57 -0700 (PDT) |
|---|---|
| X-Received | by 10.157.37.168 with SMTP id q37mr459521ota.1.1463563437390; Wed, 18 May 2016 02:23:57 -0700 (PDT) |
| Path | csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!11no4847445qgt.0!news-out.google.com!l67ni1409ith.0!nntp.google.com!sq19no6306753igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.ruby |
| Date | Wed, 18 May 2016 02:23:57 -0700 (PDT) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=93.51.167.60; posting-account=bj9PDQoAAABOGmvJHTHNTl4b2srfmcmg |
| NNTP-Posting-Host | 93.51.167.60 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <bfc6c044-e8ff-436d-af00-038742e45c3f@googlegroups.com> (permalink) |
| Subject | Curious about some comments I received on some of my code |
| From | ngw@nofeed.org |
| Injection-Date | Wed, 18 May 2016 09:23:57 +0000 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Received-Bytes | 3278 |
| X-Received-Body-CRC | 1822084339 |
| Xref | csiph.com comp.lang.ruby:7250 |
Show key headers only | View raw
Hi, I recently took a coding challenge for a job, and as part of my application they sent me a coding challenge I had to pass.
Today I received the answer, and I've been rejected. No big deal, I already found a job I like a lot (and part of it will be in Erlang, yay!), but the comments they made over my code left me... baffled. I would like to have if possible a code review (really not a lot of code) and some comments over the issues they point out.
The task was "Write a program that prints a multiplication table of primes numbers."
I will omit the one-liner Thor script that actually generates the thing, and post my implementation.
class Fixnum
def erathostenes
starting_array = (2..self).to_a
starting_array.each_with_index do |n, outer|
(outer..(starting_array.count - 1)).each do |inner|
if Fixnum.erathostenes_sieves?(starting_array[inner], starting_array[outer])
starting_array[inner] = nil
end
end
starting_array.compact!
end
end
def self.erathostenes_sieves?(number, dividend)
number % dividend == 0 && number / dividend != 1
end
end
Here is the class that prints the table:
module FundingCirclePrimeTable
class Table
attr_reader :numbers, :rows
def initialize(count)
@count = count
@numbers = @count.erathostenes
@rows = @numbers.collect {|n| [n] + @numbers.last(@count - 1).map {|i| (i * n).to_s }}
end
def to_s
Terminal::Table.new(headings: @numbers.map(&:to_s).unshift(' '), rows: @rows)
end
end
end
Yes, the attr_reader in the last class isn't needed, I added it for simplicity when writing tests, and at some point I used an each_with_index and forgot about the index, my bad, left some dirty when refactoring, my bad and I count it as a problem in my code.
They told me that "The feedback from the team showed that the tests provided complete coverage, however the code had a few issue regarding naming and organising and contained quite a few clusters of functionality in a few lines."
Also consider I'm not a native english speaker.
What you guys think? Maybe it's because I opened Fixnum?...
TIA,
ngw
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar
Curious about some comments I received on some of my code ngw@nofeed.org - 2016-05-18 02:23 -0700 Re: Curious about some comments I received on some of my code Robert Klemme <shortcutter@googlemail.com> - 2016-05-21 22:01 +0200 Re: Curious about some comments I received on some of my code "WJ" <w_a_x_man@yahoo.com> - 2016-07-23 23:43 +0000
csiph-web