Created
April 22, 2020 16:08
-
-
Save spirinvladimir/bdd54c98274cde465ea1ec62285a1306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = [ | |
'Monday', | |
'Tuesday', | |
'Wednesday', | |
'Thursday', | |
'Friday', | |
'Saturday', | |
'Sunday' | |
] | |
const N = [].concat( | |
new Array(100).fill(0).map((_, i) => i), | |
new Array(100).fill(0).map((_, i) => -i), | |
) | |
const D = Object.keys(m.reduce( | |
(h, w) => { | |
w.split('').map(c => h[c] = 1) | |
return h | |
}, {})) | |
const bfs = [ | |
(day, a, b, c, x, y, r) => r == (a * day.indexOf(x) + b * day.indexOf(y) + c) % 7, | |
(day, a, b, c, x, y, r) => r == (a * day.indexOf(x) % b * day.indexOf(y) + c) % 7, | |
(day, a, b, c, x, y, r) => r == ((a * day.indexOf(x) * day.indexOf(y) % b) + c) % 7, | |
(day, a, b, c, x, y, r) => r == (((a * day.indexOf(x) + b) % day.indexOf(y)) + c) % 7, | |
(day, a, b, c, x, y, r) => r == ((a * day.indexOf(x) + b) % day.indexOf(y)) % 7, | |
(day, a, b, c, x, y, r) => r == (a * day.indexOf(x) * day.indexOf(y) + b) % 7, | |
(day, a, b, c, x, y, r) => r == (a * day.indexOf(y) % b * day.length + c) % 7, | |
(day, a, b, c, x, y, r) => r == ((a * day.indexOf(y) + b) % day.length) % 7, | |
(day, a, b, c, x, y, r) => r == (a * day.length + b * day.indexOf(y) + c) % 7, | |
(day, a, b, c, x, y, r) => r == (a * day.length % b * day.indexOf(y) + c) % 7, | |
(day, a, b, c, x, y, r) => r == ((a * day.length * day.indexOf(y) % b) + c) % 7, | |
(day, a, b, c, x, y, r) => r == (((a * day.length + b) % day.indexOf(y)) + c) % 7, | |
(day, a, b, c, x, y, r) => r == (((a * day.length + b) % day.indexOf(y)) % c) % 7, | |
(day, a, b, c, x, y, r) => r == ((a * day.length * day.indexOf(y) + b) % c) % 7 | |
] | |
N.forEach(a => | |
N.forEach(b => | |
N.forEach(c => | |
D.forEach(x => | |
D.forEach(y => { | |
var oks = bfs.map(() => true) | |
for (var i = 0;i < m.length;i++) { | |
oks = bfs.map((bf, n) => | |
oks[n] && bf(m[i], a, b, c, x, y, i) | |
) | |
} | |
oks.map((ok, i) => ok && console.log(bfs[i], a, b, c, x, y)) | |
}) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment