Skip to content

Sudoku Solver Added (C++)#38

Open
dhruvkej9 wants to merge 14 commits into
abhishekSharmaGithub:mainfrom
dhruvkej9:main
Open

Sudoku Solver Added (C++)#38
dhruvkej9 wants to merge 14 commits into
abhishekSharmaGithub:mainfrom
dhruvkej9:main

Conversation

@dhruvkej9

Copy link
Copy Markdown

Added a code of Sudoku Solver in C++ @abhishekSharmaGithub

@abhishekSharmaGithub

Copy link
Copy Markdown
Owner

please follow and star i will merge

@dhruvkej9

Copy link
Copy Markdown
Author

Done @abhishekSharmaGithub

@dhruvkej9

Copy link
Copy Markdown
Author

Merge it @abhishekSharmaGithub

@dhruvkej9

Copy link
Copy Markdown
Author

@abhishekSharmaGithub ????

@dhruvkej9

Copy link
Copy Markdown
Author

@abhishekSharmaGithub when will you merge ???

Copilot AI review requested due to automatic review settings February 17, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a Sudoku solver implementation in C++ along with a GitHub Actions workflow file. The PR description states "Added a code of Sudoku Solver in C++", but the changes include an unrelated workflow configuration file that appears to set up an automated code review/generation system.

Changes:

  • Added SudokuSolver.cpp containing a backtracking-based Sudoku solver implementation
  • Added .github/workflows/opencode.yml workflow file for automated code assistance (unrelated to PR description)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
