From 0d7ab05f05c3a16df0b3c08053b34637eeb9dc08 Mon Sep 17 00:00:00 2001 From: Xiaoou WANG <16024291+xiaoouwang@users.noreply.github.com> Date: Thu, 3 Nov 2022 16:32:49 +0100 Subject: [PATCH] Update birthday.py starting from i to avoir comparing the same pair a second time --- chapter_02/birthday.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_02/birthday.py b/chapter_02/birthday.py index 796c848..dc2f4f1 100644 --- a/chapter_02/birthday.py +++ b/chapter_02/birthday.py @@ -31,7 +31,7 @@ match = 0 b = np.random.randint(0,364,m) for i in range(m): - for j in range(m): + for j in range(i, m): # starting from i to avoir comparing the same pair a second time if (i != j) and (b[i] == b[j]): match += 1 if (match != 0):