wheel (GitLab)
wheel (GHA via
nightly.link
)
We have moved to https://codeberg.org/KOLANICH-libs/SolutionTable.py, grab new versions there.
Under the disguise of "better security" Micro$oft-owned GitHub has discriminated users of 1FA passwords while having commercial interest in success and wide adoption of FIDO 1FA specifications and Windows Hello implementation which it promotes as a replacement for passwords. It will result in dire consequencies and is competely inacceptable, read why.
If you don't want to participate in harming yourself, it is recommended to follow the lead and migrate somewhere away of GitHub and Micro$oft. Here is the list of alternatives and rationales to do it. If they delete the discussion, there are certain well-known places where you can get a copy of it. Read why you should also leave GitHub.
This library was initially written in 2013 for analyzing Mafia/Werewolf games but it is suitable to solving problems. it has 3 main methods:
.init([one set],[another set])
- initializes table columns and rows.aIsNotB("element of the first set","element of the second set")
- used when it is known that 2 elements differ.removePairAndResolve(name1, name2)
- used when it is known that 2 elements are equal
Look the examples (the problems were taken from http://mmmf.msu.ru/archive/20052006/z5/11.html) .
The three clown: Bim
, Bom
and Bam
act in green
, red
and blue
shirts.
Their shoes are of the same colors.
Colors of Bim
's shoes and shirt match.
Neither Bom
's shirt, nor shoes are red
.
Bam
wears green
shoes and a shirt of a different color.
How are the clowns dressed? (All the clowns wear different shirts and different shoes).
var a = new SolutionTable();
var shoes={}, shirts={};
a.onResolved.push(console.info);
a.onResolved.push(function(v){for(let n in v) shoes[n]=v[n];});
// prbs/clowns_shoes.prb
a.init(["Bim","Bom","Bam"],["r","g","b"]);
a.isNot("Bom","r"); // Neither Bom's shirt, nor **shoes are red**.
a.equal("Bam","g"); // Bam wears green shoes
a.onResolved[a.onResolved.length-1]=(function(v){for(let n in v) shirts[n]=v[n];});
a.init(["Bim", "Bom", "Bam"],["r", "g", "b"]);
a.isNot("Bom", "r");//**Neither Bom's shirt**, nor shoes **are red**.
a.isNot("Bam", "g");//Bam wears green shoes
a.equal("Bim", shoes["Bim"]);//Colors of Bim's shoes and shirt match.
console.log(shoes,shirts);
One plant employs three friends: turner
, fitter
and welder
. Their surnames are Borisov
, Ivanov
and Semenov
.
The fitter
has neither brothers, nor sisters. He is the youngest of the friends.
Semenov
is married to Borisov
's sister and he is older than the turner
. Match the surnames to the occupations.
var a = new SolutionTable();
a.onResolved.push(console.info);
// prbs/plant.prb
a.init(["turner", "fitter", "welder"], ["Borisov", "Ivanov", "Semenov"]);
a.isNot("fitter","Borisov"); // fitter has no sisters, Borisov has
a.isNot("turner","Semenov"); // Semenov is older than the turner
a.isNot("fitter", "Semenov"); // fitter is the youngest, Semenov is older than someone
console.log(a.hash1,a.hash2);
Initially this was developed to reveal roles from mafia game log
var a = new SolutionTable();
a.onResolved.push(console.info);
a.init(["maniac", "maf", "doc", "psy"], ["Paul", "Vlad", "Nick", "Paul"]);
var alone = a.equal("doc", "Paul"); // we know he is doc
var alone = a.equal("maniac", "Paul"); // you need to be careful - no checks are implemented, so this will delete maniac column though Paul cannot be a maniac and this can be seen from the table.
console.log(alone,a.hash1,a.hash2);
// prbs/mafia_2.prb
a.init(["maniac", "maf", "doc", "psy"],["Paul", "Vlad", "Nick", "Paul"]);
var alone = a.isNot("doc", "Paul");
var alone = a.isNot("maniac", "Paul");
var alone = a.isNot("maniac", "Vlad");
var alone = a.isNot("psy", "Vlad");
var alone = a.isNot("psy", "Nick");
var alone = a.isNot("maniac", "Nick");
console.log(alone, a.hash1, a.hash2);
This repo also contains some python classes. They are not finished yet.
SolutionTable.py
contains my try to implement the same as inSolutionTable.js
, but using Bayessian approach.prbs
contains machine-readable problems in a form of*.prb
files. You needprb.py
to read them. You can also open them with Logic Problem Solver by Gary Darby. The archives with the tool contain quite some pre-formalized examples, that may be used in future to test this library.