# [Pyth](https://pyth.readthedocs.io), <s>20</s> 19 bytes My current prefix approach (will hopefully golf further). +*tlQsQssM+_M.__Q._ **[Test Suite](http://pyth.herokuapp.com/?code=%2B%2atlQsQssM%2B_M.__Q._&input=%22123%22&test_suite=1&test_suite_input=%2212%22%0A%22101%22%0A%22123%22%0A%221234567%22&debug=0)** or try **[an alternative approach with the same byte count](http://pyth.herokuapp.com/?code=%2B%2alQsQssM%2B_MP.__Q._&input=%22123%22&test_suite=1&test_suite_input=%2212%22%0A%22101%22%0A%22123%22%0A%221234567%22&debug=0).** # Explanation +*tlQsQssM+_M.__Q._ - Full program that reads a String from STDIN, with implicit input. tlQ - Length of the input - 1. sQ - The input converted to an integer. * - Product of the above two elements. We will call this P. ._ - Prefixes of the input. + - Concatenated with: _M.__Q - The prefixes of the reversed input, reversed. sM - Convert each to an integer. s - Sum. + - Addition of the product P and the sum above. To understand the concept better, we shall take an example, say `"123"`. - We first get the prefixes of the input. Those are `['1', '12', '123']`. - Then, we get the prefixes of the reversed input, i.e: `['3', '32', '321']` and reverse each, hence we get `['3', '23', '123']`. - We concatenate the two lists and convert each element to an integer, so we obtain `[3, 23, 123, 1, 12, 123]`. - By summing the list, the result is `285`. - The product `P` is the length of the input - 1 (i.e `2`) multiplied by the integer representation of it (`2 * 123 = 246`). - In the end, we sum the two results: `285 + 246`, hence we obtain `531`, which is the correct result. ------ # [Pyth](https://pyth.readthedocs.io), 20 bytes +*hlQsQsm+s>Qds<QdtU **[Test Suite.](http://pyth.herokuapp.com/?code=%2B%2ahlQsQsm%2Bs%3EQds%3CQdtU&input=%22123%22&test_suite=1&test_suite_input=%221234567%22%0A%22123%22%0A%22101%22%0A%2212%22&debug=0)** # Explanation <s>Explanation to come after further golfing.</s> I didn't succeed to golf this further for now (I have ideas though). +*hlQsQsm+s>Qds<QdtUQ - Full program. Reads from STDIN. Q means input, and is implicit at the end. hlQ - Length of the input + 1. sQ - The input converted to an integer. * - Multiply the above. We'll call the result P. m tUQ - Map over [1...length of the input) s>Qd - input[currentItem:] casted to an integer. s<Qd - input[:currentItem] casted to an integer. + - Sum the above. s - Sum the list. + - Add the sum of the list and P.