einwork.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. function EV() {
  2. this.__e = {};
  3. }
  4. EV.prototype.__e = {};
  5. EV.prototype.emit = function(n) {
  6. var that = this;
  7. var args = [].slice.apply(arguments, [1]);
  8. (this.__e[n] || []).map(function(lis) {
  9. lis.map(function(fn) {
  10. fn.apply(that, args)
  11. })
  12. })
  13. return this;
  14. }
  15. EV.prototype.on = function(n) {
  16. var args = [].slice.apply(arguments, [1]);
  17. this.__e[n] = this.__e[n] || [];
  18. this.__e[n].push(args);
  19. return this;
  20. }
  21. function inherits(ctor, superCtor) {
  22. var Obj = function() {};
  23. Obj.prototype = superCtor.prototype;
  24. ctor.prototype = new Obj
  25. }
  26. function permutates(xs) {
  27. var ret = [];
  28. for (var i = 0; i < xs.length; i = i + 1) {
  29. var rest = permutates(xs.slice(0, i).concat(xs.slice(i + 1)));
  30. if (!rest.length) {
  31. ret.push([xs[i]])
  32. } else {
  33. for (var j = 0; j < rest.length; j = j + 1) {
  34. ret.push([xs[i]].concat(rest[j]))
  35. }
  36. }
  37. }
  38. return ret;
  39. }
  40. function mo() {
  41. this.variabler = {};
  42. this.tabel = {};
  43. this.tableHead = [];
  44. this.tableName = "";
  45. this.regler = [];
  46. this._internal_step_counter = 0;
  47. this.rmat = [];
  48. this.funcs = {};
  49. this.rulas = [];
  50. }
  51. inherits(mo, EV)
  52. mo.prototype.addVariabelSet = function(navn, arr) {
  53. this.variabler[navn] = arr;
  54. return this;
  55. }
  56. mo.prototype.addVariableTable = function(navn, arr) {
  57. this.tableHead = arr;
  58. this.tableName = navn;
  59. return this;
  60. }
  61. mo.prototype.addFunction = function(name, func) {
  62. this.funcs[name] = func;
  63. return this;
  64. }
  65. mo.prototype.addClause = function() {
  66. var args = Array.prototype.slice.apply(arguments, []);
  67. while (args.length) {
  68. var arg = args.shift();
  69. var props = Object.keys(arg);
  70. var propid1, propid2;
  71. if (this.variabler[props[0]]) {
  72. propid1 = Object.keys(this.variabler).indexOf(props[0]);
  73. }
  74. if (this.variabler[props[1]]) {
  75. propid2 = Object.keys(this.variabler).indexOf(props[1]);
  76. } else {}
  77. var arr = []
  78. if (propid1 > -1 && propid2 > -1) {
  79. val1 = this.variabler[props[0]].indexOf(arg[props[0]])
  80. val2 = this.variabler[props[1]].indexOf(arg[props[1]])
  81. arr = ["check", propid1, propid2, val1, val2, [props[0], arg[props[0]], props[1], arg[props[1]]].join(" ")];
  82. } else {
  83. var lookfor = props[props.length - 1];
  84. if (this.funcs[lookfor]) {
  85. arr = this.funcs[lookfor].apply(this, [arg])
  86. }
  87. }
  88. }
  89. this.rulas.push(arr);
  90. return this;
  91. }
  92. mo.prototype.build = function(tabl) {
  93. var r = [];
  94. var arr = [];
  95. var pertable = []
  96. for (var navn in this.variabler) {
  97. pertable.push(permutates((this.variabler[navn]).map(function(a, i) {
  98. return i
  99. })));
  100. }
  101. return pertable;
  102. }
  103. mo.prototype.checkn = function(prop1, prop2, val1, val2) {
  104. return this.current[this.sos[prop1]][val1] == val2
  105. }
  106. mo.prototype.check = function(prop1, prop2, val1, val2) {
  107. var i;
  108. // console.log(prop1,this.sos[prop1], prop2, this.current[this.sos[prop1]],this.current[this.sos[prop2]],val1,val2)
  109. for (i = 0; i < 5; i++) {
  110. if (this.current[this.sos[prop1]][i] == val1) {
  111. // console.log("II,",i,this.current[this.sos[prop1]][i],"=",val1,"&", this.current[this.sos[prop2]][i],"=",val2 );
  112. var p;
  113. p = (this.current[this.sos[prop2]][i] == val2)
  114. return p;
  115. }
  116. }
  117. return false;
  118. }
  119. mo.prototype.checkLeft = function(prop1, prop2, val1, val2) {
  120. var i;
  121. for (i = 0; i < 4; i++) {
  122. if (this.current[this.sos[prop1]][i] == val1) {
  123. var p;
  124. p = (this.current[this.sos[prop2]][i + 1] == val2)
  125. return p;
  126. }
  127. }
  128. return false;
  129. }
  130. mo.prototype.checkRight = function(prop1, prop2, val1, val2) {
  131. var i;
  132. for (i = 1; i < 5; i++) {
  133. if (this.current[this.sos[prop1]][i] == val1) {
  134. var p;
  135. p = (this.current[this.sos[prop2]][i - 1] == val2)
  136. return p;
  137. }
  138. }
  139. return false;
  140. }
  141. mo.prototype.checkBoth = function(prop1, prop2, val1, val2) {
  142. return this.checkLeft(prop1, prop2, val1, val2) || this.checkRight(prop1, prop2, val1, val2)
  143. }
  144. function intersection() {
  145. var result = [];
  146. var lists;
  147. if (arguments.length === 1) {
  148. lists = arguments[0];
  149. } else {
  150. lists = arguments;
  151. }
  152. for (var i = 0; i < lists.length; i++) {
  153. var currentList = lists[i];
  154. for (var y = 0; y < currentList.length; y++) {
  155. var currentValue = currentList[y];
  156. if (result.indexOf(currentValue) === -1) {
  157. var existsInAll = true;
  158. for (var x = 0; x < lists.length; x++) {
  159. if (lists[x].indexOf(currentValue) === -1) {
  160. existsInAll = false;
  161. break;
  162. }
  163. }
  164. if (existsInAll) {
  165. result.push(currentValue);
  166. }
  167. }
  168. }
  169. }
  170. return result;
  171. }
  172. mo.prototype.solve = function() {
  173. var self = this;
  174. self.current = this.build("House").shift();
  175. var sa = Object.keys(this.variabler);
  176. self.sos = sa.map(function(a) {
  177. return 0; //self.current.length - 1; //Math.floor(Math.random()*self.current.length-1);
  178. })
  179. self.subspace = self.current.length;
  180. self.varspace = sa.length;
  181. self.space = Math.pow(self.subspace, self.varspace - 1);
  182. var iteration = 0;
  183. var maxi = 0;
  184. var ioa = -1;
  185. var soso = [];
  186. var sat = false;
  187. self.rulas = self.rulas; //slice(0, 9);
  188. /* self.rulas.sort(function(a, b) {
  189. return a[1] > b[1] ? -1 : a[1] < b[1] ? 1 : a[2] > b[2] ? 1 : a[2] < b[2] ? -1 : 0
  190. })
  191. */
  192. // console.log(self.rulas);
  193. // return false;
  194. // først find variabler som bruges i samme opslag.
  195. var tas = {}
  196. var firsta = [];
  197. self.rulas.map(function(ru) {
  198. console.log(ru);
  199. if (ru[1] == ru[2]) {
  200. firsta.push(ru);
  201. }
  202. })
  203. self.sos = self.sos.map(function(a) {
  204. return 0
  205. })
  206. var osa = -1
  207. console.log(firsta);
  208. var cands = [];
  209. for (var x = 0; x < firsta.length; x++) {
  210. self.sos = self.sos.map(function(a) {
  211. return 0
  212. })
  213. var t = firsta[x];
  214. var ca = [];
  215. for (var i = 0; i < self.subspace; i++) {
  216. var ff = false;
  217. self.sos[t[1]] = i
  218. console.log(self.sos);
  219. ff = self[t.slice(0, 1)[0]].apply(self, t.slice(1))
  220. if (ff) {
  221. ca.push(i);
  222. }
  223. }
  224. cands.push([t[1], ca]);
  225. }
  226. console.log(cands);
  227. // var inta=intersection.apply(this,cands.map(function(a){ return a[1]}));
  228. self.sos = self.sos.map(function(a) {
  229. return 0
  230. })
  231. var cc = cands.length;
  232. var ticks = [0, 0, 0, 0, 0];
  233. var ic = 0;
  234. var iomax = self.rulas.length;
  235. var ioa = 0;
  236. for (var i0 = 0; i0 < cands[0][1].length; i0++) {
  237. if (cands[1]) {
  238. for (var i1 = 0; i1 < cands[1][1].length; i1++) {
  239. if (cands[2]) {
  240. for (var i2 = 0; i2 < cands[2][1].length; i2++) {
  241. if (cands[3]) {
  242. } else {
  243. var st = [0, 1, 2, 3, 4]
  244. self.sos[cands[0][0]] = cands[0][1][i0]
  245. self.sos[cands[1][0]] = cands[1][1][i1]
  246. self.sos[cands[2][0]] = cands[2][1][i2]
  247. st.splice(st.indexOf(cands[0][0]), 1);
  248. st.splice(st.indexOf(cands[1][0]), 1);
  249. st.splice(st.indexOf(cands[2][0]), 1);
  250. for (var i3 = 0; i3 < 120; i3++) {
  251. for (var i4 = 0; i4 < 120; i4++) {
  252. ic++
  253. self.sos[st[0]] = i3
  254. self.sos[st[1]] = i4
  255. var io = 0;
  256. var ff = true;
  257. while (io < iomax && ff) {
  258. ff = false;
  259. var t = self.rulas[io];
  260. ff = self[t.slice(0, 1)[0]].apply(self, t.slice(1))
  261. if (ff) {
  262. io++;
  263. }
  264. }
  265. if (io > ioa) {
  266. // soso.push([].concat(self.sos));
  267. ioa = io;
  268. var tt = self.rulas.map(function(t) {
  269. return [self[t.slice(0, 1)[0]].apply(self, t.slice(1))].concat(t);
  270. })
  271. console.log(ic, io, ioa, iomax, self.sos.join(" "), tt.map(function(a) {
  272. return a.join(" ")
  273. }));
  274. }
  275. if(ioa >= iomax){
  276. return self.sos;
  277. }
  278. if(ic % 1000000 === 0){
  279. console.log("X", ic, io,ioa,iomax, self.sos[cands[0][0]], self.sos[cands[1][0]], self.sos[cands[2][0]], i3, i4);
  280. }
  281. }
  282. }
  283. }
  284. }
  285. } else {
  286. console.log(cands[0][1][i1], cands[1][1][i2])
  287. }
  288. }
  289. }
  290. }
  291. return false;
  292. // console.log("II",inta);
  293. /* for (var i = 0; i < self.subspace; i++) {
  294. self.sos[0] = i;
  295. var mio = 0;
  296. var ff = true;
  297. var iomax = 1; // firsta.length;
  298. while (mio < iomax && ff) {
  299. var t = firsta[mio];
  300. ff = self[t.slice(0, 1)[0]].apply(self, t.slice(1))
  301. if (ff) {
  302. mio++;
  303. }
  304. }
  305. if (mio > 0) {
  306. cands.push(i);
  307. } else {}
  308. }
  309. self.sos[0] = 0;
  310. */
  311. //cands = [105,81]
  312. var iomax = self.rulas.length;
  313. while (!sat && cands.length > 0) {
  314. var cand1 = cands.shift();
  315. self.sos[0] = cand1;
  316. iteration = 0;
  317. while (!sat && iteration < self.space) {
  318. var io = 0;
  319. var ff = true;
  320. while (io < iomax && ff) {
  321. var t = self.rulas[io];
  322. ff = self[t.slice(0, 1)[0]].apply(self, t.slice(1))
  323. if (ff) {
  324. io++;
  325. }
  326. }
  327. if (io > ioa) {
  328. soso.push([].concat(self.sos));
  329. ioa = io;
  330. var tt = self.rulas.map(function(t) {
  331. return [self[t.slice(0, 1)[0]].apply(self, t.slice(1))].concat(t);
  332. })
  333. console.log(iteration, io, ioa, iomax, self.sos.join(" "), tt.map(function(a) {
  334. return a.join(" ")
  335. }));
  336. }
  337. if (io >= iomax) {
  338. sat = true;
  339. // console.log((iteration).toFixed(0) + " ", ioa, "::", self.sos.join(" "), soso.join(" | "));
  340. } else {
  341. self.sos[1] = iteration % self.subspace;
  342. self.sos[2] = Math.floor(iteration / self.subspace) % self.subspace;
  343. self.sos[3] = Math.floor(iteration / (self.subspace * self.subspace)) % self.subspace;
  344. self.sos[4] = Math.floor(iteration / (self.subspace * self.subspace * self.subspace)) % self.subspace;
  345. // self.sos[0] = Math.floor(iteration / (self.subspace * self.subspace * self.subspace * self.subspace)) % self.subspace;
  346. }
  347. if (iteration % 10000000 === 0) {
  348. self.emit("status", (iteration / (self.space / 100)).toFixed(2), ioa + ":: " + cands.length + ":: " + self.sos.join(" "))
  349. }
  350. // console.log(iteration, self.sos.join(" "));
  351. iteration++;
  352. }
  353. }
  354. /* while (!sat && iteration < self.space) {
  355. var io = 0;
  356. var ff = true;
  357. while (io < iomax && ff) {
  358. var t = self.rulas[io];
  359. ff = self[t.slice(0, 1)[0]].apply(self, t.slice(1))
  360. if (ff) {
  361. io++;
  362. }
  363. }
  364. if (io > ioa) {
  365. soso.push([].concat(self.sos));
  366. ioa = io;
  367. var tt = self.rulas.map(function(t) {
  368. return [self[t.slice(0, 1)[0]].apply(self, t.slice(1))].concat(t);
  369. })
  370. console.log(iteration, io, ioa, iomax, self.sos.join(" "), tt.map(function(a) {
  371. return a.join(" ")
  372. }));
  373. }
  374. if (io >= iomax) {
  375. sat = true;
  376. // console.log((iteration).toFixed(0) + " ", ioa, "::", self.sos.join(" "), soso.join(" | "));
  377. } else {
  378. self.sos[4] = iteration % self.subspace;
  379. self.sos[1] = Math.floor(iteration / self.subspace) % self.subspace;
  380. self.sos[2] = Math.floor(iteration / (self.subspace * self.subspace)) % self.subspace;
  381. self.sos[3] = Math.floor(iteration / (self.subspace * self.subspace * self.subspace)) % self.subspace;
  382. self.sos[0] = Math.floor(iteration / (self.subspace * self.subspace * self.subspace * self.subspace)) % self.subspace;
  383. }
  384. if (iteration % 10000000 === 0) {
  385. self.emit("status", (iteration / (self.space / 100)).toFixed(2), self.sos.join(" "))
  386. }
  387. iteration++;
  388. }*/
  389. if (sat) {
  390. console.log("SOLUTION FOUND");
  391. }
  392. var tt = self.rulas.map(function(t) {
  393. return [self[t.slice(0, 1)[0]].apply(self, t.slice(1))].concat(t);
  394. })
  395. console.log(iteration, self.sos.join(" "), tt.map(function(a) {
  396. return a.join(" ")
  397. }));
  398. self.printit()
  399. }
  400. mo.prototype.printit = function(vals) {
  401. var self = this;
  402. var vals = vals || self.sos;
  403. var lpad = function(s, l) {
  404. while (s.length < l) {
  405. s = " " + s
  406. };
  407. return s;
  408. }
  409. var rpad = function(s, l) {
  410. while (s.length < l) {
  411. s = s + " "
  412. };
  413. return s;
  414. }
  415. var s = [];
  416. s.push([" ", 1, 2, 3, 4, 5].map(function(a) {
  417. return lpad("" + a, 12)
  418. }).join(" "));
  419. Object.keys(self.variabler).map(function(k, ia) {
  420. s.push([k, 0, 1, 2, 3, 4].map(function(a, io) {
  421. return a == k ? rpad(k + ":" + vals[ia], 20) : lpad("" + self.variabler[k][self.current[vals[ia]][a]], 12)
  422. }).join(" "))
  423. // s.push( )
  424. })
  425. console.log(s.join("\n") + "\n")
  426. }
  427. mo.prototype.stats = function() {
  428. console.log("steps ", this._internal_step_counter)
  429. console.log(this);
  430. }
  431. var t = new mo()
  432. .addVariabelSet("Nationality", [ "Dane","Norwegian", "Swede", "Englishman", "German"])
  433. .addVariabelSet("Color", ["Red", "White", "Yellow", "Blue","Green"])
  434. .addVariabelSet("Smokes", ["Prince", "Blend", "Dunhill", "BlueMasters", "PallMall"])
  435. .addVariabelSet("Drinks", ["Water", "Bier", "Milk", "Tea", "Coffee"])
  436. .addVariabelSet("Animals", ["Dogs", "Birds", "Cats", "Horses", "Fish"])
  437. .addVariableTable("House", [0, 1, 2, 3, 4])
  438. .addFunction("Neighbor", function(arg) {
  439. var prop1 = Object.keys(arg)[0];
  440. var prop2 = Object.keys(arg[Object.keys(arg)[1]])[0]
  441. var val1 = arg[prop1];
  442. var val2 = arg["Neighbor"][prop2];
  443. var propid1 = Object.keys(this.variabler).indexOf(prop1)
  444. var propid2 = Object.keys(this.variabler).indexOf(prop2)
  445. var valid1 = (this.variabler[prop1]).indexOf(val1)
  446. var valid2 = (this.variabler[prop2]).indexOf(val2)
  447. return ["checkBoth", propid1, propid2, valid1, valid2, [prop1, val1, "Besides", prop2, val2].join(" ")]
  448. })
  449. .addFunction("Neighbor_Before", function(arg) {
  450. var prop1 = Object.keys(arg)[0];
  451. var prop2 = Object.keys(arg[Object.keys(arg)[1]])[0]
  452. var val1 = arg[prop1];
  453. var val2 = arg["Neighbor_Before"][prop2];
  454. var propid1 = Object.keys(this.variabler).indexOf(prop1)
  455. var propid2 = Object.keys(this.variabler).indexOf(prop2)
  456. var valid1 = (this.variabler[prop1]).indexOf(val1)
  457. var valid2 = (this.variabler[prop2]).indexOf(val2)
  458. return ["checkLeft", propid1, propid2, valid1, valid2, [prop1, val1, "Before", prop2, val2].join(" ")]
  459. })
  460. .addFunction("Neighbor_After", function() {
  461. var prop1 = Object.keys(arg)[0];
  462. var prop2 = Object.keys(arg[Object.keys(arg)[1]])[0]
  463. var val1 = arg[prop1];
  464. var val2 = arg["Neighbor_After"][prop2];
  465. var propid1 = Object.keys(this.variabler).indexOf(prop1)
  466. var propid2 = Object.keys(this.variabler).indexOf(prop2)
  467. var valid1 = (this.variabler[prop1]).indexOf(val1)
  468. var valid2 = (this.variabler[prop2]).indexOf(val2)
  469. return ["checkRight", propid1, propid2, valid1, valid2, [prop1, val1, "After", prop2, val2].join(" ")]
  470. })
  471. .addFunction("House", function(arg) {
  472. var prop1 = Object.keys(arg)[0];
  473. var prop2 = prop1
  474. var propid1 = Object.keys(this.variabler).indexOf(prop1)
  475. var val1 = arg[prop1];
  476. var val2 = arg["House"];
  477. var valid1 = (this.variabler[prop1]).indexOf(val1)
  478. return ['checkn', propid1, propid1, valid1, val2, [prop1, val1, "House", val2].join(" ")]
  479. })
  480. .addClause({
  481. "Nationality": "Norwegian",
  482. "House": 0
  483. })
  484. .addClause({
  485. "Drinks": "Milk",
  486. "House": 2
  487. })
  488. .addClause({
  489. "Nationality": "Norwegian",
  490. "Neighbor": {
  491. "Color": "Blue"
  492. }
  493. })
  494. .addClause({
  495. "Nationality": "Englishman",
  496. "Color": "Red"
  497. })
  498. .addClause({
  499. "Smokes": "Blend",
  500. "Neighbor": {
  501. "Drinks": "Water"
  502. }
  503. })
  504. .addClause({
  505. "Nationality": "Swede",
  506. "Animals": "Dogs"
  507. })
  508. .addClause({
  509. "Nationality": "Dane",
  510. "Drinks": "Tea"
  511. })
  512. .addClause({
  513. "Color": "Green",
  514. "Neighbor_Before": {
  515. "Color": "White"
  516. }
  517. })
  518. .addClause({
  519. "Color": "Green",
  520. "Drinks": "Coffee"
  521. })
  522. .addClause({
  523. "Smokes": "PallMall",
  524. "Animals": "Birds"
  525. })
  526. .addClause({
  527. "Color": "Yellow",
  528. "Smokes": "Dunhill"
  529. })
  530. .addClause({
  531. "Nationality": "German",
  532. "Smokes": "Prince"
  533. })
  534. .addClause({
  535. "Smokes": "Blend",
  536. "Neighbor": {
  537. "Animals": "Cats"
  538. }
  539. })
  540. .addClause({
  541. "Animals": "Horses",
  542. "Neighbor": {
  543. "Smokes": "Dunhill"
  544. }
  545. })
  546. .addClause({
  547. "Smokes": "BlueMasters",
  548. "Drinks": "Bier"
  549. })
  550. /* .addClause("$House('Nationality','Norwegian')","eq","$House().first")
  551. .addClause("$House('Drinks','Milk')","eq","$House().mid")
  552. .addClause("$House('Nationality','Englishman')","eq","$House('Color','Red')")
  553. .addClause("Math.abs($House('Smokes','Blend') - $House('Drinks','Water'))===1")
  554. */
  555. /*.addClause(0,"Norwegian",-1,-1,-1,-1)
  556. .addClause(2,-1,-1,-1,"Milk",-1)
  557. .addClause(-1,"Englishman","Red",-1,-1,-1,-1)
  558. .addClause(-1,"N Norwegian","Blue",-1,-1,-1,-1)
  559. .addClause("Math.abs($House('Nationality','Norwegian') - $House('Color','Blue'))===1")
  560. .addClause("Math.abs($House('Smokes','Blend') - $House('Drinks','Water'))===1")
  561. .addClause("$House('Nationality','Swede')===$House('Animals','Dogs')")
  562. .addClause("$House('Nationality','Dane')===$House('Drinks','Tea')")
  563. .addClause("($House('Color','Green')+1)===$House('Color','White')")
  564. .addClause("$House('Color','Green')===$House('Drinks','Coffee')")
  565. .addClause("$House('Smokes','PallMall')===$House('Animals','Birds')")
  566. .addClause("$House('Color','Yellow')===$House('Smokes','Dunhill')")
  567. .addClause("Math.abs($House('Smokes','Blend')-$House('Animals','Cats'))===1")
  568. .addClause("$House('Smokes','BlueMasters')===$House('Drinks','Bier')")
  569. //.addClause("Math.abs($House('Animals','Horses')-$House('Smokes','Dunhill'))===1")
  570. //.addClause("$House('Nationality','German')===$House('Smokes','Prince')")
  571. */
  572. /*
  573. The Englishman lives in the red house.<br>
  574. The Swede keeps dogs.<br>
  575. The Dane drinks tea.<br>
  576. The green house is just to the left of the white one.<br>
  577. The owner of the green house drinks coffee.<br>
  578. The Pall Mall smoker keeps birds.<br>
  579. The owner of the yellow house smokes Dunhills.<br>
  580. The man in the center house drinks milk.<br>
  581. The Norwegian lives in the first house.<br>
  582. The Blend smoker has a neighbor who keeps cats.<br>
  583. The man who smokes Blue Masters drinks bier.<br>
  584. The man who keeps horses lives next to the Dunhill smoker.<br>
  585. The German smokes Prince.<br>
  586. The Norwegian lives next to the blue house.<br>
  587. The Blend smoker has a neighbor who drinks water.<br>
  588. */
  589. //console.log(t.randoma("House"));
  590. //t.stats();
  591. t.on("status", function(per, found) {
  592. console.log("PER", per, found);
  593. })
  594. var result = t.solve();
  595. console.log(t.printit(result));
  596. /*
  597. var Colors = ["Red", "White", "Yellow", "Blue", "Green"],
  598. Nationality = ["Norwegian", "Dane", "Swede", "Englishman", "German"],
  599. Cigarettes = ["Prince", "Blend", "Dunhill", "Blue Masters", "Pall Mall"],
  600. Drinks = ["Water", "Bier", "Milk", "Tea", "Coffee"],
  601. Animals = ["Dogs", "Birds", "Cat", "Horses", "Fish"];*/