mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.1 KiB
27 lines
1.1 KiB
6 years ago
|
## brackets
|
||
|
|
||
|
### Instructions
|
||
|
|
||
5 years ago
|
Write a program that takes an undefined number of `string` in arguments. For each argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline (`'\n'`), otherwise it prints `Error` followed by a newline.
|
||
6 years ago
|
|
||
5 years ago
|
Symbols considered as brackets are parentheses `(` and `)`, square brackets `[` and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
|
||
6 years ago
|
|
||
5 years ago
|
An opening bracket must always be closed by the good closing bracket in the correct order. A `string` which does not contain any bracket is considered as a correctly bracketed `string`.
|
||
6 years ago
|
|
||
5 years ago
|
If there is no argument, the program must print nothing.
|
||
6 years ago
|
|
||
5 years ago
|
### Usage
|
||
6 years ago
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/brackets$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/brackets$ ./brackets '(johndoe)' | cat -e
|
||
6 years ago
|
OK$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/brackets$ ./brackets '([)]' | cat -e
|
||
6 years ago
|
Error$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/brackets$ ./brackets '' '{[(0 + 0)(1 + 1)](3*(-1)){()}}' | cat -e
|
||
6 years ago
|
OK$
|
||
|
OK$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/brackets$ ./brackets
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/brackets$
|
||
6 years ago
|
```
|