-
Notifications
You must be signed in to change notification settings - Fork 20
Sudoku Solver Added (C++) #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1a4fa36
5bc5dd6
37d1d51
2ffef26
f596b29
4c978b8
193368b
6ab2478
d5dd359
821a356
b9b5134
7c5e876
5e7306a
dfddbe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| 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"] } | ||
| }, | ||
| "big-pickle": { | ||
| "name": "Big-Pickle", | ||
| "limit": { "context": 200000, "output": 64000 }, | ||
| "modalities": { "input": ["text", "image"], "output": ["text"] } | ||
| }, | ||
| "minimax-m2.5-free": { | ||
| "name": "MiniMax M2.5 Free", | ||
| "limit": { "context": 204800, "output": 128000 }, | ||
| "modalities": { "input": ["text", "image"], "output": ["text"] } | ||
| }, | ||
| "glm-5-free": { | ||
| "name": "GLM-5 Free", | ||
| "limit": { "context": 200000, "output": 128000 }, | ||
| "modalities": { "input": ["text", "image"], "output": ["text"] } | ||
| }, | ||
| "trinity-large-preview-free": { | ||
| "name": "Trinity Large Preview Free", | ||
| "limit": { "context": 128000, "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"] } | ||
| }, | ||
| "gpt-5-nano": { | ||
| "name": "GPT-5 Nano", | ||
| "limit": { "context": 400000, "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 | ||
|
Comment on lines
+1
to
+159
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <bits/stdc++.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <bits/stdc++.h> | |
| #include <iostream> | |
| #include <vector> |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
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
AI
Feb 17, 2026
There was a problem hiding this comment.
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
AI
Feb 17, 2026
There was a problem hiding this comment.
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
AI
Feb 17, 2026
There was a problem hiding this comment.
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.
| bool aageSolutionPossible = solve(board); | |
| if(aageSolutionPossible) | |
| bool isSolutionPossible = solve(board); | |
| if(isSolutionPossible) |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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: writeandpull-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.