From 3d6c73c33276ecedba86cb871b4b5a089571629b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 18 Oct 2024 12:21:51 +0200 Subject: New interface function nissy_countmoves --- shell/shell.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/shell.c b/shell/shell.c index 24ae243..42b3ccd 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -67,6 +67,7 @@ static int64_t datasize_exec(args_t *); static int64_t gendata_exec(args_t *); static int64_t solve_exec(args_t *); static int64_t solve_scramble_exec(args_t *); +static int64_t countmoves_exec(args_t *); static int64_t help_exec(args_t *); static int parse_args(int, char **, args_t *); @@ -202,12 +203,19 @@ struct { "solve_scramble", "solve_scramble " FLAG_SOLVER " SOLVER" "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " - FLAG_CUBE " CUBE", + FLAG_MOVES " MOVES", "Solve the given SCRAMBLE using SOLVER, " "using at least n and at most N moves. " INFO_MOVESFORMAT, solve_scramble_exec ), + COMMAND( + "countmoves", + "countmoves " FLAG_MOVES " MOVES", + "Count the given MOVES in HTM. " + INFO_MOVESFORMAT, + countmoves_exec + ), COMMAND( "help", "help [" FLAG_COMMAND " COMMAND]", @@ -487,6 +495,19 @@ solve_scramble_exec(args_t *args) return solve_exec(args); } +static int64_t +countmoves_exec(args_t *args) +{ + long long count; + + count = nissy_countmoves(args->str_moves); + + if (count >= 0) + printf("%lld\n", count); + + return count >= 0 ? 0 : count; +} + static int64_t help_exec(args_t *args) { -- cgit v1.3