At the annual family gathering, the family likes to find the oldest living family member’s age and the youngest family member’s age and calculate the difference between them.

You will be given an array of all the family members' ages, in any order.  The ages will be given in whole numbers, so a baby of 5 months, will have an ascribed ‘age’ of 0.  Return a new array (a tuple in Python) with [youngest age, oldest age, difference between the youngest and oldest age].

Difficulty: EASY
Tags: Data structures
Skill types: Data structures

Starter code:
def difference_in_ages(ages):
	

Solutions:
def difference_in_ages(ages):
	return (min(ages), max(ages), max(ages) - min(ages))


def difference_in_ages(ages):
	(x, y) = (min(ages), max(ages))
	return (x, y, y - x)


def difference_in_ages(ages):
	age = sorted(ages)
	return (age[0], age[-1], age[-1] - age[0])


def difference_in_ages(ages):
	youngest_age = min(ages)
	oldest_age = max(ages)
	difference = oldest_age - youngest_age
	return (youngest_age, oldest_age, difference)


def difference_in_ages(ages):
	youngest = min(ages)
	oldest = max(ages)
	return (youngest, oldest, oldest - youngest)


def difference_in_ages(a):
	L = []
	L.append(min(a))
	L.append(max(a))
	L.append(max(a) - min(a))
	return tuple(L)


def difference_in_ages(ages):
	ages.sort()
	min_age = ages[0]
	max_age = ages[-1]
	return (min_age, max_age, max_age - min_age)


def difference_in_ages(ages):
	(age_min, age_max) = (min(ages), max(ages))
	return (age_min, age_max, age_max - age_min)


def difference_in_ages(ages):
	sortedages = sorted(ages)
	return (sortedages[0], sortedages[-1], sortedages[-1] - sortedages[0])


def difference_in_ages(ages):
	x = sorted(ages)
	return (x[0], x[-1], x[-1] - x[0])


difference_in_ages = lambda ages: (lambda x, y: (x, y, y - x))(min(ages), max(ages))


difference_in_ages = lambda l: (min(l), max(l), max(l) - min(l))


from typing import List

def difference_in_ages(ages: List[int]):
	return (sorted(ages)[0], sorted(ages)[-1], sorted(ages)[-1] - sorted(ages)[0])


def difference_in_ages(ages):
	young = 10000000
	old = 0
	for x in ages:
		if x < young:
			young = x
		if x > old:
			old = x
	difference = old - young
	ris = (young, old, difference)
	return ris


def difference_in_ages(ages):
	ygs = min(ages)
	lrgs = max(ages)
	dif = lrgs - ygs
	return (ygs, lrgs, dif)
	pass


def difference_in_ages(ages):
	ages.sort()
	lst = []
	lst.append(ages[0])
	lst.append(ages[-1])
	lst.append(ages[-1] - ages[0])
	m = tuple(lst)
	return m


def difference_in_ages(ages):
	ages.sort()
	result = []
	res1 = ages[-1] - ages[0]
	res2 = ages[0]
	res3 = ages[-1]
	return (res2, res3, res1)


def difference_in_ages(ages: list) -> tuple:
	return (min(ages), max(ages), max(ages) - min(ages))


def difference_in_ages(ages):
	lista_noua = []
	lista_noua.append(min(ages))
	lista_noua.append(max(ages))
	diferenta = lista_noua[1] - lista_noua[0]
	lista_noua.append(diferenta)
	tupled = tuple(lista_noua)
	return tupled


def difference_in_ages(ages):
	age = sorted(ages)
	age_len = len(age)
	young = age[0]
	old = age[age_len - 1]
	diff = old - young
	result = (young, old, diff)
	return result


def difference_in_ages(ages):
	return (min((x for x in ages)), max((y for y in ages)), max((z for z in ages)) - min((a for a in ages)))


def difference_in_ages(ages):
	ages.sort()
	older = ages[-1]
	younger = ages[0]
	difference = older - younger
	return (younger, older, difference)


def difference_in_ages(ages):
	ages0 = max(ages)
	ages1 = min(ages)
	return (ages1, ages0, ages0 - ages1)


def difference_in_ages(ages):
	minimum = min(ages)
	maximum = max(ages)
	diff = maximum - minimum
	return (minimum, maximum, diff)


def difference_in_ages(ages):
	b = max(ages) - min(ages)
	a = (min(ages), max(ages), b)
	return a


def difference_in_ages(ages):
	ages = sorted(ages)
	return (ages[0], ages[len(ages) - 1], abs(ages[0] - ages[len(ages) - 1]))


def difference_in_ages(ages):
	min_ = min(ages)
	max_ = max(ages)
	return (min_, max_, max_ - min_)


def difference_in_ages(ages):
	x = len(ages)
	ages.sort()
	a = ages[0]
	b = ages[x - 1]
	c = a - b
	if c >= 0:
		c = c
	else:
		c = -c
	z = (a, b, c)
	return z


def difference_in_ages(ages):
	t = (min(ages), max(ages), max(ages) - min(ages))
	return tuple(t)


def difference_in_ages(ages):
	sorta = sorted(ages)
	return (sorta[0], sorta[-1], sorta[-1] - sorta[0])


def difference_in_ages(ages):
	old = max(ages)
	y = min(ages)
	diff = old - y
	return (y, old, diff)


def difference_in_ages(ages):
	min = ages[0]
	max = ages[0]
	for age in ages:
		if age < min:
			min = age
		if age > max:
			max = age
	diff = max - min
	return (min, max, diff)


def difference_in_ages(ages):
	goal = []
	goal.append(min(ages))
	goal.append(max(ages))
	goal.append(goal[1] - goal[0])
	return tuple((i for i in goal))


def difference_in_ages(ages):
	l = min(ages)
	p = max(ages)
	s = min(ages) - max(ages)
	return (l, p, abs(s))


def difference_in_ages(ages):
	max_age = max(ages)
	min_age = min(ages)
	dif_age = max_age - min_age
	return (min_age, max_age, dif_age)


def difference_in_ages(ages):
	ages_sorted = sorted(ages)
	youngest = ages_sorted[0]
	oldest = ages_sorted[-1]
	difference = oldest - youngest
	return (youngest, oldest, difference)
	return ages_sorted
	pass


def difference_in_ages(ages):
	(mx, mn) = (max(ages), min(ages))
	return (mx - mn, mx, mn)[::-1]


def difference_in_ages(ages):
	(lowest, highest) = (min(ages), max(ages))
	return (lowest, highest, highest - lowest)


def difference_in_ages(ages):
	(mi, ma) = (min(ages), max(ages))
	return (mi, ma, ma - mi)


def difference_in_ages(ages):
	a = max(ages)
	t = min(ages)
	l = a - t
	return (t, a, l)


def difference_in_ages(ages):
	a = max(ages)
	b = min(ages)
	dif = abs(a - b)
	return (b, a, dif)


def difference_in_ages(ages):
	a = ages[0]
	b = ages[0]
	for i in ages:
		if i < a:
			a = i
	for x in ages:
		if b <= x:
			b = x
	return (a, b, b - a)


def difference_in_ages(ages):
	mini = min(ages)
	maxi = max(ages)
	diff = maxi - mini
	tup = (mini, maxi, diff)
	return tup


def difference_in_ages(ages):
	(y, o) = (min(ages), max(ages))
	d = o - y
	return (y, o, d)


def difference_in_ages(ages):
	youngest_age = ages[0]
	oldest_age = 0
	for age in ages:
		if age < youngest_age:
			youngest_age = age
		if age > oldest_age:
			oldest_age = age
	soln = (youngest_age, oldest_age, oldest_age - youngest_age)
	return soln


def difference_in_ages(ages):
	max = 0
	for i in ages:
		if i > max:
			max = i
	min = max
	for j in ages:
		if j < min:
			min = j
	a = max - min
	return (min, max, a)


from typing import List

def difference_in_ages(ages: List[int]):
	return (min(ages), max(ages), max(ages) - min(ages))


def difference_in_ages(ages):
	x = []
	x.append(min(ages))
	x.append(max(ages))
	x.append(max(ages) - min(ages))
	return tuple(x)


def difference_in_ages(ages):
	result = [min(ages), max(ages), max(ages) - min(ages)]
	return tuple(result)


def difference_in_ages(ages):
	max_age = max(ages)
	min_age = min(ages)
	sub = max_age - min_age
	sum = max_age - min_age
	listt = (min_age, max_age, sub)
	return listt


def difference_in_ages(ages):
	s = sorted(ages)[0]
	s1 = sorted(ages, reverse=True)[0]
	return (s, s1, s1 - s)


def difference_in_ages(ages):
	ages.sort()
	tpp1 = (ages[0], ages[-1], ages[-1] - ages[0])
	return tpp1


def difference_in_ages(ages):
	ages.sort()
	poo = (ages[0], ages[-1], ages[-1] - ages[0])
	return poo


def difference_in_ages(ages):
	ages.sort()
	youngest = ages[0]
	oldest = ages[-1]
	difference = ages[-1] - ages[0]
	return (youngest, oldest, difference)


def difference_in_ages(ages):
	maximum = max(ages)
	minimum = min(ages)
	diffrence = maximum - minimum
	return (minimum, maximum, diffrence)


def difference_in_ages(ages):
	bruh = list()
	bruh.append(min(ages))
	bruh.append(max(ages))
	bruh.append(max(ages) - min(ages))
	return tuple(bruh)


def difference_in_ages(ages):
	ages.sort()
	summary = (ages[0], ages[-1], ages[-1] - ages[0])
	return summary


def difference_in_ages(a):
	a.sort()
	return (a[0], a[-1], a[-1] - a[0])


from operator import sub

def difference_in_ages(ages):
	sort_ages = sorted(ages)
	return (sort_ages[0], sort_ages[-1], sub(sort_ages[-1], sort_ages[0]))


def difference_in_ages(ages):
	ages.sort()
	m = ages[0]
	u = ages[-1]
	return (m, u, u - m)


def difference_in_ages(s):
	return (min(s), max(s), max(s) - min(s))


def difference_in_ages(ages):
	ages.sort()
	a = ages[-1]
	b = ages[0]
	c = a - b
	return (b, a, c)


def difference_in_ages(ages):
	ages.sort()
	a = ages[0]
	b = ages[-1]
	m = b - a
	return (a, b, m)


def difference_in_ages(ages):
	youngest_age = 10000000000000
	oldest_age = 0
	for x in ages:
		if x < youngest_age and x > oldest_age:
			youngest_age = x
			oldest_age = x
		elif x < youngest_age:
			youngest_age = x
		elif x > oldest_age:
			oldest_age = x
		else:
			pass
	difference = oldest_age - youngest_age
	return (youngest_age, oldest_age, difference)


def difference_in_ages(age):
	ergebnis = []
	ergebnis.append(sorted(age)[0])
	ergebnis.append(sorted(age)[-1])
	ergebnis.append(ergebnis[-1] - ergebnis[0])
	return tuple(ergebnis)


def difference_in_ages(ages):
	smallest = ages[0]
	largest = ages[1]
	for age in ages:
		if smallest > age:
			smallest = age
		if largest < age:
			largest = age
	return (smallest, largest, largest - smallest)


def difference_in_ages(ages):
	ages.sort()
	oldest_age = ages[-1]
	youngest_age = ages[0]
	diff = ages[-1] - ages[0]
	return tuple([youngest_age, oldest_age, diff])


def difference_in_ages(ages):
	ages = sorted(ages)
	ages_diff = (ages[0], ages[-1], ages[-1] - ages[0])
	return ages_diff


def difference_in_ages(ages):
	(lo, hi) = (min(ages), max(ages))
	return (lo, hi, hi - lo)


def difference_in_ages(ages):
	oldest = ages[0]
	youngest = ages[0]
	for e in ages:
		if e > oldest:
			oldest = e
		elif e < youngest:
			youngest = e
	arr = (youngest, oldest, oldest - youngest)
	return arr


def difference_in_ages(ages):
	sor = sorted(ages)
	a = sor[0]
	b = max(sor)
	diff = ()
	c = b - a
	j = 0
	diff = (a, b, c)
	return diff
	pass


def difference_in_ages(ages):
	ages.sort()
	diference = []
	diference.append(ages[0])
	diference.append(ages[len(ages) - 1])
	diference.append(ages[len(ages) - 1] - ages[0])
	return tuple(diference)


def difference_in_ages(ages):
	sorted = ages.sort()
	low = ages[0]
	high = ages[-1]
	diff = high - low
	return (low, high, diff)


import math

def difference_in_ages(ages):
	young = math.inf
	old = -math.inf
	for age in ages:
		if age > old:
			old = age
		if age < young:
			young = age
	return (young, old, old - young)


def difference_in_ages(ages):
	ages.sort()
	agelen = len(ages)
	return (ages[0], ages[agelen - 1], ages[agelen - 1] - ages[0])


import sys

def difference_in_ages(ages):
	array = []
	youngest = sys.maxsize
	oldest = -sys.maxsize - 1
	for i in ages:
		if youngest > i:
			youngest = i
		if oldest < i:
			oldest = i
	difference = oldest - youngest
	return (youngest, oldest, difference)


def difference_in_ages(ages):
	ages.sort()
	youngest = ages[0]
	oldest = ages[-1]
	diff = oldest - youngest
	return (youngest, oldest, diff)


def difference_in_ages(ages):
	ageDif = []
	ageDif.extend([min(ages), max(ages), max(ages) - min(ages)])
	return tuple(ageDif)


def difference_in_ages(ages):
	youngestAge = min(ages)
	oldestAge = max(ages)
	difference = oldestAge - youngestAge
	return (youngestAge, oldestAge, difference)


def difference_in_ages(ages):
	m = min(ages)
	b = max(ages)
	r = b - m
	return (m, b, r)


def difference_in_ages(ages):
	minage = min(ages)
	maxage = max(ages)
	return (minage, maxage, abs(maxage - minage))


def difference_in_ages(ages):
	M = max(ages)
	m = min(ages)
	return (m, M, M - m)


def difference_in_ages(ages):
	ages.sort()
	young = ages[0]
	old = ages[len(ages) - 1]
	return (young, old, old - young)


def difference_in_ages(ages):
	first = max(ages)
	second = min(ages)
	return (second, first, first - second)