-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday6.ps1
More file actions
35 lines (33 loc) · 709 Bytes
/
day6.ps1
File metadata and controls
35 lines (33 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
. .\day6input.ps1
$source = $source.Split([Environment]::NewLine)
$total = 0
$iter = $source.GetEnumerator()
while($iter.MoveNext()){
$dict = @{}
$count= 0
while( -not [string]::IsNullOrEmpty( $iter.Current ) )
{
$count=$count+1
foreach($c in $iter.Current.ToCharArray())
{
if($dict.ContainsKey($c))
{
$dict[$c] = $dict[$c] +1
}
else{
$dict[$c] = 1
}
}
$iter.MoveNext()
}
$result =0
foreach( $key in $dict.Keys )
{
if($dict[$key] -eq $count)
{
$result = $result +1
}
}
$total += $result
}
$total