-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivisibility_by_seven.pas
More file actions
55 lines (48 loc) · 1.07 KB
/
Copy pathdivisibility_by_seven.pas
File metadata and controls
55 lines (48 loc) · 1.07 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
{
7 kyu
A Rule of Divisibility by 7
https://www.codewars.com/kata/55e6f5e58f7817808e00002e
}
program divisibility_by_seven;
{$mode objfpc}{$H+}
uses
SysUtils,
divisibility_by_seven_unit;
type
TSeven = array [0..1] of int64;
function ArrayToString(A: TSeven): string;
var
i: int64;
res: string;
begin
res := '[';
for i := 0 to High(A) do
res += IntToStr(A[i]) + ', ';
if (res = '[') then
Result := '[]'
else
Result := Copy(res, 1, Length(res) - 2) + ']';
end;
procedure DoTest(m: int64; Expected: string);
var
Actual: string;
begin
Actual := ArrayToString(Seven(m));
writeln('m : ', m);
writeln('Expected: ', Expected);
writeln('Actual : ', Actual);
if Expected = Actual then
writeln('-> OK', LineEnding)
else
writeln('-> FAIL', LineEnding);
end;
begin
DoTest(0, '[0, 0]');
DoTest(99, '[99, 0]');
DoTest(105, '[0, 1]');
DoTest(112, '[7, 1]');
DoTest(1021, '[10, 2]');
DoTest(770784, '[63, 4]');
DoTest(477557101, '[28, 7]');
DoTest(477557102, '[47, 7]');
end.