This series of katas will introduce you to basics of doing geometry with computers.

`Point` objects have `x`, `y`,  and `z` attributes. For Haskell there are `Point` data types described with record syntax with fields `x`, `y`, and `z`.

Write a function calculating distance between `Point a` and `Point b`.

Tests round answers to 6 decimal places. Tests in Haskell will not round.

Source: codewars | Difficulty: EASY
Tags: Geometry

Fundamentals

Starter code: def distance_between_points(a, b):
	

Solutions:
def distance_between_points(a, b):
	return ((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + (b.z - a.z) ** 2) ** 0.5


def distance_between_points(a, b):
	return sum(((getattr(a, i) - getattr(b, i)) ** 2 for i in 'xyz')) ** 0.5


import math

def distance_between_points(a, b):
	x_prime = b.x - a.x
	y_prime = b.y - a.y
	z_prime = b.z - a.z
	distance = math.sqrt(x_prime ** 2 + y_prime ** 2 + z_prime ** 2)
	return distance


import math
distance_between_points = lambda a, b: round(math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2 + (a.z - b.z) ** 2), 6)


from collections import namedtuple

def distance_between_points(a, b):
	return ((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + (b.z - a.z) ** 2) ** 0.5


def distance_between_points(a, b):
	return sum((x * x for x in [a.x - b.x, a.y - b.y, a.z - b.z])) ** 0.5


distance_between_points = lambda a, b: round(sum(((a[0] - a[1]) ** 2 for a in zip([a.x, a.y, a.z], [b.x, b.y, b.z]))) ** 0.5, 6)


def distance_between_points(a, b):
	ss = [(a.__getattribute__(i) - b.__getattribute__(i)) ** 2 for i in 'xyz']
	return sum(ss) ** 0.5