I would have see the code you're using to really know..


It was just an exorcize at exercism.io. the link to the (now working right)
code is right here:

http://exercism.io/submissions/05e33e2c4a984ae4bc1af3f76b87a9f0

Rule of thumb: when you think you've found a bug in a language, try to dig
deeper and see what the deal is, because, most likely, it ain't a bug.  In
this case, you're mis-interpreting the output.  What it's telling you is
that 8 = 2 ^ 3.  As a different example

I really didn't think it was but for the life of me, I couldn't figure out
why it was just that one test that was failing. but as soon as someone
clarified what I was actually getting it all started coming back.

What do you mean by "worked just fine"?

Write a program that converts a number to a string, the contents of which
depend on the number's factors.

- If the number has 3 as a factor, output 'Pling'.
- If the number has 5 as a factor, output 'Plang'.
- If the number has 7 as a factor, output 'Plong'.
- If the number does not have 3, 5, or 7 as a factor,
  just pass the number's digits straight through.

that was the objective and there were about 20 test cases which all worked
just fine with the exception of '8' (expected 8 but returned pling)

heres the method:

  def self.convert(num)
    # factors =
num.prime_division.flatten.uniq                                   # changed
this line:
    factors = num.prime_division.map {|ary|
ary.delete_at(0)}                # to this. and now all cases work
    ans = []
    if factors.include?(3) || factors.include?(5) || factors.include?(7)
      factors.each do |n|
        if n == 3
          ans << "Pling"
        elsif n == 5
          ans << "Plang"
        elsif n == 7
          ans << "Plong"
        end
      end
      return ans.join
    else
      num.to_s
    end

  end
end
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>