From e6354cf0977898727bf573259ab3e82cfd882c8d Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 20 Aug 2022 22:54:25 -0500 Subject: [PATCH] elaborated on an alternative syntax in day 2 --- day2/day2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/day2/day2.py b/day2/day2.py index 8e1c233..d4b1197 100755 --- a/day2/day2.py +++ b/day2/day2.py @@ -21,7 +21,9 @@ def parse(puzzle_input: str): def part1(data): """Solve part 1""" test = lambda x: x.first<=x.password.count(x.letter)<=x.second - return sum(1 for p in data if test(p)) + # these two lines are equivilant. + # return sum(1 for p in data if test(p)) + return len([1 for p in data if test(p)]) def test_password(passwordSpec: PasswordSpec): if passwordSpec.password[passwordSpec.first-1]==passwordSpec.letter: