• Sign Up
  • Kata
  • Kumite
  • Blog
  • Forum
  • Wiki
  • Leaders
  • Log In
  • Sign Up
Name:Unknown
Clan:Unknown
Member Since:Mar 2015
Last Seen:Jan 2021
Profiles:
Following:6
Followers:7
Allies:0
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (75)
  • Replies
  • Authored
  • Needs Resolution
    • CDJimmy
    • commented on "Simple Fun #114: "abacaba"" python solution

    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.

    • Shikogo
    • commented on "Returning Strings" python solution

    This just taught me f-strings. Neat!

    • discopython
    • commented on "All Star Code Challenge #2" python solution

    :) now that is a one liner!

    • CSWinnall
    • commented on "Simple Fun #114: "abacaba"" python solution

    hi could you tell me why this works its a simple answer but i have o clue why

    • cekstedt
    • commented on "Almost Everywhere Zero" python solution

    I'll just pack up all my reinvented wheels and go home...
    Seriously though, this solution is beautiful. Mad kudos.

    • shumendra
    • commented on "Prize Draw" python solution

    Could somebody please explain how the last line works specifically the sorted part and role of the indices in the end. Thanks

    • reconndev
    • commented on "Almost Everywhere Zero" python solution

    This is exactly my solution, except yours is recursive and thus super elegant. Props to you!

    • OOW
    • commented on "Square root without using library : math" python solution

    LOL

    • sjamr10
    • commented on "Double Sort" python solution

    This comment is hidden because it contains spoiler information about the solution

    • matnad
    • commented on "Make the Deadfish swim" python solution

    From the PEP8 Style guide (https://www.python.org/dev/peps/pep-0008/):

    • 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

    • ShrewdStyle
    • commented on "Returning Strings" python solution

    click the drop down at the top of the kata and you can select the version

    • alexfaley
    • commented on "Palindromic Expression" python solution

    Witty))

    • andy_lz
    • commented on "Sorting by bits" python solution

    why I don't know '.count()'

    • preactive
    • commented on "get character from ASCII Value" python 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.

    • shoark7
    • commented on "get character from ASCII Value" python solution

    Just assigning the function to another... Brilliant.

  • Loading more items...
  • © 2021 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Contact
  • powered by

Confirm

  • Cancel
  • Confirm