summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-01-10 20:32:01 +0100
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-01-10 20:32:01 +0100
commitb3682cb5f98288e81ac6e95b8885263866798229 (patch)
tree23c75fd126eb8ac8b125db0f4857a0b9731015a8
parent3b24dc9b961c238a58083ba1e68dfd5f21915e7f (diff)
Got the last record from the existing solution.HEADmaster
-rw-r--r--src/solve.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/solve.c b/src/solve.c
index 9ddbb03..4daa81d 100644
--- a/src/solve.c
+++ b/src/solve.c
@@ -3,10 +3,24 @@
/* Basically bruteforce. */
+static long getrecord(input_t *inp, const char *solpath)
+{
+ output_t *outp = NULL;
+ long record = 0;
+
+ if (!parse_output(&outp, inp, solpath)) {
+ if (count_lamps_turned_on(inp, outp, &record))
+ record = 0;
+ free_output(outp);
+ }
+
+ return (record);
+}
+
int solve_illumination(input_t *inp, const char *solpath)
{
long swid = 0, swmax = get_switch_count(inp) - 1;
- long count, record = 0;
+ long count, record = getrecord(inp, solpath);
output_t *outp = NULL;
if (make_output(&outp, inp))