Anonymous user
Balanced brackets: Difference between revisions
Replaced PowerShell with simpler example
No edit summary |
(Replaced PowerShell with simpler example) |
||
Line 4,018:
=={{header|PowerShell}}==
{{works with|PowerShell|2}}
<lang PowerShell>
function
$Open = 0
ForEach ( $Character in [char[]]$String )
)▼
# If Open drops below zero (close
#
If ( $Open -lt
}
$Status = ( "NOT
return
</lang>
<lang PowerShell>
# Test
$Strings = @( "" )
$Strings += 1..5 | ForEach { ( [char[]]("[]" * $_) | Get-Random -Count ( $_ * 2 ) ) -join "" }
ForEach ( $String in $Strings )
$String.PadRight( 12, " " ) + (Get-BalanceStatus $String)
▲ }
</lang>
{{out}}
<pre>
OK
[] OK
]][[ NOT OK
]][][[ NOT OK
][[[]][][]
</pre>
|