From 4ba0faeb5ff6aaf9a29299bebeb6fd7dc8f0b4e6 Mon Sep 17 00:00:00 2001 From: Michael Manring Date: Sat, 25 Jun 2022 01:02:19 +0700 Subject: add more test case for ch-1 where m is a square and fix bug --- challenge-142/pokgopun/go/dldcount/dldcount.go | 3 +++ challenge-142/pokgopun/go/dldcount/dldcount_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/challenge-142/pokgopun/go/dldcount/dldcount.go b/challenge-142/pokgopun/go/dldcount/dldcount.go index 2a1088aac2..e4ee7467f1 100644 --- a/challenge-142/pokgopun/go/dldcount/dldcount.go +++ b/challenge-142/pokgopun/go/dldcount/dldcount.go @@ -15,6 +15,9 @@ func Count(m, n uint) (c uint) { if v%10 == n { c++ } + if d == m/d { + break + } } } } diff --git a/challenge-142/pokgopun/go/dldcount/dldcount_test.go b/challenge-142/pokgopun/go/dldcount/dldcount_test.go index fcab676796..8189b1127c 100644 --- a/challenge-142/pokgopun/go/dldcount/dldcount_test.go +++ b/challenge-142/pokgopun/go/dldcount/dldcount_test.go @@ -12,6 +12,7 @@ func TestDldCount(t *testing.T) { {30, 5, 2}, {30, 0, 1}, {30, 6, 1}, + {64, 8, 1}, } for _, d := range data { res := Count(d.m, d.n) -- cgit