Squidleet is a command-line LeetCode practice game that allows you to solve LeetCode problems in your terminal. It uses the LeetCode API to fetch problems and submit solutions. You can practice solving problems in your terminal without having to switch between the browser and the terminal.
- Daily Challenge Integration: Fetch and solve the LeetCode Daily Coding Challenge directly from the terminal.
- Study Plan Mode: Fetch random problems based on a specific study plan.
- Random Problem Practice: Get a randomly selected LeetCode problem to practice.
- Company Mode: Fetch random problems asked by a specific company over a given duration (e.g., last 30 days).
- Specific Problem Mode: Solve a specific problem by providing its problem slug.
- Problem Fetching: Added enhanced fetching capabilities, including filtering based on difficulty (e.g.,
easy
,medium
,hard
) and more. - Submit Solutions: Users can now directly submit their solutions to LeetCode from the terminal via a
submit_solution
function. - Custom Modes: Support for specific practice workflows like random mode or custom problem-solving mode by providing slugs.
- Editor Selection: Integration with multiple editors, allowing configuration via CLI (e.g.,
vim
,nano
, and others).
Squidleet uses the LeetCode API to fetch problems and submit solutions. It provides a command-line interface that allows you to interact with the LeetCode platform without leaving your terminal. You can:
- Fetch problems based on criteria like difficulty or tags.
- Solve the LeetCode Daily Challenge.
- Solve random problems or specific problems via their unique problem slug or study plan.
- Write solutions with your preferred code editor and submit them directly from the terminal.
- Open problem links in your browser if preferred.
Additionally, Squidleet provides an interactive CLI experience with options for configuring your practice workflow.
You can install squidleet
using pip
:
git clone https://github.com/daily-coding-problem/squidleet.git
cd squidleet
python3 -m venv .venv
pip install -r requirements.txt
Squidleet offers multiple modes and configuration options for practicing LeetCode problems effectively, catering to various workflows. Below are commands to get started:
Daily Challenge Mode allows you to fetch and solve the LeetCode Daily Challenge directly from the terminal.
python3 main.py --practice-mode daily
Optional arguments:
--open-in-browser
: Opens the challenge in a browser window.--editor
: Open the code editor to write solutions. Supported editors includedefault
,vim
,nano
, and others. Example usage:--editor vim
Welcome to π¦ SquidLeet!
π Using authenticated session
Selected π
Daily Challenge Mode
π― Daily Coding Challenge:
π
Date: 2025-01-19
π― Problem Selected: Trapping Rain Water II
β¨ Difficulty: Hard
π URL: https://leetcode.com/problems/trapping-rain-water-ii
π·οΈ Tags: Array, Breadth-First Search, Heap (Priority Queue), Matrix
π Acceptance Rate: 55.04%
...
β³ You have 45 min minutes to solve the problem. Good luck!
Solve a randomly selected LeetCode problem based on difficulty. Random Practice Mode allows you to solve a randomly selected LeetCode problem. Enhanced difficulty classification includes options such as easy
, medium
, hard
, or a combination (e.g., --difficulty easy,medium
).
python3 main.py --practice-mode random --difficulty medium
Optional arguments:
--difficulty
: Choose betweeneasy
,medium
, orhard
or select multiple using comma-separated list (e.g.,easy,medium
).--open-in-browser
: Opens the problem in a browser window.--editor
: Specify a code editor for writing solutions. Supported editors:default
,vim
,nano
, etc.
Welcome to π¦ SquidLeet!
π Using authenticated session
Selected π² Random Problem Mode
π― Problem Selected: Shortest Distance in a Plane
β¨ Difficulty: Medium
π URL: https://leetcode.com/problems/shortest-distance-in-a-plane
π·οΈ Tags: Database
π Acceptance Rate: 61.29%
...
β³ You have 45 min minutes to solve the problem. Good luck!
Custom Modes enable solving specific problems or sets of problems by providing one or multiple problem slugs (e.g., --problems two-sum,three-sum
).
python3 main.py --practice-mode custom --problems two-sum
Optional arguments:
--open-in-browser
: Opens the problem in a browser window.--editor
: Specify the preferred code editor (e.g.,vim
,nano
). Default is the system-configured default editor.
Welcome to π¦ SquidLeet!
π Using authenticated session
Selected 𧩠Custom Practice Mode
π― Problem Selected: Two Sum
β¨ Difficulty: Easy
π URL: https://leetcode.com/problems/two-sum
π·οΈ Tags: Array, Hash Table
π Acceptance Rate: 54.67%
...
β³ You have 45 min minutes to solve the problem. Good luck!
Study Plan Mode allows you to fetch random problems based on a specific study plan. You can specify the study plan name to fetch problems from that plan.
python3 main.py --practice-mode study-plan --plan-name top-interview-150
Optional arguments:
--open-in-browser
: Opens the problem in a browser window.--editor
: Specify the preferred code editor (e.g.,vim
,nano
). Default is the system-configured default editor.
Welcome to π¦ SquidLeet!
π Using authenticated session
Selected π― Study Plan Mode: top-interview-150
π― Problem Selected: Game of Life
β¨ Difficulty: Medium
π URL: https://leetcode.com/problems/game-of-life
π·οΈ Tags: Array, Matrix, Simulation
π Acceptance Rate: 70.65%
...
β³ You have 45 min minutes to solve the problem. Good luck!
Company Mode allows you to fetch random problems asked by a specific company.
--leetcode-session
argument to be set with a valid LeetCode session cookie. This is because the company-specific problem data is not available publicly and requires a valid LeetCode Premium subscription.
python3 main.py --practice-mode company --company-name microsoft --duration thirty-days
Optional arguments:
--open-in-browser
: Opens the problem in a browser window.--editor
: Specify the preferred code editor (e.g.,vim
,nano
). Default is the system-configured default editor.--difficulty
: Choose betweeneasy
,medium
, orhard
or select multiple using comma-separated list (e.g.,easy,medium
).--tags
: Filter problems based on tags. Example usage:--tags Array,Hash Table
.--duration
: Fetch the problems asked by the company over a given span of time. Valid values:thirty-days
,three-months
,six-months
,more-than-six-months
, orall
. Default isall
.
Welcome to π¦ SquidLeet!
π Using authenticated session
Selected π Company Mode: Top Questions asked at Microsoft in the last 30 days
π― Problem Selected: Maximum Length of a Concatenated String with Unique Characters
β¨ Difficulty: Medium
π URL: https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters
π·οΈ Tags: Array, String, Backtracking, Bit Manipulation
π Acceptance Rate: 54.2%
...
β³ You have 45 min minutes to solve the problem. Good luck!
Squidleet uses a LEETCODE_SESSION
cookie for authentication. Setting the LEETCODE_SESSION
environment variable is necessary for all operations, including fetching and submitting problems.
To obtain the LEETCODE_SESSION
cookie, follow these steps:
- Login to LeetCode: Open the LeetCode website and log in to your account.
- Open Developer Tools: Press
F12
or right-click and selectInspect
to bring up the browser's Developer Tools. - Locate Cookies: In the
Application
tab, expand theCookies
section and click onhttps://leetcode.com
. - Copy
LEETCODE_SESSION
: Locate theLEETCODE_SESSION
cookie in the table and copy its value.
Set the cookie value as an environment variable .env
:
LEETCODE_SESSION=<your_session_cookie>
Squidleet exposes two environment variables for logging:
LOG_LEVEL
: Set the log level for the application. Default isINFO
.SHOW_DETAILED_LOGS
: Enable detailed logs for debugging purposes. Default isFalse
.
These can also be set via arguments in the CLI:
python3 main.py --practice-mode daily --log-level INFO --show-detailed-logs
You can run Squidleet using Docker. Below are the steps to set up and run the application using Docker.
Clone the repository and navigate to the project directory:
git clone https://github.com/daily-coding-problem/squidleet.git
cd squidleet
Build the Docker image:
docker build -t squidleet .
Run the Docker container and mount the directory where your environment file (.env
) is located:
docker run --rm -it --env-file .env squidleet
To specify additional options (e.g., modes), append them to the run command:
docker run --rm -it --env-file .env squidleet --practice-mode daily
If you prefer using Docker Compose, you can create a docker-compose.yml
file with the following content:
version: "3.8"
services:
squidleet:
build: .
environment:
- LEETCODE_SESSION=<your_session_cookie>
stdin_open: true
tty: true
command: ["--practice-mode", "daily"]
To run the container:
docker-compose up
Squidleet is open-sourced under the MIT License. See the LICENSE
file for more details.