aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-274/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-274/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-274/luca-ferrari/pljava/pom.xml72
-rw-r--r--challenge-274/luca-ferrari/raku/ch-1.raku35
-rw-r--r--challenge-274/luca-ferrari/raku/ch-2.raku55
5 files changed, 92 insertions, 72 deletions
diff --git a/challenge-274/luca-ferrari/blog-1.txt b/challenge-274/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..53df09edbb
--- /dev/null
+++ b/challenge-274/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/19/PerlWeeklyChallenge274.html#task1
diff --git a/challenge-274/luca-ferrari/blog-2.txt b/challenge-274/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..0b5d75b2eb
--- /dev/null
+++ b/challenge-274/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2024/06/19/PerlWeeklyChallenge274.html#task2
diff --git a/challenge-274/luca-ferrari/pljava/pom.xml b/challenge-274/luca-ferrari/pljava/pom.xml
deleted file mode 100644
index ade9b2efb4..0000000000
--- a/challenge-274/luca-ferrari/pljava/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>PWC</groupId>
- <artifactId>
- PWC273
- </artifactId>
- <version>
- 1
- </version>
-
- <name>Perl Weekly Challenge 273 with package PWC273</name>
- <description>Implementation of the tasks in PL/Java for PWC 273</description>
-
- <properties>
- <project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>pljava-api</artifactId>
- <version>1.6.6</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
- <configuration>
- <release>9</release>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <archive>
- <manifest>
- <!-- This identifies and version-stamps the jar.
- Not essential, but easy and useful. -->
- <addDefaultImplementationEntries>
- true
- </addDefaultImplementationEntries>
- </manifest>
-
- <manifestSections>
- <!-- This identifies a file in the jar named
- pljava.ddr as an SQLJDeploymentDescriptor. -->
- <manifestSection>
- <name>pljava.ddr</name>
- <manifestEntries>
- <SQLJDeploymentDescriptor>
- true
- </SQLJDeploymentDescriptor>
- </manifestEntries>
- </manifestSection>
- </manifestSections>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/challenge-274/luca-ferrari/raku/ch-1.raku b/challenge-274/luca-ferrari/raku/ch-1.raku
new file mode 100644
index 0000000000..d88b5a81a8
--- /dev/null
+++ b/challenge-274/luca-ferrari/raku/ch-1.raku
@@ -0,0 +1,35 @@
+#!raku
+
+#
+# Perl Weekly Challenge 274
+# Task 1
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-274>
+#
+
+sub MAIN( Str $sentence ) {
+# 1) If a word begins with a vowel ("a", "e", "i", "o", "u"), append
+# "ma" to the end of the word.
+# 2) If a word begins with consonant i.e. not a vowel, remove first
+# letter and append it to the end then add "ma".
+# 3) Add letter "a" to the end of first word in the sentence, "aa" to
+ # the second word, etc etc.
+
+ my $suffix = 'a';
+ my @words;
+ for $sentence.split( / \s+ / ) -> $word is copy {
+ $word ~~ / ^ ( <[a..zA..Z]> ) .* $ /;
+ my $initial = $/[ 0 ].Str;
+ if ( $initial.lc !~~ / <[aeiou]> / ) {
+ $word = $word.comb[ 1 .. * ].join ~ $initial;
+ }
+
+ $word ~= 'ma';
+ $word ~= $suffix;
+ $suffix ~= 'a';
+ @words.push: $word;
+ }
+
+ @words.join( ' ' ).say;
+
+}
diff --git a/challenge-274/luca-ferrari/raku/ch-2.raku b/challenge-274/luca-ferrari/raku/ch-2.raku
new file mode 100644
index 0000000000..70e0d160ad
--- /dev/null
+++ b/challenge-274/luca-ferrari/raku/ch-2.raku
@@ -0,0 +1,55 @@
+#!raku
+
+#
+# Perl Weekly Challenge 274
+# Task 2
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-274>
+#
+
+sub MAIN() {
+
+ my @routes = [ [12, 11, 41], [15, 5, 35] ];
+
+ my @times;
+ my $route = 0;
+
+ my %timetable;
+
+ my $preferred = False;
+ for @routes -> $current_route {
+
+ my ( $interval, $start_at, $time ) = $current_route;
+
+ my $arrive_at = $start_at + $time;
+ my $previous_bus_start_at = 0;
+
+ while ( $arrive_at < 120 ) {
+ for 0 .. 59 -> $minute {
+ last if $minute > $start_at;
+ next if $minute < $previous_bus_start_at;
+ %timetable{ $minute }.push: { start => $start_at, arrive => $arrive_at, route => $current_route.Str, preferred => $preferred };
+ }
+
+ $previous_bus_start_at = $start_at;
+ $start_at += $interval;
+ $arrive_at = $start_at + $time;
+ }
+
+ $preferred = True;
+ }
+
+ my @skip;
+ for %timetable.keys.sort( * <=> * ) -> $minute {
+ my @bus = %timetable{ $minute }.Array;
+ next if ( @bus.elems == 1 && ! @bus[ 0 ]<preferred> );
+
+ @skip.push: $minute if ( @bus.sort( { $^a<arrive> <=> $^b<arrive> } )[ 0 ]<preferred> );
+ }
+
+
+ @skip.say;
+
+
+
+}