Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
#C, 121 122 114 bytes
Shaved of 8 bytes thanks to @xsot!
a[99],i,k;main(c){for(;read(0,&c,!k);c%7&2?k|=a[i--]^c/9:(a[++i]=c/9))k|=!strchr("()[]{}<>",c);putchar(48+!k*!i);}
Uses a stack.
#C, 121 122 114 111114 bytes
Shaved of 8 118 bytes thanks to @xsot!
a[99],i;maini,k;main(c){for(;read(0,&c,1!k);c%7&2?i+=a[i]^ck|=a[i--]^c/9?1:-1:(a[++i]=c/9))i+=k|=!strchr("()[]{}<>",c);putchar(48+!k*!i);}
#C, 121 122 114 111 bytes
Shaved of 8 11 bytes thanks to @xsot!
a[99],i;main(c){for(;read(0,&c,1);c%7&2?i+=a[i]^c/9?1:-1:(a[++i]=c/9))i+=!strchr("()[]{}<>",c);putchar(48+!i);}
#C, 121 122 114114 111 bytes
Shaved of 88 11 bytes thanks to @xsot!
a[99],i,k;maini;main(c){for(;read(0,&c,!k1);c%7&2?k|=a[i--]^ci+=a[i]^c/9?1:-1:(a[++i]=c/9))k|=i+=!strchr("()[]{}<>",c);putchar(48+!k*!i);}