html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<!--
Challenge by codasan.com located here:
https://www.sololearn.com/Discuss/826514/?ref=app
🏰 CHALLENGE 🏰 The Nearest Cities
Assume we have 5 cities located on a plane whose
coordinates are determined by pairs of random
integer numbers between 1 and 500. You can
compute the distance of each pair of cities
using the Euclid's formula: distance of (x1,y1)
and (x2,y2) equals square root of the sum
(x1-x2)**2+(y1-y2)**2, where **2 means to the
power 2.
CHALLENGE: Find two cities that have the least
distance from each other.
Before printing the final answer, please print
the coordinates of each city.
HINTS: See my answer!
-->
<!--
While I didn't examine his code to make this, I
wish to thank Jonathan for grid graphic idea via
his answer to this challenge located here:
https://code.sololearn.com/W51rh3HE8cOt/?ref=app#html
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Challenge by codasan.com located here:
https://www.sololearn.com/Discuss/826514/?ref=app
🏰 CHALLENGE 🏰 The Nearest Cities
Assume we have 5 cities located on a plane whose
coordinates are determined by pairs of random
integer numbers between 1 and 500. You can
compute the distance of each pair of cities
using the Euclid's formula: distance of (x1,y1)
and (x2,y2) equals square root of the sum
(x1-x2)**2+(y1-y2)**2, where **2 means to the
power 2.
CHALLENGE: Find two cities that have the least
distance from each other.
Before printing the final answer, please print
the coordinates of each city.
HINTS: See my answer!
*/
/*
While I didn't examine his code to make this, I
wish to thank Jonathan for grid graphic idea via
his answer to this challenge located here:
https://code.sololearn.com/W51rh3HE8cOt/?ref=app#html
I doubt I would have come up with it and it was a
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Challenge by codasan.com located here:
// https://www.sololearn.com/Discuss/826514/?ref=app
// 🏰 CHALLENGE 🏰 The Nearest Cities
// Assume we have 5 cities located on a plane whose
// coordinates are determined by pairs of random
// integer numbers between 1 and 500. You can
// compute the distance of each pair of cities
// using the Euclid's formula: distance of (x1,y1)
// and (x2,y2) equals square root of the sum
// (x1-x2)**2+(y1-y2)**2, where **2 means to the
// power 2.
// CHALLENGE: Find two cities that have the least
// distance from each other.
// Before printing the final answer, please print
// the coordinates of each city.
// HINTS: See my answer!
// While I didn't examine his code to make this, I
// wish to thank Jonathan for grid graphic idea via
// his answer to this challenge located here:
// https://code.sololearn.com/W51rh3HE8cOt/?ref=app#html
// I doubt I would have come up with it and it was a
// great learning experience.
//******************** initialize ********************
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run