Skip to content

gitprojectGT/Sudoku

Repository files navigation

Sudoku Game

Preparation time:

You should spend max. 4 hours on the project. The goal is not to "finish" the project, but to have code you are already familiar with so that we can discuss efficiently during the interview. Ideally, don't focus only on the back end or front end, and have a bit of both, even if it is heavily mocked/hard-coded.

Create a Sudoku game ( https://en.wikipedia.org/wiki/Sudoku ) with a JavaScript frontend and a backend of your choice (e.g. Java, Python, Node.js)

Do not use any MVC framework. The goal for us is to understand your coding skills.

The generation of the Sudoku grid is out of scope and can be read from an external source or mocked

Users should have some feedback when then enter a new number, letting them know if the input is valid and the validation should be done server side

Deploy the project into a Docker container

Deploy the application into a cloud environment of your choice (e.g. AWS, Azure) without the use of Kubernetes

The underlying server needs to be Linux (any flavour).

Implementation

A very simple JavaScript frontend with Flask (Python) REST API backend. Server-side validation with real-time feedback via API calls.

Quick Start

# Setup
python -m venv .venv
.venv\Scripts\activate  # Windows

pip install -r requirements.txt
python app.py

Access at http://localhost:5000

Command Line Interface

Play Sudoku directly in your terminal without starting the web server:

python sudoku_cli.py

Note: This feature has been implemented using Copilot for creating the scaffold if you don't want to use the web server. (Effort: 20 minutes)

How to play:

  • Enter moves in format: row col value (e.g., 3 5 7 places 7 at row 3, column 5)
  • To clear a cell: row col 0 (e.g., 3 5 0)
  • Commands:
    • h - Show help
    • n - Start new game
    • q - Quit

Display:

  • [#] - Fixed cells (cannot be modified)
  • *#* - Your last move
  • . - Empty cells

The CLI uses the same validation logic as the web version.

Running the Tests

# Install test dependencies
pip install -r requirements-dev.txt

# Run all tests
pytest

# Run with verbose output
pytest -v

Note: Test coverage is intentionally incomplete. The test suite includes basic happy path tests and essential error handling to demonstrate testing approach. Full coverage of all edge cases, validation rules, and error scenarios was not implemented due to time constraints.

Flask API Endpoints

GET /api/grid

Returns a new Sudoku game session.

Response:

{
  "game_id": "game_1234",
  "grid": [[5,3,0,...], ...],
  "difficulty": "easy"
}

POST /api/validate

Validates a player's move server-side.

Request:

{
  "game_id": "game_1234",
  "row": 0,
  "col": 2,
  "value": 4
}

Response:

{
  "valid": true,
  "message": "Valid move",
  "is_correct": true,
  "is_solved": false
}

GET /api/solution/<game_id>

Returns the solution for a game (testing endpoint).

Docker

docker build -t sudoku-game .
docker run -d -p 5000:5000 --name sudoku sudoku-game

AWS Deployment

Option 1: EC2 (Simple & Quick)

On your EC2 instance (Ubuntu/Amazon Linux):

# Clone or upload your code, then run:
bash deploy-aws.sh

The script installs Docker, builds the image, and runs the container on port 80.

Requirements:

  • Security group allows HTTP (port 80)
  • Linux instance with bash

Option 2: ECS Fargate (Lightweight)

  1. Push Docker image to ECR:
aws ecr create-repository --repository-name sudoku-game
aws ecr get-login-password --region REGION | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com
docker tag sudoku-game:latest ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/sudoku-game:latest
docker push ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/sudoku-game:latest
  1. Update aws-ecs-task-definition.json with your ACCOUNT_ID and REGION

  2. Register task and create service:

aws ecs register-task-definition --cli-input-json file://aws-ecs-task-definition.json
aws ecs create-service --cluster default --service-name sudoku-game --task-definition sudoku-game --desired-count 1 --launch-type FARGATE

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published