6 kyu
Rank Gifts
66Metalowy
Loading description...
Sorting
Logic
Puzzles
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.
I'm also not a fan of the rank inflation, but this kata was definately 7 kyu.
Please mention in the description that different providers can have the same name.
Different people can have the same name.
The description is not too clear; not sure what to suggest - perhaps use code blocks for the examples and follow through from input to output within the same code block?
The input parameters are crazy - the name being the last element of the list is just... wierd - guess it's too late to change that now, and it just adds to the challenge.
You need a test where a name is on the gift list (e.g. 'Kitty'?) such that counting that name as a gift from that name produces the wrong output.
There Is no possibility for a name to be the same as element of the gift.
I was suggesting there should be, but if you are adamant about that perhaps you should specify it in the description.
I added it. Thanks for the suggestion.
Can anyone else other than the author explain what this kata is about?
Ha, good question! As far as I was able to discover, it's about assigning a total value to each giver's gifts. If a gift doesn't occur in the list of gift ranks, it receives no value. But if it does occur in the list of gift ranks, its value is a power of two, with its index in the list of gift ranks used as the exponent. Finally, order the givers from lowest total gift value to highest total gift value and return their names in that order.
The task is complicated by the fact that multiple givers can have the same name, and by the fact that the list used in the input is structured in a bizarre way, with the giver's name in the last position, preceded by any possible number of gifts.
I hope this helps anyone trying to figure it out.
Expected result for fixed test #2 doesn't seem to correspond to the description. Shouldn't the giver who gave the least desirable gift be listed first, and the giver of the most desirable gift be listed second?
The description is so unclear, I can't tell if the fixed tests' expected results are wrong or the description just needs to be improved.
I don't see what is wrong there. Can you explain?
The description says "return a list of people who gave the gifts, ordered from least to most desired." In the second fixed test, Jon gave the least desired gift, so according to the description, Jon should be listed first. If this isn't true, then you need to improve the description.
Ok, I see. The description doesn't specify that it should be ordered by the sum of gift's elements, not the least wanted one. I fixed the description.
Oh. You are talking about single gift elements, not entire gifts. It is not ordered by the least desired gift element, but a whole gift.
OK, now I am creating my result "by the sum of the gift's elements," as you say, giving each actual gift a value that corresponds to its position in the list of gift ranks (plus one in each case, so that even the lowest-ranked gift counts toward the sum). How else would you do that? I'm not sure what value to assign to gifts that don't even occur in the list of gift ranks; right now I'm giving them a zero. The instructions don't say anything about what to do with these.I just happened to look at the values you are assigning to gifts in the example. They are powers of two. The description says nothing about that. That needs to be explained.
This is in a
Heading
Explanation:
Lego Bricks have a value of 1 (2^0).Cat Food has a value of 2 (2^1).
Intercontinental Ballistic Missile has a value of 4 (2^2).
A Single Piece Of Paper has a value of 8 (2^3).
John's gift has a value of 0, and Bob's gift has a value of 2 (because Cat Food has a value of 2). (Gift's value is the sum of all elements of that gift.)
Hi, there's some mixed-up text in the description. It's not a major problem, but it would be better to correct it for clarity.
And you might want to consider using Markdown, which is recommended in the codewars guideline
happy birthday!
Thanks! I misplaced the line break tag. fixed.
the list of words contains duplicate values, which can mess up the first argument
Fixed.
suggestion part:
leste = tuple(random.sample(words, random.randint(2, 6)))
-> here, you could keeprandom.choices
, because one person could offer the same gift several times(I didn't take a look at the description yet)
Issue part:
The number of offered gifts (ie. the number of tuples given as arguments) must also be random. To accomodate this with the function calls, just replace
func(lst, lst2[0], lst2[1], lst2[2], lst2[3], lst2[4], lst2[5], lst2[6], lst2[7], lst2[8], lst2[9])
withfunc(lst, *lst2)
(but with proper variable names... ;) )Hi again,
Moving the technical parts to another issue:
choice
, butsample
)Cheers
Fixed.
Hi,
Well... The description makes no sense. Moreover, the initial solution is incomplete (see point 4).
...and n gifts (Also tuples)
=> the structure of the gifts isn't explained. Which is really a problem when their lengths start to varyhe gives you a tuple of things he would like to get (Sorted from the least wanted to the most wanted.) and n gifts (Also tuples)
-> this is contextual and the user shouldn't have to guess that this is actually implying thatthe function will be called with n+1 arguments
. The first is just storytelling and implies actually nothing about what the arguments of the function are. So the description must clarify this.Value of John's gift is 0, and Value of Bob's gift is 2.
=> Why? sum? min? what if John second gift is also CatFood? => must be sepcifiedWhat the description should do:
what the description is currently doing and shouldn't be doing:
lego brick - 1 (2**0)
could be read as "minus 1", which doesn't make sense. Just spell it out:The value of "Lego Bricks" is 1, because 2**0=1
side note: if you keep blocking reviewers, you'll just lose the authoring privilege. This is your only warning.
Cheers
Many people ca have the same name
as 3, while my third point ishow the order should be determined when one person offers several gift?
=> !??If you don't understand what the problem is or what to do, just ask for clarifications, there's no problem with that. On the other hand, if you keep closing the issues without doing anything, you'll also lose authoring privilege pretty quickly...
Sorry. My changes didn't save. I will redo all of that as fast as I can.
sure, no problem. Post another message when you're done
I have rewriten as much of it as possible. Reply, if there is something I forgot.
The description of this kata is INCOMPREHENSIBLE.
@Metalowy: well, you mostly didn't change anything that was problematic, yeah...
=> read again my message, this time frogetting your affect.
The information that
2 ** gift rank
andcannot be left until the examples: they must be brought up in the description as soon as they become relevant.
Hy mate, first of all, happy birthday!!!
I had a great time solving this kata; I loved the thematic and examples. I always appreciate when a creator includes a little story at the beginning.
I just had a little problem I'd like to address. I'm not a moderator, so take my advice with a grain of salt.
Issue
If given repeated gifts in the gifts he would like to get, what should be done? For example:
Given:
("Lego Bricks", "Cat Food", "Cat Food")
Should
"Cat Food"
be worth2
or4
?Suggestion
If this is a mistake and the given list is supposed to be unique, you could try using the
choices
function from therandom
module; it will pickk
elements without repetition from the givenIterable
.Otherwise, please specify what should be done in case we receive repeated gifts in the first input.
Side Note
There are a few grammar mistakes in the Story section; I'm not one to judge, but there are people who aren't big fans of this.
As someone who has English as their second language, I often use QuillBot to verify my writing; maybe it could be helpful to you too.
Final
Don't let this discourage you from making other katas; I'm sure you'll improve your craft with sufficient practice. Also, don't take the mod's criticism too personally; they can be pretty harsh at times.
Hopefully I didn't sound condescending throughout this comment, and I apologize if I did. Anyways, best of luck, mate, and happy coding.
Also, sorry, mods, if I'm not supposed to do this.
When I changed random.randind to choice, the first problem resolved itself. And I corrected some grammar. I am truly motivated by this message, so thank you.
You sure can, no problem with that. Tho you forgot one thing:
Same goes for other users reviewing betas regularly.
Cheers
Many issues with this Kata:
Description is vague and difficult to understand
Example:
It's entirely unclear how these "values of elements" are derived from the input tuple alone. One could extrapolate and guess that the values of each element should be determined as increasing powers of 2 based on the index within the input tuple, but it's not explicitly specified which is not acceptable.
Poor choice of data structures
Tuples are good for data where the number of elements are pre-determined and fixed. They are not for data where the number of elements are variable and cannot be pre-determined - use a list instead.
Broken tie-breaking logic in reference solution
Python's built-in sorting functions are stable by default so input order should already be preserved - see my solution below for an example.
On the other hand, the reference solution does not always preserve input order - it's difficult to present a concrete example given the way the inputs are structured for this Kata but it's possible to confirm this by printing a transformed view of the inputs and comparing the output of my solution from that of the reference solution.
Please refer to Creating your first Kata for guidelines on authoring a good Kata.
This comment has been hidden.
Example has been fixed