Java 10, 198181 바이트
s->{var p=s.split("(?<=(.))(?!\\1)");int l=p.length,L[]=new int[l],i=l,r=0,a,b;for(;i-->0;r+=a*-~a/2-(i<l-1?p[i].charAt(0)<61?a<(b=L[i+1])?a:b:1:0))a=L[i]=p[i].length()+1;return r;}
온라인으로 사용해보십시오.
설명:
s->{ // Method with String parameter and integer return-type
var p=s.split("(?<=(.))(?!\\1)");
// Split the String into parts
// (i.e. ">><<>><>>>" becomes [>>, <<, >>, <, >>>])
int l=p.length, // Get the amount of parts
L[]=new int[l], // Create an integer-array of the same size
i=l, // Index-integer, starting at this size
r=0, // Result-integer, starting at 0
a,b; // Two temp integers to reduce the byte-count
for(;i-->0; // Loop downwards over the array; range: (`l`,0]
;r+= // After every iteration: increase the result with:
a*-~a/2 // The triangle number of the current item
-(i<l-1? // If it's not the last item:
p[i].charAt(0)<61?
// And the order of the current and previous is "<>":
a<(b=L[i+1])? // If the current item in `L` is smaller than the previous:
a // Subtract the current item
: // Else (the current is equal or larger than the previous):
b // Subtract the previous item
: // Else (the order of the two parts is "><" instead):
1 // Subtract 1
: // Else (it's the last item in `L`):
0)) // Leave the result `r` unchanged
a=L[i]= // Set both `a` and the current item in `L` to:
p[i].length()+1; // The length of the part + 1
return r;} // Return the result
>
및 이외의 기호를 사용할 수 있습니까<
?