aboutsummaryrefslogtreecommitdiff
path: root/challenge-128
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-10-26 15:36:54 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2021-10-26 15:36:54 +0100
commit55a89f177a2f20adb1d900fbddfa537418daeec9 (patch)
tree128018cb827613d35eb150e51ff7eb1e48da619c /challenge-128
parentadefe0af37e086496274f65b00db423e0a91f9fe (diff)
downloadperlweeklychallenge-club-55a89f177a2f20adb1d900fbddfa537418daeec9.tar.gz
perlweeklychallenge-club-55a89f177a2f20adb1d900fbddfa537418daeec9.tar.bz2
perlweeklychallenge-club-55a89f177a2f20adb1d900fbddfa537418daeec9.zip
Whitespace
Diffstat (limited to 'challenge-128')
-rw-r--r--challenge-128/paulo-custodio/perl/ch-2.pl68
-rw-r--r--challenge-128/paulo-custodio/python/ch-2.py4
-rw-r--r--challenge-128/paulo-custodio/t/test-2.yaml4
3 files changed, 38 insertions, 38 deletions
diff --git a/challenge-128/paulo-custodio/perl/ch-2.pl b/challenge-128/paulo-custodio/perl/ch-2.pl
index dccbdc1cc4..74e75713e1 100644
--- a/challenge-128/paulo-custodio/perl/ch-2.pl
+++ b/challenge-128/paulo-custodio/perl/ch-2.pl
@@ -33,50 +33,50 @@ my @platforms = allocate_platforms(@stops);
say scalar(@platforms);
sub parse_arrivals_departures {
- my @arrivals = parse_times();
- my @departures = parse_times();
-
- my @stops;
- while (@arrivals && @departures) {
- push @stops, [shift @arrivals, shift @departures];
- }
- return @stops;
+ my @arrivals = parse_times();
+ my @departures = parse_times();
+
+ my @stops;
+ while (@arrivals && @departures) {
+ push @stops, [shift @arrivals, shift @departures];
+ }
+ return @stops;
}
sub parse_times {
- my @times = map {Time::Piece->strptime($_, "%H:%M")->epoch}
- split(' ', scalar(<>));
+ my @times = map {Time::Piece->strptime($_, "%H:%M")->epoch}
+ split(' ', scalar(<>));
}
sub allocate_platforms {
- my(@stops) = @_;
- my @platforms;
-
- for my $stop (@stops) {
- allocate_stop(\@platforms, @$stop);
- }
- return @platforms;
+ my(@stops) = @_;
+ my @platforms;
+
+ for my $stop (@stops) {
+ allocate_stop(\@platforms, @$stop);
+ }
+ return @platforms;
}
sub allocate_stop {
- my($platforms, $s, $e) = @_;
- for my $p (0 .. $#$platforms) {
- if (platform_free($platforms->[$p], $s, $e)) {
- push @{$platforms->[$p]}, [$s, $e];
- return;
- }
- }
- push @$platforms, [[$s, $e]];
+ my($platforms, $s, $e) = @_;
+ for my $p (0 .. $#$platforms) {
+ if (platform_free($platforms->[$p], $s, $e)) {
+ push @{$platforms->[$p]}, [$s, $e];
+ return;
+ }
+ }
+ push @$platforms, [[$s, $e]];
}
sub platform_free {
- my($platform, $s, $e) = @_;
- for my $stop (@$platform) {
- if (($s >= $stop->[0] && $s < $stop->[1]) ||
- ($e >= $stop->[0] && $e < $stop->[1]) ||
- ($s < $stop->[0] && $e >= $stop->[1])) {
- return 0;
- }
- }
- return 1;
+ my($platform, $s, $e) = @_;
+ for my $stop (@$platform) {
+ if (($s >= $stop->[0] && $s < $stop->[1]) ||
+ ($e >= $stop->[0] && $e < $stop->[1]) ||
+ ($s < $stop->[0] && $e >= $stop->[1])) {
+ return 0;
+ }
+ }
+ return 1;
}
diff --git a/challenge-128/paulo-custodio/python/ch-2.py b/challenge-128/paulo-custodio/python/ch-2.py
index ce50be00a6..d7f73d821a 100644
--- a/challenge-128/paulo-custodio/python/ch-2.py
+++ b/challenge-128/paulo-custodio/python/ch-2.py
@@ -42,7 +42,7 @@ def parse_arrivals_departures():
def allocate_platforms(stops):
platforms = []
-
+
def platform_free(platform, s, e):
for stop in platform:
if (s >= stop[0] and s < stop[1]) or \
@@ -57,7 +57,7 @@ def allocate_platforms(stops):
platform.append([s, e])
return
platforms.append([[s, e]])
-
+
for stop in stops:
allocate_stop(stop[0], stop[1])
return platforms
diff --git a/challenge-128/paulo-custodio/t/test-2.yaml b/challenge-128/paulo-custodio/t/test-2.yaml
index adfe949621..b1be9371b6 100644
--- a/challenge-128/paulo-custodio/t/test-2.yaml
+++ b/challenge-128/paulo-custodio/t/test-2.yaml
@@ -1,13 +1,13 @@
- setup:
cleanup:
- args:
+ args:
input: |
11:20 14:30
11:50 15:00
output: 1
- setup:
cleanup:
- args:
+ args:
input: |
10:20 11:00 11:10 12:20 16:20 19:00
10:30 13:20 12:40 12:50 20:20 21:20