Ad
  • Custom User Avatar

    This!

    I have been reading a bit and found no simple solution. Without knowing the constraints DP could be too slow. Small number of towns large values for the distances. Without being able to printi the input of the test that times out it's hard to solve this.

  • Custom User Avatar

    The generalization does affect the definition. Generalizing from the whole numbers to the integers (includes negative numbers) makes it natural to generalize the definition of primes. It's strange to do so since generalizing to complex numbers is more useful.

    I read the description again. It leaves no ambuiguity, so the fault is on me. I just saw negative numbers and primes and assumed we would use a definition generelized to integers. I should have been more diligent before making an issue. My only excuse is that there are others.

  • Custom User Avatar

    Wikipedia's article first sentence is "A prime number (or a prime) is a natural number...". This excludes de facto negative integers. In the paragraph you mention: " The integers are a ring, and the prime numbers in the integers have been generalized to rings in two different ways,.." This is a generalization of prime numbers, and doesn't affect the definition of what is a prime number. Moreover, if anyone would have a doubt, the description clearly explains what must be considered a prime number in this kata. Removing the kata for this would just be ridiculous.

  • Custom User Avatar
  • Custom User Avatar

    Maybe just remove this Kata? In Python the tests are stating that -5 and -41 are not prime. That's not correct.

    I know that the definition they teach this is something like this: A prime is a positive integer p>1 that has no positive integer divisors other than 1 and p itself.

    Negative numbers are excluded. In fact, they are given no thought. Wikipedia does the same. Notice how it's not mentioned that no negative number is a prime on the wiki page. It's simpler and for most purposes not addressing it works.

    Now if you actually want to check if a negative number is a prime you should extend the definition to handle negative numbers.

    https://en.wikipedia.org/wiki/Prime_number#Prime_elements_in_rings
    https://math.stackexchange.com/questions/1002459/do-we-have-negative-prime-numbers

  • Custom User Avatar

    datachap is right, Kacarott is wrong.

    The rest of the paragraph on Wikipedia:

    A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself. However, 4 is composite because it is a product (2 × 2) in which both numbers are smaller than 4. Primes are central in number theory because of the fundamental theorem of arithmetic: every natural number greater than 1 is either a prime itself or can be factorized as a product of primes that is unique up to their order.

    It only relates to natural numbers.

    Asking to check if a negative number is a prime I would expect more diligence. It's not trivial. On wiki you want to check Prime elements in rings if you include negative numbers.

    You could also go here: https://math.stackexchange.com/questions/1002459/do-we-have-negative-prime-numbers to learn more.