Ad
  • Custom User Avatar

    a lot of people probably posted this solution when minimum was new to prelude, it was only added in 2015

  • Custom User Avatar
  • Custom User Avatar

    Applied.

  • Custom User Avatar

    if it overflows the flower will have many petals, an overflower if you will

  • Custom User Avatar

    Definitely more in the spirit of the question

  • Custom User Avatar

    I was wrong. I don't know what I meant with the second sentence (after all it's two years ago).

  • Custom User Avatar

    @muesli4, can you elaborate on conditions when you expect problems to happen for this solution?
    https://downloads.haskell.org/~ghc/6.0/docs/html/base/Data.Int.html states "All arithmetic is performed modulo 2^n, where n is the number of bits in the type."

  • Custom User Avatar

    Fixed

  • Custom User Avatar

    I get it now. I had a feeling that I was missing something.

  • Custom User Avatar

    There's a good chance that I'm wrong, but have you actually given a proof that thirt will always return a number less than 100?
    You have shown that the sum of the products will always be less than the original number, but what about 191. The sum of the products for 191 is equal to 100.

  • Custom User Avatar

    Trying to recognize patterns "early on" in data sets can sometimes be dangerous. Of course, "early on" is a relative term.
    Experience has taught me that if you think you found a pattern, and it holds for "a lot" of inputs but fails "every now and then," you probably didn't find a pattern. Because, now you have to modify your pattern so that it holds for those inputs that failed for the previous pattern. And you're probably going to find that the new pattern eventually fails for some input. So you could modify the pattern again, but at this point you should probably realize that this new pattern has the potential to fail again at some later point. You might be inclined to belive that perhaps there is a pattern to the failure points, and you might actually find a pattern that works for "a long time."
    The only way to be sure that you found an acurate pattern is to formulate a rigorous mathematical proof.
    Now, I don't have the time, or mathematical background to formulate a proof for this, but I do have some comments.

    • You mention "valid/safe" integers. The assumed upper bound for the thirt function, as given by the problem description, is infinity (n >= 0).
      No matter how many numbers you check, you can never be 100% certain that your pattern holds for all numbers in the given range.

    • I'm not sure what you mean by "A simple pattern from 9 to 2000." You kind of skipped over the fact that something strange happens between 99 and 100. Up until that point, you increment the argument by 1, and the result is incremented by 1. At 99 to 100, the argument is incremented by 1, but the result is decremented by 90. After every 90 increments to the agrument after that, you again need to decrement by 90. This holds true untill 999 to 1000, at which point the result is decremented by 77.

    • I did find something that I thought was interesting. For every input from 1 to 10,000,000 the thirt function returns a number that is less than 100. It took 7 minutes to verify this, but I have no idea if this holds true for all numbers greater than 0.

  • Custom User Avatar
  • Default User Avatar

    Good guessing, the one stayed in the keyboard... Lots of thanks, corrected!

  • Custom User Avatar

    Sorry, I've only been coding for about six months.
    I didn't want to use globals, and I didn't want to mess with class definitions, and I didn't want to open the Kernel.
    I spent most of a day working on this one, and I just wanted it to pass the tests.
    I was very tired.

  • Custom User Avatar

    Haskell Test Cases on line 17.
    I think seriesSumAux was supposed to be seriesSumAux1

  • Loading more items...