#!/usr/bin/env tclsh8.6 set total 0 while {[gets stdin line] >= 0} { set line [lindex [split $line :] 1] lassign [split $line |] win has array unset winhash foreach n $win {set winhash($n) 1} set score 0 foreach n $has { if {[info exists winhash($n)]} {incr score} } if {$score > 0} {incr total [expr {2**($score-1)}]} } puts $total