Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
brackets test 2
#perl 5.22 my $str=""; for my $length (0..(rand()*10+4)){ $str.=("(",")")[rand()*2]; } print balance( $str); sub balance{ my $level=0; my $pointer =0; foreach (split "",shift){ $level+=($_ eq "(")?1:-1; last if $level<0; } return 1+$level/abs ($level); }
run
|
edit
|
history
|
help
0
Compare Versions
Riyali-101738
Sortttttttt
Array_with_pop_function
Price_supriya
Lol
Jeffy John Sam (101724)
Lieta 101733
size_of_array
Interpolation_with_case_sensitive