From 825ad379983681769e83cc7fe1949c5922062799 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 24 Dec 2021 15:33:09 +0100 Subject: Changed default behavior of -s --- doc/nissy.1 | 16 +++++++++++++++- nissy | Bin 321192 -> 321192 bytes nissy-2.0beta9.tar.gz | Bin 59974 -> 60731 bytes src/commands.c | 10 ++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/nissy.1 b/doc/nissy.1 index 8f92b01..add0da6 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 @@ -111,7 +111,21 @@ Plain style: do not print the number of moves. .It Fl s Ar n Try to find .Ar n -solutions. +solutions. By default and unless the +.Fl M +or +.Fl o +options are used, at most one solution is printed. +If at least one of +.Fl M +and +.Fl o +is used, all the solutions found within the given bounds are printed. +The option +.Fl s +overwrites these default behaviors and at most +.Ar n +solutions are printed, still satisfiyng the other constraints. . .It Fl t Ar n Use diff --git a/nissy b/nissy index 0ea0bc4..8e80407 100755 Binary files a/nissy and b/nissy differ diff --git a/nissy-2.0beta9.tar.gz b/nissy-2.0beta9.tar.gz index 097acca..85ed2f0 100644 Binary files a/nissy-2.0beta9.tar.gz and b/nissy-2.0beta9.tar.gz differ diff --git a/src/commands.c b/src/commands.c index 193ee97..6afd5cd 100644 --- a/src/commands.c +++ b/src/commands.c @@ -115,6 +115,7 @@ CommandArgs * solve_parse_args(int c, char **v) { int i; + bool infinitesols, fixedmsols; long val; CommandArgs *a = new_args(); @@ -130,6 +131,9 @@ solve_parse_args(int c, char **v) a->opts->print_number = true; a->opts->count_only = false; + fixedmsols = false; + infinitesols = false; + for (i = 0; i < c; i++) { if (!strcmp(v[i], "-m") && i+1 < c) { val = strtol(v[++i], NULL, 10); @@ -149,6 +153,7 @@ solve_parse_args(int c, char **v) return a; } a->opts->max_moves = val; + infinitesols = true; } else if (!strcmp(v[i], "-t") && i+1 < c) { val = strtol(v[++i], NULL, 10); if (val < 1 || val > 64) { @@ -166,8 +171,10 @@ solve_parse_args(int c, char **v) return a; } a->opts->max_solutions = val; + fixedmsols = true; } else if (!strcmp(v[i], "-o")) { a->opts->optimal_only = true; + infinitesols = true; } else if (!strcmp(v[i], "-n")) { a->opts->can_niss = true; } else if (!strcmp(v[i], "-v")) { @@ -183,6 +190,9 @@ solve_parse_args(int c, char **v) } } + if (infinitesols && !fixedmsols) + a->opts->max_solutions = 1000000; /* 1M = +infty */ + a->success = read_scramble(c-i, &v[i], a); return a; } -- cgit v1.3