Change your Points of View
Description:
We want to define the location x
, y
of a point
on a two-dimensional plane where x
and y
are positive integers.
Our definition of such a point
will return a function (procedure). There are several possible functions to do that.
Possible form of point
:
point(a: Int, b: Int): ... complete ... {
// your code
};
The type of point(a, b) is "scala.Function..."
Of course we need to be able to extract from our point
the two coordinates x
and y
.
The function fst
must return the first element x
and our function snd
must return the second element y
.
We will also write a function sqr-dist
which returns the square of the distance between two points point1
and point2
.
Last function to write line
:
Given two points
foo
and bar
this function return a list (l m n)
or [l, m, n]
where l, m, n
are the coefficients in
the general equation l*x + m*y + n = 0 (1)
of the straight line through the points foo
and bar
.
Equation k*l*x + k*m*y + k*n = 0
is equivalent to (1) and the tests consider that they define the "same" line.
Examples: See "Sample Tests".
Note:
- Please ask before translating: some translations are already written and published when/if the kata is approved.
Similar Kata:
Stats:
Created | Apr 2, 2019 |
Published | Apr 2, 2019 |
Warriors Trained | 1853 |
Total Skips | 159 |
Total Code Submissions | 2155 |
Total Times Completed | 344 |
Racket Completions | 12 |
Python Completions | 162 |
Clojure Completions | 11 |
Ruby Completions | 19 |
JavaScript Completions | 108 |
Scala Completions | 10 |
F# Completions | 7 |
C# Completions | 17 |
VB Completions | 7 |
Java Completions | 14 |
Kotlin Completions | 14 |
Total Stars | 34 |
% of votes with a positive feedback rating | 80% of 92 |
Total "Very Satisfied" Votes | 64 |
Total "Somewhat Satisfied" Votes | 19 |
Total "Not Satisfied" Votes | 9 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |