• 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
AFP Avatar
Name:Unknown
Clan:Unknown
Member Since:Jan 2017
Last Seen:Nov 2023
Profiles:
Following:0
Followers:0
Allies:0
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (28)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • AFP
    • commented on "Abbreviate a Two Word Name" c solution
    • 2 years ago

    You can also skip the "i < (int)strlen(full_name)" check because a pre-condition of the input is that a space must exist.

  • Custom User Avatar
    • Carbon2077
    • commented on "Factorial" c solution
    • 3 years ago

    Maybe that was a joke only :)

  • Custom User Avatar
    • Husoski
    • commented on "Where my anagrams at?" ruby solution
    • 3 years ago

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

  • Custom User Avatar
    • npassaro
    • commented on "Credit Card Mask" ruby solution
    • 4 years ago

    I do know regex :) What I didn't know was how to manage gsub with it and it is actually more difficult to read what is considered the top answer.

  • Custom User Avatar
    • AFP
    • commented on "Best travel" c solution
    • 4 years ago

    Nice combinations code.

  • Custom User Avatar
    • dinglemouse
    • commented on "up AND down" c solution
    • 4 years ago

    The copy allocates heap space (strdup) which I want to free to avoid leakage, and so does arr (malloc), but char *p is just a pointer.

  • Custom User Avatar
    • AFP
    • commented on "Factorial" c solution
    • 4 years ago

    Avoid recursion if you can.

  • Custom User Avatar
    • AFP
    • commented on "Factorial" c solution
    • 4 years ago

    This is hilarious and clever. Good job man.

  • Custom User Avatar
    • AFP
    • commented on "up AND down" c solution
    • 4 years ago

    Thanks, I learned several things from this solution :) Very clean.

    I have a question though. Why do you need to free the copy variable but not variables like the char* p from the last iteration?

  • Custom User Avatar
    • Adsidera
    • commented on "Duplicate Encoder" ruby solution
    • 5 years ago

    Not if the word chars are set to uniq before starting the count loop :)

  • Custom User Avatar
    • Adsidera
    • commented on "Is a number prime?" ruby solution
    • 5 years ago

    Exactly..that is a good practice!

  • Custom User Avatar
    • AFP
    • commented on "Where my anagrams at?" ruby solution
    • 9 years ago

    Mmmmmkay

  • Custom User Avatar
    • sahglie
    • commented on "Where my anagrams at?" ruby solution
    • 9 years ago

    wow, ur a genius!

  • Custom User Avatar
    • AFP
    • commented on "Where my anagrams at?" ruby solution
    • 9 years ago

    This is not beautiful, it is a waste of processing resources. Sorting every word is awful. Just Hash it with O(n). Sorting is O(nlog(n))

  • Custom User Avatar
    • AFP
    • commented on "Memoized Fibonacci" ruby solution
    • 9 years ago

    It means the value will only be replaced if it is nil or false. (Correct me if I'm wrong please, I'm also new)

    #Case 1:
    a = 1
    a ||= 10
    print a #=> 1

    #Case 2:
    a = nil
    a ||= 10
    print a #=> 10

    a||= 10 is logically equivalent to: a || a = 10

    Let's understand that behaviour. When we put together many or's:
    a || b || c || d, it will return true immediatly when the first true value is found.
    So in the example above, if 'a' is true, then b, c and d WON'T be evaluated by the or operator.

    The same happens here: a || a = 10.

    if a is false (or nil) it will evaluate (a = 10) which then changes the value of a.
    if a is true (or != nil), then (a = 10) WON'T be evaluated at all.

  • Loading more items...
  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...