6 kyu
Fizz Buzz Reloaded
129 of 358the_Hamster
Loading description...
Fundamentals
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.
python new test frameworks
Approved by someone
Next time I would prefer that instead of relying on implementation details such as ordered dicts/Maps you simply provide an array of tuplies (i.e. the result of
functions.entries()
in JS). the V8 engine happens to also have ordered Maps and Sets, but that is not guranteed to happen in other JS engines.what about this ?
If multiple functions are true for any given x, return them in same order found in the intial dictionary. (for example, in the case above 15 is "fizzbuzz" not "buzzfizz" because "fizz" appears first)
But a "dictionary" should have no "order"..?
But dictionaries in Python 3.6 are ordered, no?
Oh really? I really don't know new properties in py3.6.
May I firstly clarify a bit, do you really mean that
when I input {1:2,3:4} and {3:4,1:2} they are actually different
, or justI just simply use the dict as a list and need not to care about the order
?yes, see the note at the end of the description.
crossed messages. To be more precise: dict for py3.6 and above retains the order in which the items have been pushed in. So it's "ordered", but not "sorted".
As far as I remember, they are still not officially ordered, it's just an implementation detail.
This kata is designed with Python3.6 in mind. In this version of Python dictionary's are ordered.
Well, I am still not understanding.. Does that mean that we should have
while
?
^ for this kata you shouldn't have to do anything with the functions other than iterate through them (e.g "for func in functions: do X")
As for ordered dicts being a 3.6 implementation detail yes that is the case. However I've seen in mentioned in a tweet[1] that they plan on keeping it since ordered dicts have turned out to be suprisingly useful.
[1] https://twitter.com/raymondh/status/850102884972675072?lang=en
True, I've done a little research today to check this and it was stated that Python 3.7 will have ordered dicts as a language feature.
Thanks for all explanations above. Now I know that "dict is ordered" is a new implementation feature in py3.6, which means (I think) that when I do
list(a dict)
, I actually get a sorted list, while it may not be sorted before 3.6.However, in this kata, what I see is that the order I use should be the order I type. I mean when I type
{a:b,c:d}
and{c:d,a:b}
, they should cause different results, or simply I should at leastbool({1:2,3:4}=={3:4,1:2})==False
. I think this shouldn't be, so I asked to check whether I'm misunderstanding.I think it means that the only reason that
"fizz" comes before "buzz"
is"fizz" is firstly mensioned when I type the parameter of the function
.;)
meaning:
So it's definitely NOT sorted. But it is definitely ordered. In the same manner than a list is.
OK, now I totally understand. (I wonder why I didn't notice when I did some tests before..)
Simply give an example for those confused:
I can't seem to call the map function within fizzBuzzReloaded. Can someone give me a hint?
Do you mean
new Map(...)
in JavaScript version or the.map()
method? Because the first one is an associative array, not a function.Is it appropriate to ask for hints here? I've been struggling to understand why one test (with expected numbers only) seems to be off by 4. I guessed the parameters of the test and it seems to produce the desired results. If its okay, i will also post code.
Have you accounted for the fact that both ends are inclusive? So you need to include both
1001
and105
when generating the sequence.This comment has been hidden.
ChaosD there is a problem with your code snippet. I could tell you the awnser but you won't learn from it.
but heres a helpful hint: write a function that counts 1 to 10 and 10 to 1 (make sure to use the same format as my function, eg 1, 10, 1 ... 10, 1, -1) . Your code will fail do that....How?...why?
This comment has been hidden.
I found the randomly generated link name somewhat relevant and hilarious ;-)
sometimes, when all the stars align, RNGesus rewards you with blatant irony :D
Let's say you're counting down from
10
to1
: You want to say "go from10
to0
not including0
", but what your code does at the moment is "go from11
to1
not including1
" ;-)Thanks again... counting is hard when I'm tired.
JavaScript translation available! Please review and approve it ;)
I know the tests are barely readable, but don't worry, I fully copied your original fixture.
That applies ONLY for py 3.6 and above. So either you have to provide a list of tuples, or you have to be explicit about that. Dictionaries were unordered before py3.6.
As far as I can see only Python 3.6 is available, so that's already dealt with.
Ah, I missed that they were dark grayed...
Though, a note should be added for those who do not know about this feature.
B4B is right. A kata like this musn't be version-dependent: CW allows to exclude languages, but not versions. Unless a note is added to only use Python 3.6 and translation is restricted to this version, this issue isn't resolved.
If I change to lists of functions now I potentically invalidate a bunch of solutions (plus...its work, lol).
So I'll just make a note of this behaviour in the description.
No, what we are telling is that you should update the description, not the code. ;)
Yeah, its done.
In your sample tests, you've got a test4/text4 typo here:
and you've also got expected and actual reversed, so error messages claim that the desired result should equal the incorrect result instead of the other way around.
done