Skip to main content
deleted 3 characters in body
Source Link
Mitch Schwartz
  • 5.9k
  • 1
  • 27
  • 26

Brainfuck, 134132 bytes

+>,[[<->>+<>>+>[-]<[>+>>[]<<-]<[<+<+>>>+<]<[>+>[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[[]>[,]>]]]]<]>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<>+>[-]<<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>>>+>[<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            [,]>>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and movewhile moving the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 134 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[[,]>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            [,]>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 132 bytes

+>,[[<->>+>[-]<<-]<[>+>[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[,>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+>[-]<<-]
  <
  [
    not matching closing bracket
    >+>[<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            ,>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input while moving the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Rollback to Revision 1
Source Link
Mitch Schwartz
  • 5.9k
  • 1
  • 27
  • 26

Brainfuck, 132134 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[>]>[[,]]]]<]]>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            >[,]>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 132 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[>,]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            >,
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 134 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[[,]>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            [,]>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

deleted 7 characters in body
Source Link
Mitch Schwartz
  • 5.9k
  • 1
  • 27
  • 26

Brainfuck, 134132 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[[]>[>,]>]]]]<]]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            [>,]>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 134 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[[,]>]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            [,]>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Brainfuck, 132 bytes

+>,[[<->>+<-]<[>+>>[-]<[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[>,]]]]<],]<<[>]>.

Formatted:

+>,
[
  [<-> >+<-]
  <
  [
    not matching closing bracket
    >+> >[-]< [<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            >,
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.

Try it online.

Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input and move the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Source Link
Mitch Schwartz
  • 5.9k
  • 1
  • 27
  • 26
Loading