Skip to content

v1.8.4 - Fix Challenge Command Random Generation

Choose a tag to compare

@karote00 karote00 released this 28 Jul 11:33
· 23 commits to main since this release

Release Notes v1.8.4 - Fix Challenge Command Random Generation

🔧 Critical Bug Fix

Challenge Command Now Properly Generates Random Problems

  • Fixed: lct c easy 1 was always returning Two Sum (problem ID 1) instead of random easy problems
  • Root Cause: Argument parsing logic incorrectly treated difficulty + count as problem ID request
  • Solution: Modified logic to only treat numbers as problem IDs when no difficulty is specified

🎯 Behavior Changes

Before v1.8.4 (Broken):

lct c easy 1    # Always returned Two Sum (problem ID 1)
lct c easy 1    # Always returned Two Sum (problem ID 1)  
lct c easy 1    # Always returned Two Sum (problem ID 1)

After v1.8.4 (Fixed):

lct c easy 1    # Returns random easy problem (e.g., Roman to Integer)
lct c easy 1    # Returns different random easy problem (e.g., Search Insert Position)
lct c easy 1    # Returns another random easy problem (e.g., Merge Two Sorted Lists)

✅ Maintained Backward Compatibility

All existing functionality still works as expected:

  • lct c 1 → Still gets specific problem ID 1 (Two Sum) when no difficulty specified
  • lct c two-sum → Still gets specific problem by name
  • lct c easy 2 → Now correctly gets 2 random easy problems
  • lct c medium 3 → Now correctly gets 3 random medium problems

🚀 Impact

For Users:

  • Variety: No more getting the same problem repeatedly
  • Learning: Better practice experience with diverse problems
  • Expectation: Command now works as users naturally expect
  • Engagement: More interesting practice sessions

For Learning:

  • Users can practice different algorithmic patterns
  • Better exposure to various problem types
  • More comprehensive skill development
  • Prevents over-familiarity with single problems

🔍 Technical Details

What Was Fixed:

// Before (BROKEN):
if (words.length === 1 && words[0].match(/^\d+$/)) {
  specificProblem = parseInt(words[0]); // This made 'easy 1' request problem ID 1
}

// After (FIXED):
if (!difficulty && words.length === 1 && words[0].match(/^\d+$/)) {
  specificProblem = parseInt(words[0]); // Only when no difficulty specified
}

Result:

  • lct c easy 1 now correctly uses difficulty filter with count=1
  • Random selection works properly with available problems
  • No more forced conversion to specific problem ID requests

🔄 No Breaking Changes

This is a pure bug fix that makes the command work as originally intended. No changes to:

  • Command syntax
  • File structure
  • Configuration
  • Other functionality

📦 Installation

npm install -g local-leetcode-trainer@1.8.4
# or
yarn global add local-leetcode-trainer@1.8.4

🎉 Try the Fix

lct init                    # Set up your project
lct c easy 1               # Get a random easy problem
lct c easy 1               # Get a different random easy problem
lct c easy 1               # Get another different random easy problem
lct c medium 2             # Get 2 random medium problems

You should now see different problems each time, giving you the variety needed for effective practice! 🎲✨

🙏 Thanks

Thanks for the clear feedback that helped identify this issue! The challenge command now provides the variety that makes practice sessions engaging and educational.