6 kyu
Goldbach’s Conjecture
262 of 381Protino
Loading description...
Mathematics
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Description is contradictory, claims that
n
is both always even but also provides a prescribed return value for whenn
is odd. Python at least also tests for oddn
which likely should be removed.python new test framework is required. updated in this fork
Approved
Ruby error on submit:
main.rb:48:in
block in sol_goldbach_partitions': uninitialized constant Prime (NameError) from main.rb:47:in
tap' from main.rb:47:insol_goldbach_partitions' from main.rb:57:in
block (3 levels) intimes' from main.rb:55:in
block (2 levels) inblock in describe' from /runner/frameworks/ruby/cw-2.rb:46:in
measure' from /runner/frameworks/ruby/cw-2.rb:51:indescribe' from /runner/frameworks/ruby/cw-2.rb:202:in
describe' from main.rb:54:inblock in <main>' from /runner/frameworks/ruby/cw-2.rb:55:in
block in describe' from /runner/frameworks/ruby/cw-2.rb:46:inmeasure' from /runner/frameworks/ruby/cw-2.rb:51:in
describe' from /runner/frameworks/ruby/cw-2.rb:202:indescribe' from main.rb:20:in
fixed
My code is correct as I test it on my local computer. But it takes too much time to run here and failed with an execution error. Maybe the problem is with my connection. Any ideas please?
Try to review and optimize your code
made a list of prime values in python from 0 to n and checked if sum of two primes is equal to n and first value less than or equal to second value then converted them to string and appended values to partition list ... sampe tests are successful when submitting got the error 'NameError: name 'primes' is not defined' for large integers.......any help please
I falled in the same situations, but with test of 32000 correct!
It gives the same error to me. I don't think it's our fault. Blame the tests.
Error fixed in test cases -- try to submit your solutions now.
JavaScript and Crystal translations kumited (plus I was beaten by a short time translating it into Ruby).
Also, needs random test cases (try to look at my Crystal code, it should be fine to use the native Python
randint
to get the same in your language).Oh, also: I would put a few more high-numbered test cases, as currently only one test go to
32000
, the rest being rather far from it.Surprised this was approved without random tests. Please add random tests.
Random tests added to python.
Description updated and example tests fixed.
Can you also approve the translations while at it :)?
I can't -- author is "too active" ;-)
Well, actually
7=2+5
, so the example7 -> []
written in the description is not justified.Read the description carefully. Is
7
even?I have read it.
7
is odd, nevertheless it is a sum of two primes.German mathematician Christian Goldbach (1690-1764)conjectured that every even number greater than 2 can be represented by the sum of two prime numbers. For example, 10 can be represented as 5+5 or 7+3.
Your job is to make the goldbach_partitions(n) function return a list containing all unique possible representations of n in an increasing order. Hence, the first addend must always be less than or equal to the second to avoid duplicates.
n
to be even in this description of the actual task.Ok fine. I'll update the constraints and also re-edit the description.
Good one! It seems to already exist, if you search goldbach in katas you will find two others.
Maybe make a slight change to your problem to make it unique?
Hi, i think there are some mistakes:
(by the way i think it's a duplicate, found it three times at the "kata search", two of it are python and... no random tests;-))
See Goldbach's conjecture says
every even number greater than 2 ....
15 is a odd number.Thanks for letting me know about the test cases and yea I found those duplicates later in kata search.
Ah ok... once again i was a little bit too quick (haven't seen 'even');-)... So i change my solution too;-). Thanks;-)!
Happy to help :)