Sam has opened a new sushi train restaurant - a restaurant where sushi is served on plates that travel around the bar on a conveyor belt and customers take the plate that they like.

Sam is using Glamazon's new visual recognition technology that allows a computer to record the number of plates at a customer's table and the colour of those plates.  The number of plates is returned as a string.  For example, if a customer has eaten 3 plates of sushi on a red plate the computer will return the string 'rrr'.

Currently, Sam is only serving sushi on red plates as he's trying to attract customers to his restaurant.  There are also small plates on the conveyor belt for condiments such as ginger and wasabi - the computer notes these in the string that is returned as a space ('rrr r' //denotes 4 plates of red sushi and a plate of condiment).

Sam would like your help to write a program for the cashier's machine to read the string and return the total amount a customer has to pay when they ask for the bill.  The current price for the dishes are as follows:  

 * Red plates of sushi ('r') - $2 each, but if a customer eats 5 plates the 5th one is free.
 * Condiments (' ') - free.

```
Input: String
Output: Number

Examples:

Input: 'rr'  Output: 4
Input: 'rr rrr' Output: 8
Input: 'rrrrr rrrrr' Output: 16

```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def total_bill(s):
	

Solutions:
def total_bill(s):
	return 2 * (s.count('r') - s.count('r') // 5)


def total_bill(s):
	s = s.replace(' ', '')
	return 2 * (len(s) - len(s) // 5)


def total_bill(s):
	sushi = s.count('r')
	discount = int(sushi / 5)
	sushi -= discount
	return sushi * 2


from math import ceil

def total_bill(s):
	return 2 * ceil(s.count('r') * 4 / 5)


def total_bill(s):
	(n, r) = divmod(s.count('r'), 5)
	return 8 * n + 2 * r


import re

def total_bill(s):
	return len(re.sub('r{5}', 'rrrr', re.sub('\\s+', '', s))) * 2


def total_bill(s):
	plates = s.count('r')
	discount = int(plates / 5)
	return (plates - discount) * 2