---
title: "Discussion on \"Advent of Code day 4\" | Hashnode"
description: "Discussion on \"Advent of Code day 4\". In day 4 we count valid passports, i.e. passports that have all the required fields.In solving it, we have to decide how complex to be.  The first part doesn’t require much complexity -- we could just search each passport for  ‘byr:’,  ‘iyr:’, etc.  ..."
url: "https://hashnode.com/posts/advent-of-code-day-4/5fcbb1f32e4db7780e483a06"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Advent of Code day 4](https://pyetc.hashnode.dev/advent-of-code-day-4?utm_source=hashnode&utm_medium=feed)

In day 4 we count valid passports, i.e. passports that have all the required fields.In solving it, we have to decide how complex to be. The first part doesn’t require much complexity -- we could just search each passport for ‘byr:’, ‘iyr:’, etc. ...

Dec 5, 2020 · 7 min read · pyetc.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#coding-challenge](https://hashnode.com/tag/coding-challenge)
-   [#regex](https://hashnode.com/tag/regex)

## Written by

[Alysha Reinard](https://hashnode.com/@pyetc)

@pyetc · Morges, Switzerland

  
[View profile](https://hashnode.com/@pyetc)

Python expert, learning new tech, new languages, new techniques

## Responses 1

Markdown supported · ⌘↵ to post

[Eddie Smith](https://hashnode.com/@seriousdude)

[Dec 6, 2020](https://hashnode.com/posts/advent-of-code-day-4/5fcbb1f32e4db7780e483a06/comment/5fcc2132ef5f84019de79608)

Excellent work. I thought this problem demanded more legwork than other days. And those line breaks! (I used Vim, to remove single newlines and reduce doubles to a single).

For the "chain of ands" problem, I tried something like:

```
def check_validity(passport)
     keys=["byr:","iyr:","eyr:","hgt:","hcl:","ecl:","pid:"]
     for test in keys:
         if test in passport:
              pass
         else:
              return False
     return True
```
