Skip to content

Instantly share code, notes, and snippets.

@ryupy
Created December 16, 2018 13:45
Show Gist options
  • Select an option

  • Save ryupy/cd0fa12c8d26f4fed242a2b32aaffe5e to your computer and use it in GitHub Desktop.

Select an option

Save ryupy/cd0fa12c8d26f4fed242a2b32aaffe5e to your computer and use it in GitHub Desktop.
S = input()
N = len(S)
sum = 0
count = 0
flg = False
S = S[::-1]
for i in range(N):
if S[i] == 'W':
count += 1
flg = True
elif S[i] == 'B' and flg:
sum += count
print(sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment