Created
January 27, 2020 23:54
-
-
Save kulicuu/93e6965cca4ef93a43c8be90b88224d4 to your computer and use it in GitHub Desktop.
Maximal subset generated from constraint
This file contains hidden or 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
| c = console.log.bind console | |
| make_vertex = ({ k, addr, accd_set, remainder }) -> | |
| neighbors = {} | |
| remainder.reduce (acc, val, idx) -> | |
| # c val, idx | |
| # ((val + addr) % k) is 0 | |
| x99 = accd_set.reduce (acc2, val2, idx2) -> | |
| if ((val + val2) % k) is 0 | |
| acc2 = false | |
| acc2 | |
| , true | |
| # c x99, 'x99' | |
| if x99 is true | |
| rem = [].concat remainder | |
| rem.splice idx, 1 | |
| neighbors["#{val}"] = make_vertex | |
| k: k | |
| addr: val | |
| accd_set: [].concat(accd_set, [val]) | |
| remainder: rem | |
| , {} | |
| { addr, accd_set, remainder, neighbors } | |
| graph_the_set = (k, s) -> | |
| s.reduce (acc, val, idx) -> | |
| s1 = [].concat s | |
| s1.splice idx, 1 | |
| acc["#{val}"] = make_vertex | |
| k: k | |
| addr: val | |
| accd_set: [val] | |
| remainder: s1 | |
| acc | |
| , {} | |
| k_33 = 7 | |
| rayy_33 = [278, 576, 496, 727, 410, 124, 338, 149, 209, 702, 282, 718, 771, 575, 436] | |
| x55 = graph_the_set k_33, rayy_33 | |
| # c x55 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One important component to a solution is a technique to convert a set (any ordering of a set in an array or vector) into a unique string representation. If this exists on the graph already it wouldn't be computed. Actually in this way wouldn't need a graph at all, simply a list of these encodings of the sets generated that satisfy the constraint. The size is embedded in the encoded property names, which is all that is needed as a value.