Difference between revisions of "W3911 Sudoku Server"
From Coder Merlin
Line 26: | Line 26: | ||
{{CodeExplorer | {{CodeExplorer | ||
| | |exerciseID=1 | ||
|mode=swift | |mode=swift | ||
|height= | |height=400 | ||
|initialCode=import Foundation | |initialCode=import Foundation | ||
Line 43: | Line 43: | ||
} | } | ||
print(string) | print(string) | ||
}} | |||
{{CodeExplorer | |||
|exerciseId=2 | |||
|mode=swift | |||
|height=400 | |||
|initialCode=import Foundation | |||
import FoundationNetworking | |||
var request = URLRequest(url: URL(string: "https://language-server.codermerlin.com/now")!) | |||
request.httpMethod = "GET" | |||
let session = URLSession.shared | |||
let task = session.dataTask(with: request, completionHandler: { data, response, error -> Void in | |||
if let data = data, | |||
let string = String(data: data, encoding: .utf8) { | |||
print(string) | |||
} | |||
}) | |||
task.resume() | |||
sleep(3) | |||
}} | }} |
Revision as of 07:39, 5 October 2021
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Background A Sudoku board is made up of nine boxes. Boxes (container for nine cells) are listed from top-to-bottom, left-to-right indexed from zero. Cells are listed from top-to-bottom, left-to-right, indexed from zero. All valid payloads and responses must use well-formed JSON. “cells” is returned as follows: “cells”: [[<nine values from top-left>], [<nine values from top-middle>], …]
End Points
- POST /games
* Action: Creates a new game and associated board * Payload: None * Response: Id uniquely identifying a game * Status code: 201 Created
- GET /games/<id>/cells
* Action: None * Payload: None * Response: cells * Status code: 200 OK
- PUT /games/<id>/cells/<boxIndex>/<cellIndex>
* Action: Place specified value at in game at boxIndex, cellIndex * Payload: value (null for removing value) * Response: Nothing * Status: 204 No Content