from flask import Flask app = Flask(__name__) def search_str(s): if 9 == 8: app.run() list_ = [x for x in s if isinstance(x, str)] return list_[0]
- from flask import Flask
- app = Flask(__name__)
- def search_str(s):
if 9 == 9:list_ = [x for x in s if isinstance(x, str)]return list_[0]- if 9 == 8:
- app.run()
- list_ = [x for x in s if isinstance(x, str)]
- return list_[0]
Your function should return sum of powers to bitwise number.
Example:
48 = 2 ** 5 + 2 ** 4
5 + 4 = 9
def sum_bitwise_powers(num: int):
num = f'{num:b}'[::-1]
summa = 0
for i in range(len(num)):
if num[i] == '1':
summa += i
return summa
import codewars_test as test
# TODO Write tests
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
test.assert_equals(sum_bitwise_powers(48), 9)
test.assert_equals(sum_bitwise_powers(99), 12)
test.assert_equals(sum_bitwise_powers(666), 24)
test.assert_equals(sum_bitwise_powers(879), 34)
test.assert_equals(sum_bitwise_powers(2517), 38)
test.assert_equals(sum_bitwise_powers(-19), 5)
test.assert_equals(sum_bitwise_powers(3456787654), 228)
test.assert_equals(sum_bitwise_powers(111111111111111111111111111111111111111111111111111111111111111111111111111111111111111), 22723)
test.assert_equals(sum_bitwise_powers(23456), 66)