SudokuSolver.cpp Implements a backtracking algorithm to solve Sudoku puzzles with functions for checking validity and solving the puzzle
.github/workflows/opencode.yml Adds GitHub Actions workflow for OpenCode agent integration with various LLM providers and MCP tools

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SudokuSolver.cpp
using namespace std;
bool isSafe(int row,int col,vector<vector<int>> &board,int val)
{
for(int i = 0;i<board.size();i++)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in for loop. Add spaces for better readability: for (int i = 0; i < board.size(); i++). The current format for(int i = 0;i<board.size();i++) is harder to read.

Copilot uses AI. Check for mistakes.
Comment thread SudokuSolver.cpp
Comment on lines +29 to +37
for(int row = 0 ;row < n;row++)
{
for(int col = 0;col < n;col++)
{
//cell empty
if(board[row][col] == 0)
{ //Trying every value which can fit in that
//box like we solve sudoku
for(int val = 1;val <= 9;val++)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in for loops. Add spaces for better readability: for (int row = 0; row < n; row++) on line 29, for (int col = 0; col < n; col++) on line 31, and for (int val = 1; val <= 9; val++) on line 37.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +79
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: false

- name: Write OpenCode auth.json
shell: bash
run: |
mkdir -p ~/.local/share/opencode
echo "${{ secrets.OPENCODE_AUTH_JSON_B64 }}" | base64 -d > ~/.local/share/opencode/auth.json
chmod 600 ~/.local/share/opencode/auth.json

- name: Clone and start local proxy
shell: bash
run: |
git clone --depth 1 https://github.com/dhruvkej9/opencode-local-proxy.git /tmp/opencode-local-proxy
cd /tmp/opencode-local-proxy
export OPENCODE_PROXY_PORT=4318
node proxy.mjs &
sleep 3
curl -s http://127.0.0.1:4318/health

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Configure OpenCode variant
shell: bash
run: |
mkdir -p ~/.config/opencode
cat > ~/.config/opencode/opencode.json <<'JSON'
{
"$schema": "https://opencode.ai/config.json",
"model": "local-proxy/kimi-k2.5-free",
"agent": {
"build": {
"model": "local-proxy/kimi-k2.5-free",
"variant": "high",
"prompt": "Use ripgrep (rg) instead of grep/glob/find for searching. Commands: rg 'pattern' (search content), rg --files (list all files), rg --files -g '*.ext' (filter by extension), rg --files -g '*.{js,py,md}' (multiple extensions), rg 'pattern' -g '*.ext' (search in specific file types), rg -i 'pattern' (case insensitive), rg -C 3 'pattern' (show 3 lines context). ripgrep is faster and respects .gitignore by default. Use context7 for latest package info.\n\nUse websearch when local context is insufficient. At least one websearch is recommended for each task before finalizing.\n\nYou are an AI agent with persistent memory powered by SuperMemory MCP (mcp.supermemory.ai).\n\nMemory rules:\n- Before responding, call supermemory_recall only when the request benefits from past context (preferences, prior decisions, project history, recurring issues).\n- Skip recall for direct mechanical actions that already contain full context (e.g., explicit save/forget memory commands, simple one-shot confirmations).\n- Prioritize the most recent and most relevant memories; if nothing useful is found, continue normally.\n- Store memory with supermemory_memory only when there is durable value.\n- Save only durable learnings, reusable patterns, and solved-issue knowledge (root cause + fix).\n- Do not save task logs, todos, progress updates, generic work-completed notes, or low-value status noise.\n- Update incrementally; avoid overwriting prior memory unless explicitly instructed.\n\nWorkflow:\n1) Recall relevant context when useful.\n2) Reason using recalled context plus current input.\n3) Save durable insights if any.\n4) Respond concisely and personalize using recalled memory when relevant.\n\nFallback:\n- If supermemory tools fail, continue and include a concise memory-candidate summary for later storage.\n\nUse MCP tools intentionally:\n- Use chrome-devtools MCP for browser debugging, performance bottlenecks, network waterfall, runtime errors, DOM/CSS inspection, and rendering issues.\n- For frontend or integration fixes, validate behavior and include what you verified in your response."
}
},
"watcher": {
"ignore": [
"node_modules/**",
"dist/**",
".git/**"
]
},
"mcp": {
"supermemory": {
"type": "remote",
"url": "https://mcp.supermemory.ai/mcp",
"headers": {
"Authorization": "Bearer ${{ secrets.SUPERMEMORY_API_KEY }}"

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses secrets (OPENCODE_AUTH_JSON_B64 and SUPERMEMORY_API_KEY) that may not be configured in the repository. Additionally, the workflow grants broad permissions including contents: write and pull-requests: write. If this workflow is intentionally being added, ensure these secrets are properly configured and the permissions are appropriate for the intended use case.

Copilot uses AI. Check for mistakes.
Comment thread SudokuSolver.cpp
@@ -0,0 +1,64 @@
#include <bits/stdc++.h>

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using #include <bits/stdc++.h> is a non-standard header that is compiler-specific (primarily GCC) and includes the entire C++ standard library, leading to increased compilation time and reduced portability. Instead, include only the specific headers needed. For this code, you would need: #include <iostream> and #include <vector>.

Suggested change
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

Copilot uses AI. Check for mistakes.
Comment thread SudokuSolver.cpp
@@ -0,0 +1,64 @@
#include <bits/stdc++.h>
using namespace std;

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using using namespace std; is generally discouraged, especially in header files or code that may be included in larger projects. It pollutes the global namespace and can lead to name conflicts. Consider using explicit std:: prefixes for standard library types (e.g., std::vector) or use specific using declarations if needed.

Copilot uses AI. Check for mistakes.
Comment thread SudokuSolver.cpp
Comment on lines +43 to +44
bool aageSolutionPossible = solve(board);
if(aageSolutionPossible)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name aageSolutionPossible appears to be in Hindi/Hinglish (where "aage" means "ahead" or "forward"). For consistency and broader understanding, use English variable names. Consider renaming to isSolutionPossible or canSolve.

Suggested change
bool aageSolutionPossible = solve(board);
if(aageSolutionPossible)
bool isSolutionPossible = solve(board);
if(isSolutionPossible)

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +139
name: opencode

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

jobs:
opencode:
if: |
github.actor != 'opencode-agent[bot]' &&
(
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
)
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: false

- name: Write OpenCode auth.json
shell: bash
run: |
mkdir -p ~/.local/share/opencode
echo "${{ secrets.OPENCODE_AUTH_JSON_B64 }}" | base64 -d > ~/.local/share/opencode/auth.json
chmod 600 ~/.local/share/opencode/auth.json

- name: Clone and start local proxy
shell: bash
run: |
git clone --depth 1 https://github.com/dhruvkej9/opencode-local-proxy.git /tmp/opencode-local-proxy
cd /tmp/opencode-local-proxy
export OPENCODE_PROXY_PORT=4318
node proxy.mjs &
sleep 3
curl -s http://127.0.0.1:4318/health

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Configure OpenCode variant
shell: bash
run: |
mkdir -p ~/.config/opencode
cat > ~/.config/opencode/opencode.json <<'JSON'
{
"$schema": "https://opencode.ai/config.json",
"model": "local-proxy/kimi-k2.5-free",
"agent": {
"build": {
"model": "local-proxy/kimi-k2.5-free",
"variant": "high",
"prompt": "Use ripgrep (rg) instead of grep/glob/find for searching. Commands: rg 'pattern' (search content), rg --files (list all files), rg --files -g '*.ext' (filter by extension), rg --files -g '*.{js,py,md}' (multiple extensions), rg 'pattern' -g '*.ext' (search in specific file types), rg -i 'pattern' (case insensitive), rg -C 3 'pattern' (show 3 lines context). ripgrep is faster and respects .gitignore by default. Use context7 for latest package info.\n\nUse websearch when local context is insufficient. At least one websearch is recommended for each task before finalizing.\n\nYou are an AI agent with persistent memory powered by SuperMemory MCP (mcp.supermemory.ai).\n\nMemory rules:\n- Before responding, call supermemory_recall only when the request benefits from past context (preferences, prior decisions, project history, recurring issues).\n- Skip recall for direct mechanical actions that already contain full context (e.g., explicit save/forget memory commands, simple one-shot confirmations).\n- Prioritize the most recent and most relevant memories; if nothing useful is found, continue normally.\n- Store memory with supermemory_memory only when there is durable value.\n- Save only durable learnings, reusable patterns, and solved-issue knowledge (root cause + fix).\n- Do not save task logs, todos, progress updates, generic work-completed notes, or low-value status noise.\n- Update incrementally; avoid overwriting prior memory unless explicitly instructed.\n\nWorkflow:\n1) Recall relevant context when useful.\n2) Reason using recalled context plus current input.\n3) Save durable insights if any.\n4) Respond concisely and personalize using recalled memory when relevant.\n\nFallback:\n- If supermemory tools fail, continue and include a concise memory-candidate summary for later storage.\n\nUse MCP tools intentionally:\n- Use chrome-devtools MCP for browser debugging, performance bottlenecks, network waterfall, runtime errors, DOM/CSS inspection, and rendering issues.\n- For frontend or integration fixes, validate behavior and include what you verified in your response."
}
},
"watcher": {
"ignore": [
"node_modules/**",
"dist/**",
".git/**"
]
},
"mcp": {
"supermemory": {
"type": "remote",
"url": "https://mcp.supermemory.ai/mcp",
"headers": {
"Authorization": "Bearer ${{ secrets.SUPERMEMORY_API_KEY }}"
},
"enabled": true
},
"chrome-devtools": {
"type": "local",
"command": [
"npx",
"-y",
"chrome-devtools-mcp@latest",
"--headless",
"--isolated",
"--chromeArg=--no-sandbox",
"--chromeArg=--disable-dev-shm-usage",
"--logFile=/tmp/chrome-devtools-mcp.log"
],
"enabled": true
}
},
"lsp": false,
"permission": {
"external_directory": "allow",
"question": "allow",
"*": "allow"
},
"provider": {
"local-proxy": {
"npm": "@ai-sdk/openai-compatible",
"name": "Local Proxy (Free Models + Codex Fallback)",
"options": {
"baseURL": "http://127.0.0.1:4318/v1",
"apiKey": "public"
},
"models": {
"kimi-k2.5-free": {
"name": "Kimi K2.5 Free",
"limit": { "context": 262000, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"glm-5-free": {
"name": "GLM-5 Free",
"limit": { "context": 200000, "output": 128000 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex (Fallback)",
"limit": { "context": 272000, "output": 128000 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
}
}
}
}
}
JSON

- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
OPENCODE_PERMISSION: '{"*": "allow"}'
with:
model: local-proxy/kimi-k2.5-free

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire workflow file appears unrelated to the PR description, which states "Added a code of Sudoku Solver in C++". This workflow configures an OpenCode agent for automated code review/generation. If this workflow file is intentionally being added, it should be in a separate PR with appropriate justification and review. Including unrelated infrastructure changes in a code contribution PR makes the review more complex and obscures the actual contribution.

Copilot uses AI. Check for mistakes.
Comment thread SudokuSolver.cpp
}
void solveSudoku(vector<vector<int>>& sudoku)
{
solve(sudoku);

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SudokuSolver.cpp file lacks a main function for demonstration or testing purposes. Looking at other files in this repository (e.g., binary search.cpp, insertionsort.cpp, selection sort .cpp, Travelling_Sales_Person_Problem.cpp), they all include a main function that demonstrates how to use the implemented algorithm. Consider adding a main function that creates a sample Sudoku puzzle and demonstrates the solver in action, consistent with the codebase conventions.

Suggested change
solve(sudoku);
solve(sudoku);
}
void printBoard(const vector<vector<int>>& board)
{
for (int row = 0; row < board.size(); row++)
{
for (int col = 0; col < board[row].size(); col++)
{
cout << board[row][col] << " ";
}
cout << endl;
}
}
int main()
{
vector<vector<int>> sudoku = {
{3, 0, 6, 5, 0, 8, 4, 0, 0},
{5, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 8, 7, 0, 0, 0, 0, 3, 1},
{0, 0, 3, 0, 1, 0, 0, 8, 0},
{9, 0, 0, 8, 6, 3, 0, 0, 5},
{0, 5, 0, 0, 9, 0, 6, 0, 0},
{1, 3, 0, 0, 0, 0, 2, 5, 0},
{0, 0, 0, 0, 0, 0, 0, 7, 4},
{0, 0, 5, 2, 0, 6, 3, 0, 0}
};
cout << "Original Sudoku:" << endl;
printBoard(sudoku);
if (solve(sudoku))
{
cout << endl << "Solved Sudoku:" << endl;
printBoard(sudoku);
}
else
{
cout << "No solution exists for the given Sudoku." << endl;
}
return 0;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants