summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))