C) As you can see in last row, those Bin logic is the same that we want with letters:
you pop the first result for 0 and you got
[0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0]
Same as
[a, b, a, c, a, b, a, d, a, b, a, c, a, b, a, e, a, b, a]
Now why algorithmic logic Bin follows this process ...
I don't know if this sequence is known as that of Fibonacci or Padovan.
This must be related to the very logic of python operation.
Compound statements (multiple statements on the same line) are generally discouraged.
Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).
This probably should not be the top best practices solution
I think its fine. Should there be other iterations under different katas, sure.
But for someone who is brand new to codeing getting exposure to the basics and googling for answers is a great start because starting anywhere is great.
After multiple test, I understant why it's work (but sadly not why this solution made that) :
A)
Explanation of what is bin() here https://www.programiz.com/python-programming/methods/built-in/bin
B)
I try to Bin numbers and count difference between Bin's size and Bin's size without 0 :
for i in range(20):
print("{} => {} => {}".format(i, bin(i), len(bin(i)) - len(bin(i).rstrip('0'))))
''' results
0 => 0b0 => 1
1 => 0b1 => 0
2 => 0b10 => 1
3 => 0b11 => 0
4 => 0b100 => 2
5 => 0b101 => 0
6 => 0b110 => 1
7 => 0b111 => 0
8 => 0b1000 => 3
9 => 0b1001 => 0
10 => 0b1010 => 1
11 => 0b1011 => 0
12 => 0b1100 => 2
13 => 0b1101 => 0
14 => 0b1110 => 1
15 => 0b1111 => 0
16 => 0b10000 => 4
17 => 0b10001 => 0
18 => 0b10010 => 1
19 => 0b10011 => 0
C) As you can see in last row, those Bin logic is the same that we want with letters:
you pop the first result for 0 and you got
[0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0]
Same as
[a, b, a, c, a, b, a, d, a, b, a, c, a, b, a, e, a, b, a]
Now why algorithmic logic Bin follows this process ...
I don't know if this sequence is known as that of Fibonacci or Padovan.
This must be related to the very logic of python operation.
This just taught me f-strings. Neat!
:) now that is a one liner!
hi could you tell me why this works its a simple answer but i have o clue why
I'll just pack up all my reinvented wheels and go home...
Seriously though, this solution is beautiful. Mad kudos.
Could somebody please explain how the last line works specifically the sorted part and role of the indices in the end. Thanks
This is exactly my solution, except yours is recursive and thus super elegant. Props to you!
LOL
This comment is hidden because it contains spoiler information about the solution
From the PEP8 Style guide (https://www.python.org/dev/peps/pep-0008/):
This probably should not be the top best practices solution
click the drop down at the top of the kata and you can select the version
Witty))
why I don't know '.count()'
I think its fine. Should there be other iterations under different katas, sure.
But for someone who is brand new to codeing getting exposure to the basics and googling for answers is a great start because starting anywhere is great.
Just assigning the function to another... Brilliant.
Loading more items...