Skip to content

Commit

Permalink
feat: finally support near numbers in hashi (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
T0nyX1ang committed Apr 24, 2024
1 parent 07f9208 commit 61e89eb
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
7 changes: 1 addition & 6 deletions solver/core/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ def store_solutions(self, model: Model):
r, c = data
formatted[rcd_to_elt(int(r), int(c))] = _type.replace("color", "")
else: # debug only
if len(data) >= 3:
r, c = data[0], data[1]
print(r, c, data[2:])
formatted[rcd_to_elt(int(r), int(c))] = "".join(data[2:])
else:
print(data)
print(data)

self.solutions.append(formatted)

Expand Down
15 changes: 7 additions & 8 deletions static/noq/elves.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ const CLIPBOARD_SYMBOLS = {

tree: "🌲",
tent: "⛺",

// 'white_circle_u':'Ȯ',
// 'white_circle_r':'⟥',
// 'white_circle_d':'Ọ',
// 'white_circle_l':'⟤', TODO find better symbols for these if possible; and also make hotaru copy-to-clipboard actually work
// (the issue is that generate_copy_td doesn't work well with DirectSum. actually DirectSum just sorta sucks in general imo)
};

function add_json_objects(d1, d2) {
Expand Down Expand Up @@ -223,7 +217,7 @@ class Elf {
load_solution(str) {
if (COLORS.includes(str)) {
this.solution_elt.style.backgroundColor = str;
if (str == "black") this.solution_elt.style.color = "gray";
if (str === "black") this.solution_elt.style.color = "gray";
this.solution_elt.innerHTML = this.puzzle_elt.innerHTML; // retain the text
} else if (/^[0-9]+$/.test(str)) this.solution_elt.innerHTML = str;
else if (/^.+\.png$/.test(str)) {
Expand All @@ -235,6 +229,11 @@ class Elf {
}
this.solution_elt.style.backgroundImage = image_urls.join(",");
this.solution_image_str = image_strs.sort().join(",");
if (pt === "hashi" && /^[0-9]+$/.test(this.puzzle_elt.innerHTML)) {
// special case for Hashi solution display
this.solution_elt.style.clipPath =
"polygon(0% 0%, 0% 100%, 15% 100%, 15% 15%, 85% 15%, 85% 85%, 15% 85%, 15% 100%, 100% 100%, 100% 0%)";
}
} else this.solution_elt.innerHTML = str;
}
reset() {
Expand Down Expand Up @@ -1612,7 +1611,7 @@ let elf_types = {
}
),
"compress",
"center_dot" // TODO fix load_example for arrays
"center_dot"
),
kakuro: KakuroElf,
kurotto: DirectSum(
Expand Down
Binary file modified static/noq/images/d_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/noq/images/l_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/noq/images/r_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/noq/images/u_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 61e89eb

Please sign in to comment.