• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
MusicalCoder Avatar
Name:Musical Coder
Clan:Unknown
Member Since:Aug 2016
Last Seen:Mar 2025
Profiles:
Following:0
Followers:1
Allies:0
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations
  • Replies (11)
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • justinsane𒀭
    • commented on "N-th Power" python solution
    • 3 years ago

    I guess the Kata description changed. N won't be negative.

    "You are given an array with positive numbers and a non-negative number N."

  • Custom User Avatar
    • ᛚᚨᚱᛊ ᚺᛖᚾᚱᛁᚲ
    • commented on "Find Maximum and Minimum Values of a List" python solution
    • 7 years ago

    Same

  • Custom User Avatar
    • fenring76
    • commented on "Find Maximum and Minimum Values of a List" python solution
    • 8 years ago

    I tried that and the system asked me something to the effect of "Where is the code?" and wouldn't let me submit it.

  • Custom User Avatar
    • daddepledge
    • commented on "Fake Binary" python solution
    • 9 years ago

    I think a lot of folk use single letters that imply a data type. I know I do.

    e.g. c => characters, i => integer, l => list, e => generic element

  • Custom User Avatar
    • Bradley Staples
    • commented on "Fake Binary" python solution
    • 9 years ago

    probably bc I copied it ahah

  • Custom User Avatar
    • MrHobbits
    • commented on "Fake Binary" python solution
    • 9 years ago

    I'm guessing they used c instead of d because it was returning a string, thus c for character?

  • Custom User Avatar
    • jgdodson
    • commented on "Naming Files" python solution
    • 9 years ago

    Ya, I gradually worked my way to this little one-liner =)

  • Custom User Avatar
    • bouchert
    • commented on "Find The Duplicated Number in a Consecutive Unsorted List - Tougher Version" python solution
    • 9 years ago

    It appears that Python is not as smart at optimizing things as you think. I never duplicate function calls if I can help it. The difference in performance is very small, admittedly, but nonetheless, repeatedly calling len generates LOAD_GLOBAL, LOAD_FAST, and CALL_FUNCTION opcodes in that order, each time you call len, as opposed to doing it only once to find the length and then generating a LOAD_FAST to call the locally stored value back up. Benchmarking with timeit, I find a slight but reproducible benefit to calling len only once. In functions where you use the value more than twice, the benefit is obviously even greater.

  • Custom User Avatar
    • ChrisOaks
    • commented on "Find The Duplicated Number in a Consecutive Unsorted List - Tougher Version" python solution
    • 9 years ago

    No additional cost overhead for calling len twice?

    BTW, a cool variation is

    from scipy.misc import comb
    def find_dup(arr):
    return sum(arr) - comb(len(arr),2)

  • Custom User Avatar
    • the_roth
    • commented on "Sort array by string length" python solution
    • 9 years ago

    There are a lot of problems with extremely simple solutions - I've missed a lot of them but practice is certainly helping :D definitely need more practice with lambda and when to use recursion though.

  • Custom User Avatar
    • zebulan
    • commented on "Get number from string" python solution
    • 9 years ago

    @MusicalCoder,

    I also misspelled string -> strng on purpose. Since there is a module named string in Python, I've found using it as a variable name can cause minor issues like this:

    >>> import string
    >>> string.digits
    '0123456789'
    >>> def hmm(string):
    ...     return string.digits
    ...     
    >>> hmm('Codewars')
    Traceback (most recent call last):
      File "/usr/lib/python3.5/code.py", line 91, in runcode
        exec(code, self.locals)
      File "<input>", line 1, in <module>
      File "<input>", line 2, in hmm
    AttributeError: 'str' object has no attribute 'digits'
    
    

    Also, your solution does not need the square brackets inside of ''.join(...).

  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...