Given the number pledged for a year, current value and name of the month, return string that gives information about the challenge status:

- ahead of schedule
- behind schedule
- on track
- challenge is completed

Examples:

`(12, 1, "February")` - should return `"You are on track."`

`(12, 1, "March")` - should return `"You are 1 behind schedule."`

`(12, 5, "March")` - should return `"You are 3 ahead of schedule."`

`(12, 12, "September")` - should return `"Challenge is completed."`

Details:
- you do not need to do any prechecks (input will always be a natural number and correct name of the month)
- months should be as even as possible (i.e. for 100 items: January, February, March and April - 9, other months 8)
- count only the item for completed months (i.e. for March check the values from January and February) and it means that for January you should always return `"You are on track."`.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def check_challenge(pledged, current, month):
	

Solutions:
import calendar
M = {calendar.month_name[i]: i - 1 for i in range(1, 13)}

def check_challenge(pledged, current, month):
	if pledged == current:
		return 'Challenge is completed.'
	m = M[month]
	(per_month, rest) = divmod(pledged, 12)
	todo = per_month * m + min(rest, m)
	delta = current - todo
	if delta == 0 or m == 0:
		return 'You are on track.'
	elif delta > 0:
		return f'You are {delta} ahead of schedule!'
	else:
		return f'You are {-delta} behind schedule.'


MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
MONTHS_DCT = {m: i for (i, m) in enumerate(MONTHS)}

def check_challenge(pledged, current, month):
	if month == MONTHS[0]:
		return 'You are on track.'
	if current == pledged:
		return 'Challenge is completed.'
	(n, r) = divmod(pledged, 12)
	accum = sum((n + (i < r) for i in range(MONTHS_DCT[month])))
	delta = accum - current
	return 'You are on track.' if delta == 0 else 'You are {} behind schedule.'.format(delta) if delta > 0 else 'You are {} ahead of schedule!'.format(abs(delta))


from calendar import month_name
months = {m: i for (i, m) in enumerate(month_name)}

def check_challenge(pledged, current, month):
	if pledged == current:
		return 'Challenge is completed.'
	(q, r) = divmod(pledged, 12)
	m = months[month] - 1
	val = current - m * q - min(m, r)
	if m and val:
		return f'You are {-val} behind schedule.' if val < 0 else f'You are {val} ahead of schedule!'
	return 'You are on track.'


def spread(n):
	(i, r) = (0, [0 for _ in range(12)])
	while sum(r) != n:
		r[i] += 1
		i = (i + 1) % 12
	return r

def check_challenge(n, c, m):
	d = dict(zip('January February March April May June July August September October November December'.split(), range(13)))
	arr = spread(n)
	if m == 'January':
		return 'You are on track.'
	if n == c:
		return 'Challenge is completed.'
	x = sum(arr[:d.get(m)])
	if x > c:
		return f'You are {x - c} behind schedule.'
	return f'You are {c - x} ahead of schedule!' if c - x != 0 else 'You are on track.'


m = {'January': 1, 'February': 2, 'March': 3, 'April': 4, 'May': 5, 'June': 6, 'July': 7, 'August': 8, 'September': 9, 'October': 10, 'November': 11, 'December': 12}

def check_challenge(pledged, current, month):
	t = [pledged // 12] * 12
	for i in range(pledged % 12):
		t[i] += 1
	x = sum(t[:m[month] - 1])
	if month == 'January' or current == x:
		return 'You are on track.'
	elif pledged <= current:
		return 'Challenge is completed.'
	elif current < x:
		return 'You are {} behind schedule.'.format(x - current)
	else:
		return 'You are {} ahead of schedule!'.format(current - x)


from itertools import accumulate

def check_challenge(pledged, current, month):
	if month == 'January':
		return 'You are on track.'
	if pledged == current:
		return 'Challenge is completed.'
	months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
	(q, r) = divmod(pledged, 12)
	progresses = list(accumulate([q + (m < r) for m in range(12)]))
	p = progresses[months.index(month) - 1]
	if p == current:
		return 'You are on track.'
	return f'You are {p - current} behind schedule.' if p > current else f'You are {current - p} ahead of schedule!'


def check_challenge(p, c, m):
	if p == c:
		return 'Challenge is completed.'
	n = 'an eb ar pr ay un ul ug ep ct ov ec'.split().index(m[1:3])
	s = p // 12 * n + min(p % 12, n) - c
	return 'You are ' + ('%s schedule' % ('%d ahead of' % -s, '%d behind' % s)[0 < s] + '.!'[s < 0], 'on track.')[n == 0 or s == 0]


def check_challenge(p, c, m):
	if p == c:
		return 'Challenge is completed.'
	n = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split().index(m[:3])
	s = p // 12 * n + min(p % 12, n) - c
	return 'You are ' + ('%s schedule' % ('%d ahead of' % -s, '%d behind' % s)[0 < s] + '.!'[s < 0], 'on track.')[n == 0 or s == 0]


def check_challenge(p, c, m, M='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()):
	if p == c:
		return 'Challenge is completed.'
	D = [0] * 12
	while p:
		for (i, x) in enumerate(D):
			if p == 0:
				break
			D[i] += 1
			p -= 1
	m = M.index(m[:3])
	s = sum(D[:m]) - c
	if m == 0 or s == 0:
		return 'You are on track.'
	return 'You are %s schedule' % ('%d behind' % s if 0 < s else '%d ahead of' % -s) + '.!'[s < 0]