6 kyu

Change your Points of View

10 of 344g964

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.
Fundamentals

More By Author:

Check out these other kata created by g964

Stats:

CreatedApr 2, 2019
PublishedApr 2, 2019
Warriors Trained1853
Total Skips159
Total Code Submissions2155
Total Times Completed344
Racket Completions12
Python Completions162
Clojure Completions11
Ruby Completions19
JavaScript Completions108
Scala Completions10
F# Completions7
C# Completions17
VB Completions7
Java Completions14
Kotlin Completions14
Total Stars34
% of votes with a positive feedback rating80% of 92
Total "Very Satisfied" Votes64
Total "Somewhat Satisfied" Votes19
Total "Not Satisfied" Votes9
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • g964 Avatar
  • Blind4Basics Avatar
  • hobovsky Avatar
Ad