Repository navigation
dict-and-join simplify for raindrops approaches - #3620
Conversation
|
Hi there! 👋🏽 Thanks for submitting this PR. 😄
I did do it on purpose, but my 'copypasta' got the better of me! It is more sound when using def convert(number):
#This is clear and easily added to. Unless the factors get
# really long, this won't take up too much memory.
sounds = {3: 'Pling',
5: 'Plang',
7: 'Plong'}
results = (sounds[divisor] for
divisor in sounds.keys()
if number % divisor == 0)
return ''.join(results) or str(number)Buuut. I copied the code above and missed modifying Now that I am looking at all this again, I think perhaps the best thing to do is use the example above in the approach document, and use the code with |
Swapped the two dictionary approaches and adjusted `introduction.md`, `Benchmark.py`, `Performance`, and the approaches doc accordingly.
|
Yes, looks even better. The distinguish between using items() and keys() adds even more knowledge to the already rich article! |
BethanyG
left a comment
There was a problem hiding this comment.
Thanks for giving this one last read-through! 🌈
Going to push the big, green button then! |
* dict-and-join simplify * Swapped dictionary approaches Swapped the two dictionary approaches and adjusted `introduction.md`, `Benchmark.py`, `Performance`, and the approaches doc accordingly. --------- Co-authored-by: BethanyG <BethanyG@users.noreply.github.com>
Probably this was done on purpose but as a way to discuss this I wanted to propose a little simplification to the approach.
I think this is more sound and readable to just use the item from the dict.
Let me know what you think.
Thanks in advance.