You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The task is to write an Object Pascal program which reads the file, calculates the min, mean, and max temperature value per weather station, and emits the results on `STDOUT` like this (i.e., sorted alphabetically by station name, and the result values per station in the format `<min>/<mean>/<max>`, rounded to one fractional digit towards positive infinity with both `17.01` and `17.05` being rounded to `17.1`, with the decimal separator being a period `.`):
36
+
The task is to write an Object Pascal program which reads the file, calculates the min, mean, and max temperature value per weather station, and emits the results on `STDOUT` like this (i.e., sorted alphabetically by station name, and the result values per station in the format `<min>/<mean>/<max>`, rounded to one fractional digit, with the decimal separator being a period `.`, and for that you can chose one of the options presented in the [Rounding Section](#rounding) or implement your own that is consistent with the options provided.):
@@ -68,53 +70,11 @@ Submit your implementation and become part of the leader board!
68
70
69
71
## Rounding
70
72
71
-
While I recognize that Székely's rounding code was a good effort, it was not simple and made a lot of people doubt it was even correct for negative temperatures.\
72
-
In a discussion with [Mr. Packman](https://pack.ac/) themselves, we came up with a simpler solution. They even added some _Unit Testing_:D.
73
-
74
-
This will be the official way to round the output values, so pick your poison:
75
-
```pas
76
-
function RoundEx(x: Double): Double; inline;
77
-
begin
78
-
Result := Ceil(x * 10) / 10;
79
-
end;
80
-
81
-
function RoundExInteger(x: Double): Integer; inline;
82
-
begin
83
-
Result := Ceil(x * 10);
84
-
end;
85
-
86
-
function RoundExString(x: Double): String; inline;
87
-
var
88
-
V, Q, R: Integer;
89
-
begin
90
-
V := RoundExInteger(x);
91
-
if V < 0 then
92
-
begin
93
-
Result := '-';
94
-
V := -V;
95
-
end
96
-
else
97
-
Result := '';
98
-
Q := V div 10;
99
-
R := V - (Q * 10);
100
-
Result := IntToStr(Q) + '.' + IntToStr(R);
101
-
end;
102
-
103
-
procedure Test;
104
-
var
105
-
F: Double;
106
-
begin
107
-
for F in [10.01, 10.04, -10.01, -10.0, 0, -0, -0.01] do
| 4 | 1:23.684 | lazarus-3.0, fpc-3.2.2 | Richard Lawson | Using a single thread ||
161
+
| 5 | 5:2.512 | lazarus-3.0, fpc-3.2.2 | Iwan Kelaiah | Using a single thread ||
162
+
| 6 | 7:54.606 | delphi 12.1 | David Cornelius | Using 1 threads **(failed hash)**||
163
+
| 7 | 10:55.724 | delphi 12.1 | Brian Fire | Using 1 threads ||
202
164
203
165
> **NOTE**
204
166
>
@@ -230,7 +192,8 @@ I'd like to thank [@mobius](https://github.com/mobius1qwe) for taking the time t
230
192
I'd like to thank [@dtpfl](https://github.com/dtpfl) for his invaluable work on maintaining the `README.md` file up to date with everything.\
231
193
I'd like to thank Székely Balázs for providing many patches to make everything compliant with the original challenge.\
232
194
I'd like to thank [@corneliusdavid](https://github.com/corneliusdavid) for giving some of the information files a once over and making things more legible and clear.\
233
-
I'd like to thank Mr. **Pack**man, aka O, for clearing the fog around the rounding issues.
195
+
I'd like to thank Mr. **Pack**man, aka O, for clearing the fog around the rounding issues.\
196
+
I'd like to thank [Georges](https://github.com/georges-hatem) for providing us with the Delphi version of baseline.
234
197
235
198
## Links
236
199
The original repository: https://github.com/gunnarmorling/1brc\
0 commit comments