6 kyu
Find the discounted prices
280 of 549GiacomoSorbi
Loading description...
Arrays
Lists
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.
Error in random tests
Which language? Which error? Help us help you.
golang, the number series must be sorted
Then it's already reported as an issue here: https://www.codewars.com/kata/56f3ed90de254a2ca7000e20/discuss#62c5a34d1c2a720058b4d888
And the post below yours too mentions that.
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.
Very creative kata, congratulations.
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
The pair is not in sequential order, you would have to find them yourself, as written below...
python new test framework is required. updated in this fork
Approved
Rust translation ready for review.
Read the note in the translation discourse.
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.
Problem source link doesn't work
Ruby 3.0 should be enabled.
Enabled in this fork
the descriptions is very bold
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)
See possibly the message below; any clue on how to fix the testing code?
Alright, I removed the extra tests. Now the random test cases will only be valid input strings.
Lovely, thanks!
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 inControl.Applicative' instance Foldable (Either a) -- Defined in
Data.Foldable' instance Foldable Data.Proxy.Proxy -- Defined inData.Foldable' ...plus 88 others In the second argument of
(.)', namelyconcatMap ((\ x -> [x, 3 * x
div` 4]) . div4able . getPositive)'I think is some kind of issue in Haskell which arose recently: can you work well on other katas and are you sure it has nothing to do with your solution, right?
Well, that's just great. The Foldable-Traversable proposal patch seems to have hit CW. For those unaware, the type of
concat
andconcatMap
has changed fromto
And now the code needs to specify which
t
is used. Adding type signatures at the right place will suffice. The kata is now fixed.Thank you again, senpai!
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%!
+1 for honestly admitting a shortcoming :+1:
This comment has been hidden.
Post under bkaes comment down below, so that he can get notified, then :)
Apparently fixed.
Another 'sweet' ;) kata from Mr Sorbi. Be careful, you're in danger of becoming my go-to kataist.
Thanks for your kind feed, albeit I fear I will disappoint you sooner or later, as I try to diversify my interest (and my offer to my trainees) in katas, ranging from very basic to more advanced katas, so not to easy to stay that palatable.
Just be sure to tell me what I do wrong, anyway :)
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.
Thank you for awesome katas as always, GiacomoSorbi! :)
My pleasure, man :)
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.
Do you think now it is ok to close the issue?
I would approve this great kata, when the issue would be closed...
Issue closed, as apparently it is all fixed; feel free to proceed, if you wish so, Steffen :)
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.
Which language and are you sure it is a random test case? Because the last fixed test case should expect
""
as an output.@Giacomo: that's one of the Haskell random tests (the one that does not check whether there are any discounts)
Oh, I see. Did you try something to solve it already?
Why is the input given as a string and not as a list or an array?
Good question: I wanted both to keep it consistent with the code jam version and to let my trainées play a bit with the
.join()
and.split()
methods.You should know that @bkaes "hates" strings:-)
Nice kata but no upvote button!
Meaning you don't like it, find it buggy or what?
Yes I like it because it is interesting BUT I wanted to tell you that there was no upvote button on the page! In other words it is impossible to find it... or maybe I am a bit blind:-) Sorry for my previous post: sentence too short:-(
Uh, how strange :S... The button for the issues, conversely, are still there?
I can see all three of them (and of course cannot do anything with them, as I am the author here).
I can see "Ready", "Minor issues", "Major issues" but no "Upvote". I thought there is an "Upvote" button. I can see it in some other katas.
Ready = Upvote in beta katas.
Wait, does this mean you never upvoted a kata in beta, then :D?
I voted "Ready" without knowing it was the same than "upvoting" elsewhere:-( Voted ready --> +8 or +4 for Giacomo?
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
Because 5220 is "burnt" as the original of 3915. And you know for sure that the smallest number has to be a discounted number, don't you ;)?