-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbouncing_balls.pas
More file actions
42 lines (37 loc) · 930 Bytes
/
bouncing_balls.pas
File metadata and controls
42 lines (37 loc) · 930 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
6 kyu
Bouncing Balls
https://www.codewars.com/kata/5544c7a5cb454edb3c000047
}
program bouncing_balls;
{$mode objfpc}{$H+}
uses
SysUtils,
bouncing_balls_unit;
procedure DoTest(h, bounce, window: double; Expected: int64);
var
Actual: int64;
begin
Actual := BouncingBall(h, bounce, window);
writeln('h : ', Format('%.7g', [h]));
writeln('bounce : ', Format('%.7g', [bounce]));
writeln('window : ', Format('%.7g', [window]));
writeln('Expected: ', Expected);
writeln('Actual : ', Actual);
if Expected = Actual then
writeln('-> OK', LineEnding)
else
writeln('-> FAIL', LineEnding);
end;
begin
DoTest(3, 0.66, 1.5, 3);
DoTest(3, 0, 1.5, -1);
DoTest(3, 1, 1.5, -1);
DoTest(0, 1, 1.5, -1);
DoTest(3, 1, 4.5, -1);
DoTest(30, 0.66, 1.5, 15);
DoTest(2, 0.5, 1, 1);
DoTest(10, 0.6, 10, -1);
DoTest(40, 1, 10, -1);
DoTest(-5, 0.66, 1.5, -1);
end.