From ae4abeb59423afb2cceb188ba3941108f0e078de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:56:04 +0000 Subject: [PATCH 1/2] Initial plan From eb139ec471cab20964e0981a422e4a8bffaf09f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:04:27 +0000 Subject: [PATCH 2/2] Add comprehensive change viewing functionality Co-authored-by: mranal0 <118808039+mranal0@users.noreply.github.com> --- .gitignore | 32 ++++++++++++ CHANGELOG.md | 83 +++++++++++++++++++++++++++++++ README.md | 19 +++++++ Solutions/blah | 1 - view-changes.sh | 5 ++ view_changes.py | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 CHANGELOG.md delete mode 100644 Solutions/blah create mode 100755 view-changes.sh create mode 100755 view_changes.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7eb25a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +venv/ +.venv/ + +# Temporary files +*.tmp +*.temp +.DS_Store +Thumbs.db + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo + +# Build artifacts +*.class +*.exe +*.o +*.out +a.out + +# Test files +test* +temp* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..88066eb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,83 @@ +# 📝 Changelog + +All notable changes to this LeetCode solutions repository will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## 🚀 How to View Changes + +You can view changes in several ways: + +### Using the Change Viewer Script +```bash +# View recent changes (last 7 days) +python3 view_changes.py + +# View changes from last 30 days +python3 view_changes.py --recent 30 + +# Show solution statistics +python3 view_changes.py --stats + +# List all solutions +python3 view_changes.py --list + +# View change history for a specific file +python3 view_changes.py --file "Solutions/121. Best Time to Buy and Sell Stock.java" +``` + +### Using Git Commands +```bash +# View recent commits +git log --oneline -10 + +# View changes in the last week +git log --since="1 week ago" --oneline + +# View detailed changes for a specific file +git log -p -- "Solutions/filename.java" + +# See what files were changed in recent commits +git log --name-only --oneline -5 +``` + +--- + +## [Unreleased] + +### Added +- 📜 `view_changes.py` - Interactive script to view repository changes +- 📝 `CHANGELOG.md` - This changelog file to track all changes +- 🔍 Enhanced documentation for viewing changes + +### Removed +- 🗑️ Removed placeholder `blah` file from Solutions directory + +--- + +## [2025-09-08] - Repository Enhancement + +### Added +- 🖼️ Added contribution snake animation to README +- 📚 Enhanced README with better usage instructions +- ☕ **121. Best Time to Buy and Sell Stock** - Java solution with comments +- 💻 **1342. Number of Steps to Reduce a Number to Zero** - C++ solution +- 💻 **1672. Richest Customer Wealth** - C++ solution +- 💻 **412. Fizz Buzz** - C++ solution +- ☕ **42. Trapping Rain Water** - Java solution with detailed logic + +### Changed +- 📖 Updated README with comprehensive usage guide +- 🎯 Added clear goals and learning objectives +- 📬 Added contact information and social links + +--- + +## Legend +- ☕ Java solutions +- 💻 C++ solutions +- 🐍 Python solutions +- 📚 Documentation updates +- 🔧 Tools and utilities +- 🐛 Bug fixes +- 🗑️ Removals \ No newline at end of file diff --git a/README.md b/README.md index 331ef14..d57d125 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,25 @@ This repository contains all of my **LeetCode problem solutions**, stored in a s - File names usually match the problem title (underscores instead of spaces). - Use the search bar on GitHub to quickly find a problem by name. +## 📈 View Changes & Track Progress +Want to see what's new or track your progress? Use the built-in change viewer: + +```bash +# View recent changes (last 7 days) +python3 view_changes.py + +# View changes from last 30 days +python3 view_changes.py --recent 30 + +# Show solution statistics +python3 view_changes.py --stats + +# List all solutions +python3 view_changes.py --list +``` + +You can also check the **`CHANGELOG.md`** file for a detailed history of all additions and updates! 📝 + ## 🛠️ Languages Used diff --git a/Solutions/blah b/Solutions/blah deleted file mode 100644 index 8b13789..0000000 --- a/Solutions/blah +++ /dev/null @@ -1 +0,0 @@ - diff --git a/view-changes.sh b/view-changes.sh new file mode 100755 index 0000000..b8ca594 --- /dev/null +++ b/view-changes.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# LeetCode Solutions Change Viewer - Shell wrapper +# Usage: ./view-changes.sh [options] + +python3 view_changes.py "$@" \ No newline at end of file diff --git a/view_changes.py b/view_changes.py new file mode 100755 index 0000000..bd159ba --- /dev/null +++ b/view_changes.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +""" +LeetCode Solutions Change Viewer +Helps track and view changes to your LeetCode solutions repository. +""" + +import subprocess +import os +import sys +from datetime import datetime, timedelta +import argparse + +def run_git_command(command): + """Run a git command and return the output.""" + try: + result = subprocess.run(command, shell=True, capture_output=True, text=True, cwd=os.getcwd()) + return result.stdout.strip() if result.returncode == 0 else None + except Exception as e: + print(f"Error running command: {e}") + return None + +def get_recent_changes(days=7): + """Get recent changes in the last N days.""" + since_date = (datetime.now() - timedelta(days=days)).strftime('%Y-%m-%d') + cmd = f'git log --since="{since_date}" --pretty=format:"%h|%ad|%s" --date=short --name-only' + output = run_git_command(cmd) + + if not output: + print(f"No changes found in the last {days} days.") + return + + print(f"📅 Changes in the last {days} days:\n") + + lines = output.split('\n') + current_commit = None + + for line in lines: + if '|' in line: # This is a commit line + parts = line.split('|') + hash_val, date, message = parts[0], parts[1], parts[2] + current_commit = hash_val + print(f"🔸 {date} [{hash_val}] {message}") + elif line.strip() and not line.startswith(' '): # This is a file name + if line.startswith('Solutions/'): + print(f" 📝 {line}") + else: + print(f" 📄 {line}") + print() + +def get_solution_stats(): + """Get statistics about solutions.""" + java_count = run_git_command('find Solutions -name "*.java" | wc -l') + cpp_count = run_git_command('find Solutions -name "*.cpp" | wc -l') + py_count = run_git_command('find Solutions -name "*.py" | wc -l') + + print("📊 Solution Statistics:") + print(f" ☕ Java solutions: {java_count or 0}") + print(f" 💻 C++ solutions: {cpp_count or 0}") + print(f" 🐍 Python solutions: {py_count or 0}") + print(f" 📝 Total solutions: {int(java_count or 0) + int(cpp_count or 0) + int(py_count or 0)}") + print() + +def show_file_changes(filename): + """Show changes to a specific file.""" + cmd = f'git log --follow -p -- "{filename}"' + output = run_git_command(cmd) + + if not output: + print(f"No changes found for {filename}") + return + + print(f"📜 Change history for {filename}:\n") + print(output) + +def list_solutions(): + """List all available solutions.""" + cmd = 'find Solutions -name "*.java" -o -name "*.cpp" -o -name "*.py" | sort' + output = run_git_command(cmd) + + if not output: + print("No solutions found.") + return + + print("📚 Available Solutions:\n") + for file in output.split('\n'): + if file.strip(): + # Extract problem number and name from filename + basename = os.path.basename(file) + name_without_ext = os.path.splitext(basename)[0] + ext = os.path.splitext(basename)[1] + + # Get language emoji + lang_emoji = "☕" if ext == ".java" else "💻" if ext == ".cpp" else "🐍" + + print(f" {lang_emoji} {name_without_ext}") + print() + +def main(): + parser = argparse.ArgumentParser(description='View changes in your LeetCode solutions repository') + parser.add_argument('--recent', '-r', type=int, default=7, + help='Show changes from the last N days (default: 7)') + parser.add_argument('--stats', '-s', action='store_true', + help='Show solution statistics') + parser.add_argument('--list', '-l', action='store_true', + help='List all solutions') + parser.add_argument('--file', '-f', type=str, + help='Show change history for a specific file') + + args = parser.parse_args() + + print("🚀 LeetCode Solutions Change Viewer\n") + + # Check if we're in a git repository + if not run_git_command('git rev-parse --git-dir'): + print("❌ Error: Not in a git repository") + sys.exit(1) + + if args.file: + show_file_changes(args.file) + elif args.list: + list_solutions() + elif args.stats: + get_solution_stats() + else: + get_recent_changes(args.recent) + get_solution_stats() + +if __name__ == "__main__": + main() \ No newline at end of file