EX_03/level-2/rip/subject.txt
2025-09-23 08:41:21 +01:00

28 lines
771 B
Plaintext

Assignment name : rip
Expected files : *.c *.h
Allowed functions: puts, write
--------------------------------------------------------------------------------
Write a program that will take as argument a string containing only parenthesis.
if the parenthesis are unbalanced (for example "())")
your program shall remove the minimum number of parentheses for the expression to be balanced.
By removing we mean replacing by spaces.
You will then print all the solutions (can be more than one).
The order of the solutions is not important.
For example this should work:
$> ./rip '(()' | cat -e
()$
( )$
$> ./rip '((()()())())' | cat -e
((()()())())$
$> ./rip '()())()'| cat -e
()() ()$
()( )()$
( ())()$
$> ./rip '(()(()(' | cat -e
(() ) $
( )( ) $
( ) () $
()( ) $