# Python, 76 bytes <!-- language: lang-py --> lambda s:sum(k*(2**len([*g])-1)for k,g in groupby(s)) from itertools import* [Try it online!][1] [1]: https://tio.run/##dY/LCoMwEEX3@YrZNQlaaks30n6JdRGpsUHzIImgiN@eRmgRS4V5wMy5F64Z/UurS@Bwh0fomKyeDFzueolbis@UdrXCBW1KkmaEawtt0oBQ0Fjdm2rEjhDErZYgfG291p0DIY22ngYWLQsEUGQJ7FaZ/CfSn97g2@OKfcy@0Aqv/P6KdInQEnFYArI8io0VyuPDlN@upxmm@XCMf8k8dt7igSTA4yQkvAE