sudoku_api 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Simple, dart API for Sudoku puzzles #

Introduction #

sudoku_api simplifies the generation, interaction, and management of Sudoku Puzzles.

Well, how does it do that?

  • Contains a Built-in solver for generating new puzzles, or solving existing ones
  • Utilizes and exposes event streams for grid interactions (e.g. cell value changed), and puzzle states
  • Exposes a bunch of neat, easy to use models manipulating Cells, Positions, Grids, and even Patterns of a Sudoku puzzle

What is Sudoku?

... a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids (segments) that compose the grid contain all of the digits from 1 to 9. The puzzle setter provides a partially completed grid, which for a well-posed puzzle has a single solution.

Example #


import 'package:sudoku_api/Puzzle.dart';

void main() {
  
  PuzzleOptions puzzleOptions = new PuzzleOptions(patternName: "winter");
  
  Puzzle puzzle = new Puzzle(puzzleOptions);
  
    puzzle.generate().then((_) {
      print("=====================================");
      print("Your puzzle, fresh off the press:");
      print("-------------------------------------");
      printGrid(puzzle.board());
      print("=====================================");
      print("Give up? Here's your puzzle solution:");
      print("-------------------------------------");
      printGrid(puzzle.solvedBoard());
      print("=====================================");
    });
}

Output #

=====================================
Your puzzle, fresh off the press:
-------------------------------------
  9           8   
3 4     7     6 9 
    8   5   1     
      4   5       
4 5 6   9   3 1 2 
      3   2       
    2   8   9     
8 3     2     7 5 
  6           2   
=====================================
Give up? Here's your puzzle solution:
-------------------------------------
2 9 1 6 3 4 5 8 7 
3 4 5 1 7 8 2 6 9 
6 7 8 2 5 9 1 3 4 
1 2 3 4 6 5 7 9 8 
4 5 6 8 9 7 3 1 2 
7 8 9 3 1 2 4 5 6 
5 1 2 7 8 6 9 4 3 
8 3 4 9 2 1 6 7 5 
9 6 7 5 4 3 8 2 1 
=====================================

Contributing #

Let's make some sweet Sudoku, together.

  1. Fork sudoku_api, clone, and checkout the dev branch
  2. Write some pretty neat code, then push
  3. Create a pull request from a fork

Implementations

Sudoku Toolkit (AlvinRamoutar) - WIP

Inspiration

One of my college projects; Java Sudoku.

Libraries

Changelog #

1.1.1 #

  • Fixed Board.getColumn()

1.1.0 #

  • Added ability to serialize/deserialize puzzles

1.0.1 #

  • Updated some formatting and pubspec.yaml desc. after pkg. analysis

1.0.0 #

  • Initial release, woo hoo.

example/example.dart

import 'package:sudoku_api/sudoku_api.dart';

void main() {

  PuzzleOptions puzzleOptions = new PuzzleOptions(patternName: "winter");

  Puzzle puzzle = new Puzzle(puzzleOptions);

  puzzle.generate().then((_) {
    print("=====================================");
    print("Your puzzle, fresh off the press:");
    print("-------------------------------------");
    printGrid(puzzle.board());
    print("=====================================");
    print("Give up? Here's your puzzle solution:");
    print("-------------------------------------");
    printGrid(puzzle.solvedBoard());
    print("=====================================");
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sudoku_api: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sudoku_api/sudoku_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
51
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on May 23, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Fix lib/src/models/Pattern.dart. (-1 points)

Analysis of lib/src/models/Pattern.dart reported 2 hints:

line 5 col 7: The value of the field '_difficulty' isn't used.

line 6 col 10: The value of the field '_author' isn't used.

Fix lib/src/models/PuzzleOptions.dart. (-0.50 points)

Analysis of lib/src/models/PuzzleOptions.dart reported 1 hint:

line 7 col 16: The value of the field '_id' isn't used.

Format lib/src/Puzzle.dart.

Run flutter format to format lib/src/Puzzle.dart.

Format lib/src/models/Grid.dart.

Run flutter format to format lib/src/models/Grid.dart.

Format lib/src/models/Position.dart.

Run flutter format to format lib/src/models/Position.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
collection ^1.14.11 1.14.12
flutter 0.0.0
tuple ^1.0.3 1.0.3
uuid ^2.0.4 2.0.4
Transitive dependencies
charcode 1.1.3
convert 2.1.1
crypto 2.1.5
matcher 0.12.6
meta 1.1.8
path 1.7.0
quiver 2.1.3
sky_engine 0.0.99
stack_trace 1.9.3
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test