• 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
xlamsp Avatar
Name:Unknown
Clan:Unknown
Member Since:Oct 2020
Last Seen:May 2025
Profiles:
Following:1
Followers:1
Allies:1
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (18)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • FArekkusu
    • resolved a suggestion on "Count the number of days between two dates" kata
    • 4 years ago

    Nobody's going to change the kata in the way you suggested years after it was approved.

  • Custom User Avatar
    • xlamsp
    • commented on "Can you get the loop ?" c solution
    • 4 years ago

    Will fail in case nodes addreess are not monotonically increase/decrease:

    Test(SampleTests, TwoNodesTileFourNodesLoopRandomOrder) {
      Node n[6];
    
      // 4 -> 1 -> 3 -> 0 -> 5 -> 2
      //           ^              |
      //           +--------------+
    
      n[4].next = &n[1];
      n[1].next = &n[3];
      n[3].next = &n[0];
      n[0].next = &n[5];
      n[5].next = &n[2];
      n[2].next = &n[3];
      
      Node* startNode = &n[4];
      int actual = loop_size(startNode);
      cr_assert_eq(actual, 4,
        "Incorrect answer for TwoNodesTileFourNodesLoopRandomOrder");
    }
    
  • Custom User Avatar
    • xlamsp
    • commented on "Can you get the loop ?" c solution
    • 4 years ago

    Will fail in case nodes addreess are not monotonically increase/decrease:

    Test(SampleTests, TwoNodesTileFourNodesLoopRandomOrder) {
      Node n[6];
    
      // 4 -> 1 -> 3 -> 0 -> 5 -> 2
      //           ^              |
      //           +--------------+
    
      n[4].next = &n[1];
      n[1].next = &n[3];
      n[3].next = &n[0];
      n[0].next = &n[5];
      n[5].next = &n[2];
      n[2].next = &n[3];
      
      Node* startNode = &n[4];
      int actual = loop_size(startNode);
      cr_assert_eq(actual, 4,
        "Incorrect answer for TwoNodesTileFourNodesLoopRandomOrder");
    }
    
  • Custom User Avatar
    • LarisaOvchinnikova
    • resolved a suggestion on "Determine the date by the day number" kata
    • 4 years ago

    Thank you for your comment. Unfortunately, it is probably too late to make changes to the problem condition, since all decisions of users who used the libraries will be invalid. I will definitely consider your proposal in the future.

  • Custom User Avatar
    • xlamsp
    • created a suggestion for "Count the number of days between two dates" kata
    • 4 years ago

    Thanks for the kata! Although it would be more difficult and more fun if imports were disabled :)

  • Custom User Avatar
    • xlamsp
    • created a suggestion for "Determine the date by the day number" kata
    • 4 years ago

    Nice kata, thanks! A couple of comments:

    1. For the better value I'd suggest to disable date/time libraries. The task is really worth to think a little bit about numbers crunching rather than to find a ready-made solution.
    2. There is a simple O(1) solution without loops, dictionaries and conglomerates of "if"'s.
  • Custom User Avatar
    • xlamsp
    • commented on "Find the missing term in an Arithmetic Progression" kata
    • 4 years ago

    Exactly! :)

  • Custom User Avatar
    • Awesome A.D.
    • commented on "Find the missing term in an Arithmetic Progression" kata
    • 4 years ago

    Mine is O(logN), in Python. It's a binary search.

  • Custom User Avatar
    • xlamsp
    • commented on "Assembler interpreter (part II)" kata
    • 4 years ago

    Very nice kata, thanks!

  • Custom User Avatar
    • xlamsp
    • commented on "Find the missing term in an Arithmetic Progression" kata
    • 4 years ago

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

  • Custom User Avatar
    • xlamsp
    • commented on "Find the odd int" java solution
    • 4 years ago

    Wow, nice to see the reference to Uncle Bob, I like this guy too :) Totally agree.

  • Custom User Avatar
    • xlamsp
    • commented on "Insane Coloured Triangles" kata
    • 5 years ago

    Very nice kata, thanks a lot!

  • Custom User Avatar
    • xlamsp
    • commented on "Find the odd int" java solution
    • 5 years ago

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

  • Custom User Avatar
    • xlamsp
    • commented on "Find the missing term in an Arithmetic Progression" kata
    • 5 years ago

    Have someone implemented solution with better than linear (O(n)) time complexity?

  • Custom User Avatar
    • xlamsp
    • commented on "Find the missing term in an Arithmetic Progression" kata
    • 5 years ago

    The probem is that in expression d = a/n; 'a' is (signed) int but 'n' is size_t (which is unsigned long). As unsigned long (64 bits) is longer than int (32 bits) the intermediate computation is performed as unsigned long. In case 'a' is negative (i.e. the most significant bit is 1) after conversion to unsigned long it would be a big positive number with 31st bit == 1. After division this bit is shifted right and the new 31st bit will be 0. After converson back to int (assigning to 'd') the result would not be negative any more but an "odd number" :) To fix the issue use d = a/(int)n

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

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...