6 deleted 124 characters in body
source | link

Brain-Flak, 1101, 1085, 1085981 bytes

{({}<>)(<>())(<>{}<>)<(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}{
{}>{}(<{}>)(((()))<>)(<><{}><>)}{}<(({ 
}))((((()()()()()){}){}){}())({}[{}]<(())>){((
 <{}{}>))}{}{{}>{}(<{}>)(((()))<>)({}[{}](<()>)){ 
{}{}(<(())>)}{}{<>{{}}<>{{}}((<()
 >))}{}(<><{}><>)}{}<(({}))(((((()()()()()){}){})){}{} 
)({}[{}]<(())>){((<{}{}>))}{}{
{}>{}(<({}>)(((())<>)>()<>)(<><{}><>)}{}<(({}))(((((()()()()()){}){})( 
)){}{})({}[{}]<(()
 )>){((<{}{}>))}{}{{}>{}(<({}>)(((())<>)>()<>)({}[{}](<()>)){{}{}(<(())>)}{}{ 
<>{{}}<>{
 {}}((<()>))}{}(<><{}><>)}{}<(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(() 
)>){((
 <{}{}>))}{}{{}>{}(<({}>)(((()()<>)>()()<>)(<><{}>)}{}<(({}))((((((()()()()()){})){}{}()
 )){}{} 
)({}[{}]<(())>){((<{}{}>))}{}{{}>{}(<({}>)(((()))()()<>)>()({}[{}](<()>)){{}{}(
 <(())>)}{}{<>{{ 
}}<>{{}}((<()>))}{}(<><{}><>)}{}<(({}))((((((()()()()()){}){}){}()))
 {}{})({}[{}]<(())> 
){((<{}{}>))}{}{{}>{}(<({}>)(((()))()()()<>)(<><{}>()(<>)}{}<(({}))(((
 (((()()()()()){}){}){}())()){} 
{})({}[{}]<(())>){((<{}{}>))}{}{{}>{}(<({}>)(((()))(
 )()()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{ 
<>{{}}<>{{}}((<()>))}{}(<><{}><>)}{}<{}>[()]){<>{{}}
<>(<()>)<>{{}}(<()>)}{}}<>([]<>)({}< 
(())>){((<{}{}>))}{}

Try it online!Try it online!

This is 1084980 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • First, we push a counter underneath the top character. We'll call it the "equals counter". This counter is initialized to 1, and as soon as the top character matches a bracket, we will set this to 0.

  • Then weWe check each character to see if it matches any bracket. If it is an opening bracket, we push a number onto the other stack according to the following mapping:

    ( = 1
    < = 2
    [ = 3
    { = 4
    
  • Then we check to see if it matches any closing bracket. If it does, we push the equivalent number onto the alternate stack, just like for opening brackets. Then, we check if the top two numbers are equal. If they are, the both get popped and the program continues as normal. If they are not, we clear both stacks (to stop the looping) and push a one onto the alternate stack. This is essentially a "break" statement.

  • After checking the 8 bracket types, we poppush the character and look atvalue of this run through the "equals counter"loop. If it's truthySince we zero out most of it, the only snippets that means none ofhave any value are the conditionals when we compare against brackets. So if any bracket is matched, so we have an invalid characterthe whole loop has a value of 1. If none of them did, the whole loop has a value of 0. In this case, we will clear both stacks and push a 10 onto the alternate stack. Again, this is like a "break" statement.

  • Removed some push pop redundancy

    Removed some push pop redundancy

  • Changed my zero counter logic

Brain-Flak, 1101, 1085 bytes

{({}<>)(<>())(<>{}<>)(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)(((()))<>)(<><{}>)}{}(({}))((((()()()()()){}){}){}())({}[{}]<(())>){((
 <{}{}>))}{}{{}{}(<{}>)(((()))<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<()
 >))}{}(<><{}>)}{}(({}))(((((()()()()()){}){})){}{})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)(((()))()<>)(<><{}>)}{}(({}))(((((()()()()()){}){})()){}{})({}[{}]<(()
 )>){((<{}{}>))}{}{{}{}(<{}>)(((()))()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{
 {}}((<()>))}{}(<><{}>)}{}(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(())>){((
 <{}{}>))}{}{{}{}(<{}>)(((()))()()<>)(<><{}>)}{}(({}))((((((()()()()()){})){}{}()
 )){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))()()<>)({}[{}](<()>)){{}{}(
 <(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}(({}))((((((()()()()()){}){}){}()))
 {}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))()()()<>)(<><{}>)}{}(({}))(((
 (((()()()()()){}){}){}())()){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))(
 )()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}{}{{{}}
<>(())<>}{}}<>([]<>)({}<(())>){((<{}{}>))}{}

Try it online!

This is 1084 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • First, we push a counter underneath the top character. We'll call it the "equals counter". This counter is initialized to 1, and as soon as the top character matches a bracket, we will set this to 0.

  • Then we check to see if it matches any bracket. If it is an opening bracket, we push a number onto the other stack according to the following mapping:

    ( = 1
    < = 2
    [ = 3
    { = 4
    
  • Then we check to see if it matches any closing bracket. If it does, we push the equivalent number onto the alternate stack, just like for opening brackets. Then, we check if the top two numbers are equal. If they are, the both get popped and the program continues as normal. If they are not, we clear both stacks (to stop the looping) and push a one onto the alternate stack. This is essentially a "break" statement.

  • After checking the 8 bracket types, we pop the character and look at the "equals counter". If it's truthy, that means none of the brackets matched, so we have an invalid character. In this case, we clear both stacks and push a 1 onto the alternate stack. Again, this is like a "break" statement.

  • Removed some push pop redundancy

Brain-Flak, 1101, 1085, 981 bytes

{(<(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}>{({}<>)(<>)}{}<(({ 
}))((((()()()()()){}){}){}())({}[{}]<(())>){((<{}{}>))}{}>{({}<>)({}[{}](<()>)){ 
{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<>)}{}<(({}))(((((()()()()()){}){})){}{} 
)({}[{}]<(())>){((<{}{}>))}{}>{<({}()<>)>()(<>)}{}<(({}))(((((()()()()()){}){})( 
)){}{})({}[{}]<(())>){((<{}{}>))}{}>{<({}()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{ 
<>{{}}<>{{}}((<()>))}{}(<>)}{}<(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(() 
)>){((<{}{}>))}{}>{<({}()()<>)>()(<>)}{}<(({}))((((((()()()()()){})){}{}())){}{} 
)({}[{}]<(())>){((<{}{}>))}{}>{<({}()()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{<>{{ 
}}<>{{}}((<()>))}{}(<>)}{}<(({}))((((((()()()()()){}){}){}())){}{})({}[{}]<(())> 
){((<{}{}>))}{}>{<({}()()()<>)>()(<>)}{}<(({}))((((((()()()()()){}){}){}())()){} 
{})({}[{}]<(())>){((<{}{}>))}{}>{<({}()()()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{ 
<>{{}}<>{{}}((<()>))}{}(<>)}{}<{}>[()]){<>{{}}(<()>)<>{{}}(<()>)}{}}<>([]<>)({}< 
(())>){((<{}{}>))}{}

Try it online!

This is 980 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • We check each character to see if it matches any bracket. If it is an opening bracket, we push a number onto the other stack according to the following mapping:

    ( = 1
    < = 2
    [ = 3
    { = 4
    
  • Then we check to see if it matches any closing bracket. If it does, we push the equivalent number onto the alternate stack, just like for opening brackets. Then, we check if the top two numbers are equal. If they are, the both get popped and the program continues as normal. If they are not, we clear both stacks (to stop the looping) and push a one onto the alternate stack. This is essentially a "break" statement.

  • After checking the 8 bracket types, we push the value of this run through the loop. Since we zero out most of it, the only snippets that have any value are the conditionals when we compare against brackets. So if any bracket is matched, the whole loop has a value of 1. If none of them did, the whole loop has a value of 0. In this case, we will clear both stacks and push a 0 onto the alternate stack. Again, this is like a "break" statement.

  • Removed some push pop redundancy

  • Changed my zero counter logic

5 added 23 characters in body
source | link

Brain-Flak, 1101 bytes (non-competing)1101, 1085 bytes

{({}<>)(<>())(<>{}<>)(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}{{
{}{}(<{}>)((()())(()<>)(<><{}>)}{}(({}))((((()()()()()){}){}){}())({}[{}]<(())>){((
<{}{}>))}{}{{}{}(<{}>)(((()))(()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<(
 ) 
>))}{}(<><{}>)}{}(({}))(((((()()()()()){}){})){}{})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)(((()))(()()<>)(<><{}>)}{}(({}))(((((()()()()()){}){})()){}{})({}[{}]<((
 ) 
)>){((<{}{}>))}{}{{}{}(<{}>)((()())(()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<
><>{ 
{}}((<()>))}{}(<><{}>)}{}(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(())>){(
 ( 
<{}{}>))}{}{{}{}(<{}>)((()())(()()()<>)(<><{}>)}{}(({}))((((((()()()()()){})){}{}
 () 
)){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()())(()()()<>)({}[{}](<()>)){{}
 {}( 
<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}(({}))((((((()()()()()){}){}){}()
 )) 
{}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()())(()()()()<>)(<><{}>)}{}(({}))
 ((( 
(((()()()()()){}){}){}())()){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()())
(()( 
)()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}{}{{
 {}} 
<>(())<>}{}}<>([]<>)({}<(())>){((<{}{}>))}{}

Try it online!Try it online!

This is 11001084 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.

  • Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program


revisions

  • Removed some push pop redundancy

Brain-Flak, 1101 bytes (non-competing)

{({}<>)(<>())(<>{}<>)(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}{{
}{}(<{}>)((()))(()<>)(<><{}>)}{}(({}))((((()()()()()){}){}){}())({}[{}]<(())>){((
<{}{}>))}{}{{}{}(<{}>)((()))(()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<(
 )>))}{}(<><{}>)}{}(({}))(((((()()()()()){}){})){}{})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)((()))(()()<>)(<><{}>)}{}(({}))(((((()()()()()){}){})()){}{})({}[{}]<((
 ))>){((<{}{}>))}{}{{}{}(<{}>)((()))(()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<
>{{}}((<()>))}{}(<><{}>)}{}(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(())>){(
 (<{}{}>))}{}{{}{}(<{}>)((()))(()()()<>)(<><{}>)}{}(({}))((((((()()()()()){})){}{}
 ())){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()))(()()()<>)({}[{}](<()>)){{}
 {}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}(({}))((((((()()()()()){}){}){}()
 )){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()))(()()()()<>)(<><{}>)}{}(({}))
 ((((((()()()()()){}){}){}())()){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)((()))
(()()()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}{}{{
 {}}<>(())<>}{}}<>([]<>)({}<(())>){((<{}{}>))}{}

Try it online!

This is 1100 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.

  • Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program

Brain-Flak, 1101, 1085 bytes

{({}<>)(<>())(<>{}<>)(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)(((()))<>)(<><{}>)}{}(({}))((((()()()()()){}){}){}())({}[{}]<(())>){((
<{}{}>))}{}{{}{}(<{}>)(((()))<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<() 
>))}{}(<><{}>)}{}(({}))(((((()()()()()){}){})){}{})({}[{}]<(())>){((<{}{}>))}{}{
{}{}(<{}>)(((()))()<>)(<><{}>)}{}(({}))(((((()()()()()){}){})()){}{})({}[{}]<(() 
)>){((<{}{}>))}{}{{}{}(<{}>)(((()))()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{ 
{}}((<()>))}{}(<><{}>)}{}(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(())>){(( 
<{}{}>))}{}{{}{}(<{}>)(((()))()()<>)(<><{}>)}{}(({}))((((((()()()()()){})){}{}() 
)){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))()()<>)({}[{}](<()>)){{}{}( 
<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}(({}))((((((()()()()()){}){}){}())) 
{}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))()()()<>)(<><{}>)}{}(({}))((( 
(((()()()()()){}){}){}())()){}{})({}[{}]<(())>){((<{}{}>))}{}{{}{}(<{}>)(((()))( 
)()()<>)({}[{}](<()>)){{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<><{}>)}{}{}{{{}} 
<>(())<>}{}}<>([]<>)({}<(())>){((<{}{}>))}{}

Try it online!

This is 1084 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)

  • Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.

  • Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program


revisions

  • Removed some push pop redundancy
4 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link
  • Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.

  • Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program

  • Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.

  • Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program

3 added 16 characters in body
source | link
2 added 507 characters in body
source | link
1
source | link