Suggested problems

Distance between atoms

Nov. 22, 2012, 11:43 p.m. by Guillaume Collet

A Rapid Introduction to Protein Structures

A protein structure is described on 4 levels.

The chain of amino acids of a protein is called the primary structure. The secondary structure is the representation of the protein as a chain of secondary structure elements. Secondary structure elements are highly regular local substructures like helices and sheets. The tertiary structure is the 3D shape of a protein, i.e. the 3D coordinates of all atoms. Finally, the quaternary structure is an assembly of some protein chains which form a complex. For more details, see: Protein Structure.

The string algorithm topic focus on the primary structure of proteins. Here, we will focus on the tertiary structure. Being able to align a newly discovered protein 3D structure can be of great help to annotate this protein. To be able to compare 3D structures, we must be able to calculate the distance between two atoms in 3D space.


An atom is defined by its three coordinates (x, y, z) in 3D space. To calculate the distance between two points in 3D, we apply the Pythagora's theorem.

Distance between two points

Given: Five atom's coordinates.

Return: The list of distances between all pairs of distinct atoms in any order with a decimal precision of 2.

Sample Dataset

17.426 -32.764 65.278
2.109 -38.295 41.517
-7.758 -42.568 33.470
-5.866 -3.238 13.986
-4.720 -38.377 -4.862

Sample Output

28.806 41.738 63.601 73.767 13.430 45.283 46.879 43.932 38.680 39.891