From 0c5530e545e1d1c2401b145ffdc173308ef67be3 Mon Sep 17 00:00:00 2001 From: Brady James Garvin <bgarvin@cse.unl.edu> Date: Tue, 28 Feb 2017 14:38:44 -0600 Subject: [PATCH] Provided solution to evaluate. --- nim.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nim.py b/nim.py index 006f27b..81bba44 100644 --- a/nim.py +++ b/nim.py @@ -68,7 +68,13 @@ def evaluate(heap_sizes): >>> evaluate([9, 12, 3, 7]) <Evaluation.LOSS: 'LOSS'> """ - return Evaluation.LOSS # Stub + if len(heap_sizes) > 1: + single_heap = convert_to_single_heap_using_builtin(heap_sizes[0], + heap_sizes[1]) + return evaluate([single_heap] + heap_sizes[2:]) + else: + return Evaluation.WIN if len(heap_sizes) == 0 or heap_sizes[0] == 0 \ + else Evaluation.LOSS def make_computer_move(position): -- GitLab