Giter Site home page Giter Site logo

sudoku-fight-club's Introduction

Sudoku Fight Club

A project for finding the fastest and shortest ruby programs to solve sudoku puzzles.

Instructions

  • Create a fork of the project here
  • Give your self a team name and copy contestants/basic.rb into contestants/team_name.rb. You're also permitted to put any files you want in contestants/team_name/.
  • Come up with the fastest or shortest solution you can and submit a pull request
  • The length of a program is the sum of all it's non whitespace characters.
  • The speed of the program is measured by taking the average speed for 100 randomly generated puzzles.
  • You cannot implement a solution that simply returns a cached version of the solution.
  • Profit

Interface

You should implement a ruby class that takes a puzzle and has a solve method.

It should adhere to the following format:

class MyTeamNameSolver

  # Takes a sudoku puzzle represented by a 81 character string.
  #
  # The string is read left to right, top to bottom.
  # The digits 0-8 represent filled in sudoku digits
  # The character '-' represents a blank space
  #
  # Example puzzle:  "1--856-72---3124--52-470631-132-5--62--7-83156751342800675418234520-316738162-504"
  def initialize(board)
  end

  # Returns a string representing the solved solution according to the
  # above format
  def solve
  end
end

Testing your solution

Test the length of your solution

# Set a team name, checks for team_name.rb and team_name/ in
# the contestants/ directory and sums the length
rake solution:length[basic]

Test the speed of your solution

# Test your solution against puzzle.txt and print the time
rake solution:verify[BasicSolver]

# Test your solution against all the provided puzzles and print the average time
rake solution:verify[BasicSolver,puzzles]

More rake tasks

Create a new puzzle with:

# Create a single puzzle and prints it to stdout
rake puzzle:generate

# Create 2 puzzles and prints them to stdout
rake puzzle:generate[2]

# Create one puzzle and prints it into the file puzzle.txt
rake puzzle:generate[1,puzzle.txt]

# Create 3 puzzles and places them in files called sudoku0.txt...sudoku2.txt in the directory puzzles
rake puzzle:generate[3,puzzles]

Solve existing puzzles with

# Solve the puzzle in ./puzzle.txt
rake puzzle:solve

# Solve the puzzle in dir/my_puzzle.txt
rake puzzle:solve[dir/my_puzzle.txt]

# Solve all puzzles in the puzzle directory
rake puzzle:solve[puzzle]

Testing the sudoku generator code

Run the following command to test the codebase

ruby fight_club_spec.rb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.