Skip to main content
Sign in
Snippets Groups Projects

sudoku-cpp-practice

Project ID: 76218772
Select Git revision
  • main default protected
1 result
  • Open with
  • Download source code
  • Your workspaces

      A workspace is a virtual sandbox environment for your code in GitLab.

      No agents available to create workspaces. Please consult Workspaces documentation for troubleshooting.

  • user avatar
    anyaf112358 authored
    5f1051f2
    History

    C++ Sudoku Practice

    C++ の基礎〜応用をまとめて学べる教材プロジェクト

    CLI版(コンソール)と GUI版(raylib)を使って、
    C++・アルゴリズム・CMake・raylib・GitHub を全部まとめて学べる学習向けプロジェクトです。

    この教材で学べること

    数独ロジック

    • 2次元配列(9×9 の Board 構造)
    • 行・列・3×3 ブロックのチェック
    • 再帰(バックトラック)によるソルバー
    • 解が1つのみの問題生成アルゴリズム

    GUI・CUI の違い

    • CLI(標準入出力)
    • GUI(raylib)による描画・入力処理

    開発環境

    • CMake の基本
    • GitHub でのソース管理
    • クロスプラットフォーム構成

    フォルダ構成

    sudoku-cpp-practice/
    ├─ README.md
    ├─ LICENSE
    ├─ cli/
    │  ├─ CMakeLists.txt
    │  └─ src/main.cpp
    └─ gui-raylib/
       ├─ CMakeLists.txt
       └─ src/main.cpp

    セットアップ(共通)

    Windows

    • Visual Studio 2022 Build Tools
    • CMake
    • Git

    macOS

    brew install cmake git
    xcode-select --install

    Linux

    sudo apt update
    sudo apt install cmake g++ git build-essential

    CLI版(学習の入り口)

    cd cli
    mkdir build
    cd build
    cmake ..
    cmake --build .

    実行:

    • Windows → .\Debug\cli.exe
    • macOS/Linux → ./cli

    CLI版の動き

    • 新しいパズル生成
    • Enterで解答表示
    • コード内に超丁寧コメント

    GUI版(raylib)

    <<<<<<< HEAD
    =======
    .\Debug\sudoku.exe

    macOS / Linux

    ./sudoku

    4. GUI版(raylib)のビルド方法

    ※ raylib は CMake が自動でダウンロード → ビルドします。

    Windows / macOS / Linux 共通

    >>>>>>> 9613f4c75d7e1f59593d3e4dc3cca3f3249c9ec7
    cd gui-raylib
    mkdir build
    cd build
    cmake ..
    cmake --build .

    実行:

    • Windows → .\Debug\sudoku_gui.exe
    • macOS/Linux → ./sudoku_gui

    <<<<<<< HEAD

    GUI版の操作

    • クリックでマス選択
    • 1〜9:数字入力(テンキー対応)
    • 0 / Del:消す
    • H:間違いを赤く表示(ヒント)
    • N:新規問題
    • S:解答を全部表示

    数独アルゴリズム概要

    • FindEmpty() : 空きマス探索
    • IsValid() : 置けるか判定
    • Solve() : 再帰バックトラック
    • SolveCount() : 解の数チェック
    • GeneratePuzzle() : 一意解の問題生成 =======

    Windows

    .\Debug\sudoku.exe

    macOS / Linux

    ./sudoku

    9613f4c75d7e1f59593d3e4dc3cca3f3249c9ec7

    推奨学習ルート

    1. CLI版 main.cpp を読む
    2. Solve() を理解
    3. GeneratePuzzle() を理解
    4. GUI版 main.cpp を読む
    5. 入力処理・描画処理を見る
    6. 機能追加に挑戦

    ライセンス

    MIT License

    この教材の目的

    • C++ を楽しく学ぶ
    • ゲームを作る流れを学ぶ
    • GUI と CLI を理解する
    • アルゴリズムに触れる
    • GitHub の使い方を学ぶ

    改善や提案は Issue / Pull Request まで!