Last active
February 8, 2022 15:27
-
-
Save jexp/b1882301adb95a8015d6c29d3e24e341 to your computer and use it in GitHub Desktop.
Revisions
-
jexp revised this gist
Feb 2, 2022 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -47,4 +47,17 @@ return w.name; ├────────┤ │"crash" │ └────────┘ */ // more detailed with exclusions etc. match (c1:CharAtPos {idx:0, char:'c'}), // correct (c2:CharAtPos {idx:1, char:'a'}), // wrong pos (c3:CharAtPos {char:'l'}), // incorrect (c4:CharAtPos {char:'i'}), // incorrect (c5:CharAtPos {idx:4, char:'h'}), // correct (c:CharAtPos {char:'a'}) match (w:Word)-[h1:HAS]->(c1), (w)-[h2:HAS]->(c5), (w)-[h3:HAS]->(c) WHERE not exists { (w)-[:HAS]->(c2) } and not exists { (w)-[:HAS]->(c3) } and not exists { (w)-[:HAS]->(c4) } return *; -
jexp revised this gist
Feb 2, 2022 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ * explain two models * loading * post-processing * look at char frequencies * recommend starting words (based on top frequencies) * rarest words * solve word * visualize solver * implement wordle -> split input + match -
jexp revised this gist
Feb 1, 2022 . 1 changed file with 34 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ // Alternative model // index in rel-type MATCH (w:Word) WITH w, split(w.name,"") AS chars MERGE (c0:Char {char:chars[0]}) MERGE (w)-[:POS0]->(c0) MERGE (c1:Char {char:chars[1]}) MERGE (w)-[:POS1]->(c1) MERGE (c2:Char {char:chars[2]}) MERGE (w)-[:POS2]->(c2) MERGE (c3:Char {char:chars[3]}) MERGE (w)-[:POS3]->(c3) MERGE (c4:Char {char:chars[4]}) MERGE (w)-[:POS4]->(c4); MATCH p=(n:Word {name:"crash"})--(:Char) RETURN p LIMIT 25; MATCH (c:Char {char:'c'}), (h:Char {char:'h'}), (a:Char {char:'a'}) MATCH (wordle:Word)-[:POS0]->(c), (wordle)-[:POS4]->(h), (wordle)-->(a) RETURN wordle.name; MATCH (c:Char {char:'c'}), (h:Char {char:'h'}), (a:Char {char:'a'}) MATCH (wordle:Word)-[p0:POS0]->(c), (wordle)-[p4:POS4]->(h), (wordle)-[px]->(a) RETURN *; -
jexp revised this gist
Feb 1, 2022 . 1 changed file with 24 additions and 21 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,34 @@ CREATE CONSTRAINT word_name IF NOT EXISTS ON (w:Word) ASSERT w.name IS UNIQUE; CREATE CONSTRAINT cap_idx_char IF NOT EXISTS FOR (cap:CharAtPos) REQUIRE (cap.idx, cap.char) IS NODE KEY; LOAD CSV FROM "https://gist.githubusercontent.com/jexp/b1882301adb95a8015d6c29d3e24e341/raw/6fe6ac31b9ed46900451e17b5215e9088ec09a6e/wordle.csv" as row MERGE (w:Word {name:row[0]}); :auto MATCH (w:Word) CALL { WITH w WITH w, split(w.name,"") AS chars MERGE (start:CharAtPos {idx:0, char:chars[0]}) MERGE (w)-[:STARTS]->(start) MERGE (w)-[:HAS]->(start) WITH * UNWIND range(1,size(chars)-1) AS idx MERGE (next:CharAtPos {idx:idx, char:chars[idx]}) MERGE (w)-[:HAS]->(next) WITH * MATCH (prev:CharAtPos {idx:idx-1, char:chars[idx-1]}) MERGE (prev)-[:NEXT]->(next) } IN TRANSACTIONS OF 1000 ROWS; MATCH p=(n:Word {name:"crash"})--() RETURN p LIMIT 25; MATCH (c1:CharAtPos {idx:0, char:'c'}), (c5:CharAtPos {idx:4, char:'h'}), (c:CharAtPos {char:'a'}) match (w:Word)-[:HAS]->(c1), (w)-[:HAS]->(c5), (w)-[:HAS]->(c) return w.name; /* -
jexp revised this gist
Feb 1, 2022 . 1 changed file with 19 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,4 +26,22 @@ MATCH p=(n:Word {name:"crash"})--() RETURN p LIMIT 25; match (c1:CharAtPos {idx:0, char:'c'}), (c5:CharAtPos {idx:4, char:'h'}) match (c:CharAtPos {char:'a'}) match (w:Word)-[:HAS]->(c1),(w)-[:HAS]->(c5),(w)-[:HAS]->(c) return w.name; /* ╒════════╕ │"w.name"│ ╞════════╡ │"clach" │ ├────────┤ │"clash" │ ├────────┤ │"caneh" │ ├────────┤ │"coach" │ ├────────┤ │"catch" │ ├────────┤ │"crash" │ └────────┘ */ -
jexp revised this gist
Feb 1, 2022 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,4 +21,9 @@ match (prev:CharAtPos {idx:idx-1, char:chars[idx-1]}) merge (prev)-[:NEXT]->(next) } in transactions of 1000 rows; MATCH p=(n:Word {name:"crash"})--() RETURN p LIMIT 25; match (c1:CharAtPos {idx:0, char:'c'}), (c5:CharAtPos {idx:4, char:'h'}) match (c:CharAtPos {char:'a'}) match (w:Word)-[:HAS]->(c1),(w)-[:HAS]->(c5),(w)-[:HAS]->(c) return w.name -
jexp revised this gist
Feb 1, 2022 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ create constraint on (w:Word) assert w.name is unique; // create constraint on (c:CharAtPos) assert node key (idx, char); load csv from "https://gist.githubusercontent.com/jexp/b1882301adb95a8015d6c29d3e24e341/raw/6fe6ac31b9ed46900451e17b5215e9088ec09a6e/wordle.csv" as row merge (w:Word {name:row[0]}); match (w:Word) call { with w with w, split(w.name,"") as chars merge (start:CharAtPos {idx:0, char:chars[0]}) merge (w)-[:STARTS]->(start) merge (w)-[:HAS]->(start) with * unwind range(1,size(chars)-1) as idx merge (next:CharAtPos {idx:idx, char:chars[idx]}) merge (w)-[:HAS]->(next) with * match (prev:CharAtPos {idx:idx-1, char:chars[idx-1]}) merge (prev)-[:NEXT]->(next) } in transactions of 1000 rows; MATCH p=(n:Word {name:"crash"})--() RETURN p LIMIT 25; -
jexp created this gist
Feb 1, 2022 .There are no files selected for viewing