Skip to content

ajnirp/tango

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

  • A library implementing a backtracking solver for LinkedIn Tango.
  • Code might not be very idiomatic.
  • No significant optimizations used.
  • Some testcases included.

Running the code

cargo test

Usage

The tests mod in lib.rs contains examples of how to specify a testcase, and run the solver on a testcase.

How the solver works

It uses a simple backtracking algorithm. For each unfilled square:

  • See if you can place a 0 there without violating:
    • the requirement that no three cells contain the same value
    • the requirement that no row or column has more than half of the cells set to the same value
    • the equality / inequality constraints
  • If yes, set the value and make a recursive call to the solver with the next index.
    • If the recursive call succeeds, we're done.
    • If the recursive call fails, we can't place a 0 there.
  • Now try the above but with a 1.
  • If neither works, we can't place either value there. Our solution thus far won't work. Return false.

About

LinkedIn Tango solver in Rust

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages