#!/usr/bin/env tclsh proc check {} { global field valid foreach f {byr iyr eyr hgt hcl ecl pid} { if {! [info exists field($f)]} return } incr valid } set valid 0 while {[gets stdin line] >= 0} { if {$line eq ""} { check array unset field continue } foreach f [split $line { }] { set field([string range $f 0 2]) 1 } } check puts $valid