6 kyu

Find the discounted prices

280 of 549GiacomoSorbi
Description
Loading description...
Arrays
Lists
Algorithms
  • Please sign in or sign up to leave a comment.
  • redsteel2 Avatar

    Error in random tests

  • janpi Avatar

    The Go random tests seem to be generating invalid inputs. The problem statement says that the numbers will be sorted from smaller to largers but the random tests generate unsorted inputs.

  • ahmet_popaj Avatar

    Very creative kata, congratulations.

  • uday-78 Avatar

    Could someone explain me the problem that how the we are getting the ouput i am not able to understand @GiacomoSorbi or any one else and how the pair are forming

    input "15 20 60 75 80 100"

    for this pair of discount,initial can be 15 20 , 60 75 , 80 100

    so for this all the discount prices could be 15 , 60 , 80 so how the output is 15 ,60 ,75

    input 9 9 12 12 12 15 16 20

    for this pair of discount , initial will be 9 9 , 12 12 , 12 15 , 16 20

    so for this output will be 9 , 12 , 12 , 16 so how the output is 9 , 9 ,12 ,15

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Awesome A.D. Avatar

    Rust translation ready for review.

    Read the note in the translation discourse.

  • UlrichBerntien Avatar

    Go implementation, Random tests:

    One random test was: 605703616 454277712 165357188 124017891 446130320 ...
    The numbers are not sorted.

    But in the description:
    Every input will always have all the prices in pairs (initial and discounted) sorted from smaller to bigger.

  • Romank_0 Avatar

    Problem source link doesn't work

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • bluiisdave Avatar

    the descriptions is very bold

  • DealPete Avatar

    The description implies that the input will always be a valid list of price pairs, but the random test cases test for invalid input (at least in Haskell)

  • cesare63 Avatar

    Hi, Giacomo, could you pls check the source of the following message:

    /tmp/haskell11722-18-1xoashi.1d16vfgvi/Main.hs:39:40: No instance for (Foldable t0) arising from a use of concatMap' The type variable t0' is ambiguous Note: there are several potential instances: instance Foldable (Control.Applicative.Const m) -- Defined in Control.Applicative' instance Foldable (Either a) -- Defined in Data.Foldable' instance Foldable Data.Proxy.Proxy -- Defined in Data.Foldable' ...plus 88 others In the second argument of (.)', namely concatMap ((\ x -> [x, 3 * x div` 4]) . div4able . getPositive)'

  • mn113 Avatar

    I need to learn to read! Somehow, I missed the part where the discount was always 25%, and wrote a solution which figures out the correct discount between 5% and 95%!

  • Ivan Diachenko Avatar

    This comment has been hidden.

  • marudine Avatar

    Another 'sweet' ;) kata from Mr Sorbi. Be careful, you're in danger of becoming my go-to kataist.

  • gabbek Avatar

    Every input will always have all the prices in pairs (initial and discounted) sorted from smaller to bigger.

    "9 9 12 12 12 15 16 20"

    pairs - (9, 9), (12, 12), (12, 15), (16, 20)

    Maybe the bit about pairs could be reworded a bit to make sure it's clear for everyone? I got a bit confused at start.

  • gabbek Avatar

    Thank you for awesome katas as always, GiacomoSorbi! :)

  • bkaes Avatar

    Haskell variant has some bugs:

    • absolute random tests in Haskell aren't sorted (fixed)
    • negative values (fixed)
    • reference solution recognices wrong prices as discounts, e.g. 4 as 25% discount of 5 (fixed)

    I think some other Haskellers should have a look and check that there aren't any other issues before this issue gets resolved.

  • zamcl Avatar

    I need help; I'm always getting such errors:

    works for absolute random tests Falsifiable (after 2 tests): expected: "" but got: "1" "1"

    I don't understand if it's a mistake in my code or in the random test.

  • bkaes Avatar

    Every input will always have all the prices in pairs (initial and discounted) sorted from smaller to bigger.

    Why is the input given as a string and not as a list or an array?

  • g964 Avatar

    Nice kata but no upvote button!

  • myjinxin2015 Avatar

    In this testcase: Test.assertEquals(findDiscounted("3915 5220 6960 9280 17496 19926...... 346030080"); Why the correct answer is not include "5220" ? 6960 * 0.75=5220