You can print your name on a billboard ad. Find out how much it will cost you. Each letter has a default price of £30, but that can be different if you are given 2 parameters instead of 1.

You can not use multiplier "*" operator.

If your name would be Jeong-Ho Aristotelis, ad would cost £600.
20 leters * 30 = 600 (Space counts as a letter).

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def billboard(name, price=30):
	

Solutions:
def billboard(name, price=30):
	return sum((price for letter in name))


def billboard(name, price=30):
	return len(name) * price


def billboard(name, price=30):
	return sum([price for l in name])


def billboard(name, price=30):
	return sum((price for _ in name))


def billboard(name, price=30):
	cout = 0
	for letters in name:
		cout += price
	return cout


billboard = lambda n, p=30: len(n) * p


def billboard(name, price=30):
	return sum((price for c in name))


def billboard(name, price=30):
	amt = len(name) / (1.0 / price)
	return amt


from operator import mul

def billboard(name, price=30):
	return mul(len(name), price)


def billboard(name, price=30):
	cost = 0
	for i in range(0, len(name)):
		cost += price
	return cost


def billboard(name, price=30):
	return int(len(name) / (1.0 / price))


def billboard(name: str, price: int=30) -> int:
	return len(name) * price


def billboard(name, price=30):
	return sum([price for prince in range(len(name))])


def billboard(name, price=30):
	a = 0
	for c in name:
		a += price
	return a


def billboard(name, price=30):
	l = [price for i in range(1, len(name) + 1)]
	return sum(l)


def billboard(name, price=30):
	a = 0
	for i in name:
		a += price
	return a


def billboard(name, price=30):
	total_price = 0
	for char in name:
		total_price += price
	return total_price


def billboard(name, price=30):
	suma = 0
	s = len(name)
	for i in range(1, s + 1):
		suma += price
	return suma


def billboard(name, price=30):
	tot = 0
	for x in name:
		tot += price
	return tot


def billboard(name, price=30):
	return __import__('operator').mul(len(name), price)


def pro_recursive(n, m):
	if n == 1:
		return m
	else:
		return m + pro_recursive(n - 1, m)

def billboard(name, price=30):
	return pro_recursive(len(name), price)


import functools

def billboard(name, price=30):
	print(name, price)
	return functools.reduce(lambda x, y: x + y, list(map(lambda x: price, list(range(len(name))))))


def billboard(name, price=30):
	if price == 30:
		result = 0
		for i in range(len(name)):
			result += 30
		return result
	else:
		result = 0
		for i in range(len(name)):
			result += price
		return result


def billboard(name, price=30):
	rv = 0
	for i in range(len(name)):
		rv += price
	else:
		return rv


def billboard(name, price=30):
	total = 0
	for char in name:
		total += price
	return total


def billboard(name, price=30):
	return sum((price for x in name))


def billboard(name, price=30):
	sum = 0
	for char in name:
		sum += price
	return sum


import numpy as np

def billboard(name, price=30):
	return np.dot(len(name), price)


def billboard(name, price=30):
	pri = 0
	for i in name:
		pri += price
	return pri


def billboard(name, price=30):
	return sum((1 * price for i in name))


def billboard(n, p=30):
	return len(n) * p


def billboard(name, price=30):
	cost = 0
	for s in name:
		cost += price
	return cost


def billboard(name, price=30):
	letters = 1
	new_price = 0
	while letters <= len(name):
		new_price = new_price + price
		letters = letters + 1
	return new_price


def billboard(name, price=30):
	x = 0
	for i in name:
		x += price
	return x


def billboard(name: str, price: int=30) -> int:
	return sum((price for _ in range(len(name))))


def billboard(name, price=30):
	from operator import mul
	return list(map(mul, [len(name)], [price]))[0]


def billboard(name, price=30):
	myPrice = [price for char in name]
	return sum(myPrice)


def billboard(name, price=30):
	return sum([price for x in range(0, len(name))])


def billboard(name, price=30):
	total = 0
	for each in range(len(name)):
		total += price
	return total


def billboard(name, price=30):
	total = 0
	i = 0
	while i < len(name):
		total += price
		i += 1
	return total


import numpy

def billboard(name, price=30):
	return numpy.prod([len(name), price])


def billboard(name, price=30):
	p = 0
	for c in range(len(name)):
		p += price
	return p


def billboard(name, price=30):
	total_price = 0
	for c in name:
		total_price += price
	return total_price


def billboard(name, price=30):
	r = 0
	for _ in name:
		r += price
	return r


def billboard(name, price=30):
	total = 0
	return sum((total + price for _ in name))


def billboard(name, price=30):

	def s(a, b):
		return a * b
	return s(len(name), price)


def billboard(name, price=30):
	total = 0
	for i in range(1, len(name) + 1):
		total += price
	return total


def billboard(name, price=30):
	cost = 0
	for letter in name:
		cost = cost + price
	return cost


def billboard(name, price=30):
	t = 0
	for l in name:
		t += price
	return t


def billboard(name, price=30):
	return sum([price for i in list(name)])


def billboard(name, price=30):
	q = 0
	i = 1
	while i <= len(name):
		q += price
		i += 1
	return q


def billboard(name, price=30):
	return sum([price for c in range(len(name))])


def billboard(name, price=30):
	result = 0
	for letter in name:
		result += price
	return result


from functools import reduce
billboard = lambda n, p=30: reduce(lambda a, b: a + p, n, 0)


def billboard(name, price=30):
	total = 0
	for x in name:
		if x:
			total += price
	return total


import operator
res = 0

def billboard(name, price=30):
	return sum([len(name) for i in range(price)])


def billboard(name, price=30):
	num = len(name)
	calc = 0
	count = 0
	while count < num:
		calc = calc + price
		count = count + 1
	return calc


def billboard(name, price=30):
	i = 0
	x = 0
	b = len(name)
	while i < b:
		x = x + price
		i += 1
	return x


billboard = lambda name, price=30: sum((price for x in name))


def billboard(name, price=30):
	total_price = 0
	for char in range(len(name)):
		total_price += price
	return total_price


def billboard(name, price=30):
	builder = 0
	for x in name:
		builder = builder + price
	return builder


def billboard(name, price=30):
	amount = 0
	for _ in name:
		amount += price
	return amount


def billboard(name, price=30):
	sum = 0
	for element in name:
		sum += price
	return sum


billboard = lambda s, p=30: sum((p for x in s))


def billboard(name, price=30):
	return len(name) / (1 / float(price))