so I was just working on an exorcize using the Prime module and on one test
out of like 50 I was getting an error, so after some digging around I found
this:

that should be the factors of 8, but unless I'm totally out of my mind and
my math is WAY worse than I thought, I don't think 3 is a factor of 5.
pretty sure that should be 4.
every other number I tried ranging from single digit numbers to numbers up
to the millions worked just fine, it was just that 8 being all wonky.
anyone run across this before? is there some logical explanation as to why
I would get a 3 there? or is this just a bug I should go report to....
wherever you report ruby bugs to?

so I was just working on an exorcize using the Prime module and on one test
out of like 50 I was getting an error, so after some digging around I found
this:

that should be the factors of 8, but unless I'm totally out of my mind and
my math is WAY worse than I thought, I don't think 3 is a factor of 5.
pretty sure that should be 4.

every other number I tried ranging from single digit numbers to numbers up
to the millions worked just fine, it was just that 8 being all wonky.

What do you mean by "worked just fine"? For instance, is the result [[2,
2]] correct for 4.prime_division? How about 2.prime_division being [[2,
1]]? If you accept those as working, you should be able to see how the
result you got fits into the big picture. Once you've developed a
hypothesis for these numbers, try doing #prime_division on numbers that
have factors other than 2.

···

On Tue, Dec 06, 2016, Micky Scandal wrote:

anyone run across this before? is there some logical explanation as to why
I would get a 3 there? or is this just a bug I should go report to....
wherever you report ruby bugs to?

so I was just working on an exorcize using the Prime module and on one
test out of like 50 I was getting an error, so after some digging
around I found this:

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, let's look at 10:
irb(main):002:0> 10.prime_division
=> [[2, 1], [5, 1]]

This would be expressed as:
10 = 2^1 * 5^1

So, let's look at 50, which should give us another power:
irb(main):005:0> 50.prime_division
=> [[2, 1], [5, 2]]

Also known as:
50 = 2^1 * 5^2

···

On 2016-12-06 20:37, Micky Scandal wrote:

that should be the factors of 8, but unless I'm totally out of my mind
and my math is WAY worse than I thought, I don't think 3 is a factor
of 5. pretty sure that should be 4.
every other number I tried ranging from single digit numbers to
numbers up to the millions worked just fine, it was just that 8 being
all wonky. anyone run across this before? is there some logical
explanation as to why I would get a 3 there? or is this just a bug I
should go report to.... wherever you report ruby bugs to?

Looks to me like an array of arrays, which makes me think that it's
indicating 2 to the 3 power. I'm on my phone, so i can't confirm, but the
documentation seems to indicate as much.

I would expect, for example, that 40.prime_division is [[2,3],[5,1]].

so I was just working on an exorcize using the Prime module and on one
test out of like 50 I was getting an error, so after some digging around I
found this:

that should be the factors of 8, but unless I'm totally out of my mind and
my math is WAY worse than I thought, I don't think 3 is a factor of 5.
pretty sure that should be 4.
every other number I tried ranging from single digit numbers to numbers up
to the millions worked just fine, it was just that 8 being all wonky.
anyone run across this before? is there some logical explanation as to why
I would get a 3 there? or is this just a bug I should go report to....
wherever you report ruby bugs to?

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:

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