Ad
  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Exactly. I'm just seeing that for the first time.

  • Custom User Avatar

    Actually on this site i seeing many people who kinda like to explain their code. Thats why i asked this question, and ofc playing with code and trying to figure out how it work before write comment.

  • Custom User Avatar

    Don't expect someone else to give you the answer. You can make trials with this code to see what it's doing.

    Note this code was written on Python 2, you must use // to perform an integer division in Python 3.

  • Custom User Avatar

    Why exactly if len(s) is odd then negative index slicing s[-mid] return substring witouht first number?
    I guess this operation with negative-index slicing making algorithm much more elegant and clearful, and allow you to rid of multiple if .. else blocks. But i still cant find out how it works.

  • Custom User Avatar

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

  • Custom User Avatar

    groupby() take iterable(sort of sequence) and return tuple of group key(str) and lazy iterator(itertols._grouper).
    So because its lazy it will give you a value only as in needed. But you can get sum of iterators values.

    for k,g in groupby(s): 
      print(type(k)) # str
      print(type(g)) # itertols._grouper
      x = sum(1 for _ in g) 
      print(f'This is a key {k} and these is a sum {x} of the each group'}
    

    Then you need to create generator expression, which consist of

    [[computing_sum_of_the_group=example above, key] for key, group in each_tuple]
    

    Hope i did it good.

  • Custom User Avatar

    I was little confusing about this case too :)
    Although, this is good practice for data validation

  • Custom User Avatar

    IMHO 6 kyu kata. Pretty intresting, as for me

  • Custom User Avatar

    you didn't read the description...

  • Custom User Avatar

    I dont get it: How is it possible to palindromize 750? reversed is 057.

  • Custom User Avatar

    I think this solution not so optimal at the point of memory managment. Using copy for new str is resourcefull operation that allocate new memory for new obj.
    Better one is consistant comparison, when we compare letter from end and from start of input string. .lower() method for valid compare. Only counting indenfier increase and decrease. So, if we have different letters - loop is over.

  • Custom User Avatar

    You're right and wrong at the same time. Codewars not only about algorithm training, its about finding more efficient solution too.
    Anyway, its cool, when u able to implement logic/algorithm of built-in function, and this able itself give you understanding of inner logic of those functions

  • Custom User Avatar

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

  • Loading more items...