The Challenge
Given an input string (or array) consisting of <
and >
, output a sequence (array or string) of integers such that:
- the operators are all correct when applied in order between consecutive numbers in the output
- all integers are positive (1 or greater)
- the sum of the integers is as small as is mathematically possible
Inputs can vary to match "greater than" and "less than" in your chosen language.
As an alternative output, just specify the sum of the numbers in the output. State which version you're solving in your Answer title.
Usual exclusions and rules apply, smallest bytes wins.
You can assume that the input string will never lead to an integer overflow in your language, if that helps.
Examples
>
gives2 1
which sums to3
>>>
gives4 3 2 1
which sums to10
><
gives2 1 2
which sums to5
gives
1
which sums to1
>>>>>>>>>
gives10 9 8 7 6 5 4 3 2 1
which sums to55
>><<>><>>>
gives3 2 1 2 3 2 1 4 3 2 1
which sums to24
><>><>><>
gives2 1 3 2 1 3 2 1 2 1
which sums to18
<<<<>
gives1 2 3 4 5 1
which sums to16
<<<<><<>
gives1 2 3 4 5 1 2 3 1
which sums to22
>><<
gives3 2 1 2 3
which sums to11
>
and<
? \$\endgroup\$><>
\$\endgroup\$