harbor run -t openthoughts/tasktrove-exp-rpt-taco-v2-taco-2291harbor download openthoughts/tasktrove-exp-rpt-taco-v2-taco-2291Stylish is a programming language with a unique syntax that includes names (sequences of Latin alphabet letters), specific grouping symbols (round brackets (), curly brackets {}, and square brackets []), periods (.) as term separators, and newlines. Your mission is to learn the indentation styles of Stylish masters and replicate them.
The amount of indentation of a line is determined by the formula: [ \text{indentation} = R(ro - rc) + C(co - cc) + S(so - sc) ] Where:
The input consists of multiple datasets. Each dataset starts with a line containing two integers:
The next ( p ) lines contain the Stylish program ( P ). The following ( q ) lines contain the program ( Q ). Each line has at least one character and at most 80 characters. Additionally, no line in ( Q ) starts with a period.
The input terminates with a line containing two zeros.
For each dataset, output the appropriate amounts of indentation for each line of program ( Q ). The amounts must be separated by a single space and should not end with trailing spaces. If the indentation for a line of ( Q ) cannot be determined uniquely from ( P ), output -1 for that line.
5 4
(Follow.my.style
.........starting.from.round.brackets)
{then.curly.brackets
.....[.and.finally
.......square.brackets.]}
(Thank.you
{for.showing.me
[all
the.secrets]})
4 2
(This.time.I.will.show.you
.........(how.to.use.round.brackets)
.........[but.not.about.square.brackets]
.........{nor.curly.brackets})
(I.learned
how.to.use.round.brackets)
4 2
(This.time.I.will.show.you
.........(how.to.use.round.brackets)
.........[but.not.about.square.brackets]
.........{nor.curly.brackets})
[I.have.not.learned
how.to.use.square.brackets]
2 2
(Be.smart.and.let.fear.of
..(closed.brackets).go)
(A.pair.of.round.brackets.enclosing
[A.line.enclosed.in.square.brackets])
1 2
Telling.you.nothing.but.you.can.make.it
[One.liner.(is).(never.indented)]
[One.liner.(is).(never.indented)]
2 4
([{Learn.from.my.KungFu
...}])
((
{{
[[
]]}}))
1 2
Do.not.waste.your.time.trying.to.read.from.emptiness
(
)
2 3
({Quite.interesting.art.of.ambiguity
....})
{
(
)}
2 4
({[
............................................................]})
(
{
[
]})
0 0
0 9 14 16
0 9
0 -1
0 2
0 0
0 2 4 6
0 -1
0 -1 4
0 20 40 60
The solution should be implemented in the /app/ directory. Make sure to handle all aspects of the input and output as specified, including indentation calculations based on the Stylish programming syntax.
Important: place your implementation at /app/solution.py so the verifier can run it.