From 19ecc1107e225225f0e2306bc4fd403ba40af81f Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Tue, 14 Oct 2025 10:48:22 +0200 Subject: Add Task 332 solutions for lubos-kolouch --- challenge-332/lubos-kolouch/perl/ch-1.pl | 47 ++++++++++++++++++++++++++++ challenge-332/lubos-kolouch/perl/ch-2.pl | 50 ++++++++++++++++++++++++++++++ challenge-332/lubos-kolouch/python/ch-1.py | 49 +++++++++++++++++++++++++++++ challenge-332/lubos-kolouch/python/ch-2.py | 44 ++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 challenge-332/lubos-kolouch/perl/ch-1.pl create mode 100644 challenge-332/lubos-kolouch/perl/ch-2.pl create mode 100644 challenge-332/lubos-kolouch/python/ch-1.py create mode 100644 challenge-332/lubos-kolouch/python/ch-2.py diff --git a/challenge-332/lubos-kolouch/perl/ch-1.pl b/challenge-332/lubos-kolouch/perl/ch-1.pl new file mode 100644 index 0000000000..f3ffb1fec2 --- /dev/null +++ b/challenge-332/lubos-kolouch/perl/ch-1.pl @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +use v5.38; +use strict; +use warnings; +use feature 'signatures'; +no warnings 'experimental::signatures'; + +use Type::Params qw(compile); +use Types::Standard qw(StrMatch); +use Test::More; + +=pod + +=head1 NAME + +ch-1 - Binary Date converter + +=head1 SYNOPSIS + + perl ch-1.pl + +=head1 DESCRIPTION + +The script implements Task 1 (Binary Date) from The Weekly Challenge #332. +It exposes L that validates an ISO-8601 date string +and returns the corresponding binary representation for the year, +month, and day components joined with hyphens. + +=cut + +my $ISO_DATE = StrMatch [qr/\A\d{4}-\d{2}-\d{2}\z/]; +my $date_check = compile($ISO_DATE); + +## no critic (Subroutines::ProhibitSubroutinePrototypes) +sub binary_date ($date) { + ($date) = $date_check->($date); + my ( $year, $month, $day ) = split /-/xms, $date; + return join q{-}, map { sprintf '%b', $_ + 0 } ( $year, $month, $day ); +} +## use critic + +# Unit tests (Examples provided by the challenge) +is binary_date('2025-07-26'), '11111101001-111-11010', 'Example 1'; +is binary_date('2000-02-02'), '11111010000-10-10', 'Example 2'; +is binary_date('2024-12-31'), '11111101000-1100-11111', 'Example 3'; + +done_testing(); diff --git a/challenge-332/lubos-kolouch/perl/ch-2.pl b/challenge-332/lubos-kolouch/perl/ch-2.pl new file mode 100644 index 0000000000..1db92c3ed6 --- /dev/null +++ b/challenge-332/lubos-kolouch/perl/ch-2.pl @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +use v5.38; +use strict; +use warnings; +use feature 'signatures'; +no warnings 'experimental::signatures'; + +use List::Util qw(all); +use Type::Params qw(compile); +use Types::Standard qw(StrMatch); +use Test::More; + +=pod + +=head1 NAME + +ch-2 - Odd Letters frequency checker + +=head1 SYNOPSIS + + perl ch-2.pl + +=head1 DESCRIPTION + +The script implements Task 2 (Odd Letters) from The Weekly Challenge #332. +It provides L that accepts an ASCII alphabetic string and +returns a boolean indicating whether every distinct letter occurs an odd +number of times. + +=cut + +my $AlphaWord = StrMatch [qr/\A[a-zA-Z]+\z/]; +my $string_check = compile($AlphaWord); + +## no critic (Subroutines::ProhibitSubroutinePrototypes) +sub odd_letters ($word) { + ($word) = $string_check->($word); + my %tally; + $tally{$_}++ for split //, lc $word; + my $all_odd = all { $_ % 2 == 1 } values %tally; + return $all_odd ? 1 : 0; +} +## use critic + +# Unit tests (Examples provided by the challenge) +ok !odd_letters('weekly'), 'Example 1'; +ok odd_letters('perl'), 'Example 2'; +ok !odd_letters('challenge'), 'Example 3'; + +done_testing(); diff --git a/challenge-332/lubos-kolouch/python/ch-1.py b/challenge-332/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..3d8a96fdae --- /dev/null +++ b/challenge-332/lubos-kolouch/python/ch-1.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +"""Task 1 - Binary Date converter for The Weekly Challenge #332.""" +from __future__ import annotations + +import re +import unittest +from typing import Final + +DATE_PATTERN: Final[re.Pattern[str]] = re.compile(r"^\d{4}-\d{2}-\d{2}$") + + +def binary_date(date: str) -> str: + """ + Return the binary representation of the year, month, and day components. + + Args: + date: An ISO-8601 date string in the form YYYY-MM-DD. + + Returns: + The converted date with each component rendered in base 2. + + Raises: + ValueError: If *date* is not a well-formed ISO-8601 date. + """ + if DATE_PATTERN.fullmatch(date) is None: + msg = f"Invalid ISO date: {date!r}" + raise ValueError(msg) + year_text, month_text, day_text = date.split("-") + year = int(year_text, 10) + month = int(month_text, 10) + day = int(day_text, 10) + return f"{year:b}-{month:b}-{day:b}" + + +class BinaryDateExamples(unittest.TestCase): + """Unit tests using the official examples.""" + + def test_example_1(self) -> None: + self.assertEqual(binary_date("2025-07-26"), "11111101001-111-11010") + + def test_example_2(self) -> None: + self.assertEqual(binary_date("2000-02-02"), "11111010000-10-10") + + def test_example_3(self) -> None: + self.assertEqual(binary_date("2024-12-31"), "11111101000-1100-11111") + + +if __name__ == "__main__": + unittest.main() diff --git a/challenge-332/lubos-kolouch/python/ch-2.py b/challenge-332/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..c37c90eeea --- /dev/null +++ b/challenge-332/lubos-kolouch/python/ch-2.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Task 2 - Odd Letters checker for The Weekly Challenge #332.""" +from __future__ import annotations + +import unittest +from collections import Counter + + +def has_odd_letter_counts(text: str) -> bool: + """ + Return True if every distinct letter in *text* appears an odd number of times. + + Args: + text: A string containing only alphabetic characters. + + Returns: + True when each distinct letter appears an odd number of times, otherwise False. + + Raises: + ValueError: If *text* contains non-alphabetic characters or is empty. + """ + if not text.isalpha(): + msg = f"Input must contain only alphabetic characters: {text!r}" + raise ValueError(msg) + normalized = text.lower() + counts = Counter(normalized) + return all(value % 2 == 1 for value in counts.values()) + + +class OddLettersExamples(unittest.TestCase): + """Unit tests derived from the supplied examples.""" + + def test_example_1(self) -> None: + self.assertFalse(has_odd_letter_counts("weekly")) + + def test_example_2(self) -> None: + self.assertTrue(has_odd_letter_counts("perl")) + + def test_example_3(self) -> None: + self.assertFalse(has_odd_letter_counts("challenge")) + + +if __name__ == "__main__": + unittest.main() -- cgit From 0ca51e9de47a25326fe22e2121879ac3aea64dec Mon Sep 17 00:00:00 2001 From: wanderdoc Date: Mon, 20 Oct 2025 20:15:28 +0200 Subject: Create ch-1.pl --- challenge-344/wanderdoc/perl/ch-1.pl | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 challenge-344/wanderdoc/perl/ch-1.pl diff --git a/challenge-344/wanderdoc/perl/ch-1.pl b/challenge-344/wanderdoc/perl/ch-1.pl new file mode 100644 index 0000000000..4b3119dd5c --- /dev/null +++ b/challenge-344/wanderdoc/perl/ch-1.pl @@ -0,0 +1,56 @@ +#!perl +use strict; +use warnings FATAL => qw(all); + +=prompt +You are given an array of integers, @ints and an integer, $x. + +Write a script to add $x to the integer in the array-form. + + The array form of an integer is a digit-by-digit representation stored as an array, where the most significant digit is at the 0th index. + +Example 1 + +Input: @ints = (1, 2, 3, 4), $x = 12 +Output: (1, 2, 4, 6) + +Example 2 + +Input: @ints = (2, 7, 4), $x = 181 +Output: (4, 5, 5) + +Example 3 + +Input: @ints = (9, 9, 9), $x = 1 +Output: (1, 0, 0, 0) + +Example 4 + +Input: @ints = (1, 0, 0, 0, 0), $x = 9999 +Output: (1, 9, 9, 9, 9) + +Example 5 + +Input: @ints = (0), $x = 1000 +Output: (1, 0, 0, 0) +=cut + + + + +use Test2::V0 -no_srand => 1; +is([array_form([1, 2, 3, 4], 12)], [1, 2, 4, 6], 'Example 1'); +is([array_form([2, 7, 4], 181)], [4, 5, 5], 'Example 2'); +is([array_form([9, 9, 9], 1)], [1, 0, 0, 0], 'Example 3'); +is([array_form([1, 0, 0, 0, 0], 9999)], [1, 9, 9, 9, 9], 'Example 4'); +is([array_form([0], 1000)], [1, 0, 0, 0], 'Example 5'); +done_testing(); + +sub array_form +{ + my ($ints, $x) = @_; + my $int_str = join('', @$ints); + my $result = $int_str + $x; + return split(//, $result); + +} -- cgit From 9d785a9008b9ea71b5ac926fcebbb1b6c97fab75 Mon Sep 17 00:00:00 2001 From: wanderdoc Date: Mon, 20 Oct 2025 20:16:17 +0200 Subject: Create ch-2.pl --- challenge-344/wanderdoc/perl/ch-2.pl | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 challenge-344/wanderdoc/perl/ch-2.pl diff --git a/challenge-344/wanderdoc/perl/ch-2.pl b/challenge-344/wanderdoc/perl/ch-2.pl new file mode 100644 index 0000000000..ae252b0f3e --- /dev/null +++ b/challenge-344/wanderdoc/perl/ch-2.pl @@ -0,0 +1,114 @@ +#!perl +use strict; +use warnings FATAL => qw(all); + +=prompt +You are given two list: @source and @target. +Write a script to see if you can build the exact @target by putting these smaller lists from @source together in some order. You cannot break apart or change the order inside any of the smaller lists in @source. + +Example 1 +Input: @source = ([2,3], [1], [4]) + @target = (1, 2, 3, 4) +Output: true + +Use in the order: [1], [2,3], [4] + +Example 2 + +Input: @source = ([1,3], [2,4]) + @target = (1, 2, 3, 4) +Output: false + +Example 3 + +Input: @source = ([9,1], [5,8], [2]) + @target = (5, 8, 2, 9, 1) +Output: true + +Use in the order: [5,8], [2], [9,1] + +Example 4 + +Input: @source = ([1], [3]) + @target = (1, 2, 3) +Output: false + +Missing number: 2 + +Example 5 + +Input: @source = ([7,4,6]) + @target = (7, 4, 6) +Output: true + +Use in the order: [7, 4, 6] +=cut + + + + + +use constant { true => 1, false => 0 }; +use Test2::V0 -no_srand => 1; +is(array_formation([[2,3], [1], [4]], [1, 2, 3, 4]), true, 'Example 1'); +is(array_formation([[1,3], [2,4]], [1, 2, 3, 4]), false, 'Example 2'); +is(array_formation([[9,1], [5,8], [2]], [5, 8, 2, 9, 1]), true, 'Example 3'); +is(array_formation([[1], [3]], [1, 2, 3]), false, 'Example 4'); +is(array_formation([[7,4,6]], [7, 4, 6]), true, 'Example 5'); +done_testing(); + +sub array_formation +{ + my ($source, $target) = @_; + my @source_str = map {join('', @$_)} @$source; + my $target_str = join('', @$target); + my $iterator = permutations_iterator(@source_str); + while (my $permutation = $iterator->()) + { + if ( join('', @$permutation) eq $target_str ) + { + return true; + } + } + return false; +} + + + + +sub permutations_iterator +{ + my @array = @_; + + my @stack = ([]); + my @remaining = (\@array); + + return sub + { + while (@stack) + { + # Get the current state + my $partial = pop @stack; + my $rest = pop @remaining; + + if (@$rest == 0) + { + # Complete permutation + return $partial; + } + else + { + for my $i ( reverse 0 .. $#$rest) + { + my @new_partial = (@$partial, $rest->[$i]); + my @new_rest = @$rest; + splice(@new_rest, $i, 1); + push @stack, \@new_partial; + push @remaining, \@new_rest; + } + } + } + # If the stack is empty, we're done + return undef; + }; +} -- cgit From b82c2e1f7cbba73c9a692b996be8e1058a81b19e Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 20 Oct 2025 19:28:06 +0100 Subject: - Added solutions by Conor Hoekstra. - Added solutions by Wanderdoc. --- challenge-344/conor-hoekstra/bqn/ch-1.bqn | 15 +++++++++++++++ challenge-344/conor-hoekstra/bqn/ch-2.bqn | 14 ++++++++++++++ challenge-344/conor-hoekstra/ch-1.bqn | 15 --------------- challenge-344/conor-hoekstra/ch-2.bqn | 14 -------------- stats/pwc-current.json | 17 ++++++++++++++++- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 6 +++--- stats/pwc-language-breakdown-summary.json | 4 ++-- stats/pwc-leaders.json | 26 +++++++++++++------------- stats/pwc-summary-1-30.json | 2 +- stats/pwc-summary-121-150.json | 2 +- stats/pwc-summary-151-180.json | 2 +- stats/pwc-summary-181-210.json | 2 +- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 2 +- stats/pwc-summary-301-330.json | 4 ++-- stats/pwc-summary-31-60.json | 2 +- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 4 ++-- stats/pwc-yearly-language-summary.json | 6 +++--- 27 files changed, 86 insertions(+), 71 deletions(-) create mode 100644 challenge-344/conor-hoekstra/bqn/ch-1.bqn create mode 100644 challenge-344/conor-hoekstra/bqn/ch-2.bqn delete mode 100644 challenge-344/conor-hoekstra/ch-1.bqn delete mode 100644 challenge-344/conor-hoekstra/ch-2.bqn diff --git a/challenge-344/conor-hoekstra/bqn/ch-1.bqn b/challenge-344/conor-hoekstra/bqn/ch-1.bqn new file mode 100644 index 0000000000..89d9c12c46 --- /dev/null +++ b/challenge-344/conor-hoekstra/bqn/ch-1.bqn @@ -0,0 +1,15 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/344-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +b ⇐ •Import "/home/cph/bqn-code/lib/binary.bqn" + +FromDigits ← { +´𝕩×⌽10⋆↕≠𝕩 } +ArrayFormCompute ← b.Digits+⟜FromDigits + +# Tests +u.UnitTest ( 12 ArrayFormCompute ⟨1, 2, 3, 4⟩) ≡ ⟨1, 2, 4, 6⟩ +u.UnitTest ( 181 ArrayFormCompute ⟨2, 7, 4⟩) ≡ ⟨4, 5, 5⟩ +u.UnitTest ( 1 ArrayFormCompute ⟨9, 9, 9⟩) ≡ ⟨1, 0, 0, 0⟩ +u.UnitTest (9999 ArrayFormCompute ⟨1, 0, 0, 0, 0⟩) ≡ ⟨1, 9, 9, 9, 9⟩ +u.UnitTest (1000 ArrayFormCompute ⟨0⟩) ≡ ⟨1, 0, 0, 0⟩ diff --git a/challenge-344/conor-hoekstra/bqn/ch-2.bqn b/challenge-344/conor-hoekstra/bqn/ch-2.bqn new file mode 100644 index 0000000000..f104129e4f --- /dev/null +++ b/challenge-344/conor-hoekstra/bqn/ch-2.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/344-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn" + +ArrayFormation ← { ∨´𝕨⊸≡∘∾˘fn.Permutations𝕩 } + +# Tests +u.UnitTest ( ⟨1, 2, 3, 4⟩ ArrayFormation ⟨⟨2,3⟩, ⟨1⟩, ⟨4⟩⟩) ≡ 1 +u.UnitTest ( ⟨1, 2, 3, 4⟩ ArrayFormation ⟨⟨1,3⟩, ⟨2,4⟩⟩) ≡ 0 +u.UnitTest (⟨5, 8, 2, 9, 1⟩ ArrayFormation ⟨⟨9,1⟩, ⟨5,8⟩, ⟨2⟩⟩) ≡ 1 +u.UnitTest ( ⟨1, 2, 3⟩ ArrayFormation ⟨⟨1⟩, ⟨3⟩⟩) ≡ 0 +u.UnitTest ( ⟨7, 4, 6⟩ ArrayFormation ⟨⟨7,4,6⟩⟩) ≡ 1 diff --git a/challenge-344/conor-hoekstra/ch-1.bqn b/challenge-344/conor-hoekstra/ch-1.bqn deleted file mode 100644 index 89d9c12c46..0000000000 --- a/challenge-344/conor-hoekstra/ch-1.bqn +++ /dev/null @@ -1,15 +0,0 @@ -# For up to date code: -# https://github.com/codereport/bqn-code/blob/main/pwc/344-1.bqn - -u ⇐ •Import "/home/cph/bqn-test/test.bqn" -b ⇐ •Import "/home/cph/bqn-code/lib/binary.bqn" - -FromDigits ← { +´𝕩×⌽10⋆↕≠𝕩 } -ArrayFormCompute ← b.Digits+⟜FromDigits - -# Tests -u.UnitTest ( 12 ArrayFormCompute ⟨1, 2, 3, 4⟩) ≡ ⟨1, 2, 4, 6⟩ -u.UnitTest ( 181 ArrayFormCompute ⟨2, 7, 4⟩) ≡ ⟨4, 5, 5⟩ -u.UnitTest ( 1 ArrayFormCompute ⟨9, 9, 9⟩) ≡ ⟨1, 0, 0, 0⟩ -u.UnitTest (9999 ArrayFormCompute ⟨1, 0, 0, 0, 0⟩) ≡ ⟨1, 9, 9, 9, 9⟩ -u.UnitTest (1000 ArrayFormCompute ⟨0⟩) ≡ ⟨1, 0, 0, 0⟩ diff --git a/challenge-344/conor-hoekstra/ch-2.bqn b/challenge-344/conor-hoekstra/ch-2.bqn deleted file mode 100644 index f104129e4f..0000000000 --- a/challenge-344/conor-hoekstra/ch-2.bqn +++ /dev/null @@ -1,14 +0,0 @@ -# For up to date code: -# https://github.com/codereport/bqn-code/blob/main/pwc/344-2.bqn - -u ⇐ •Import "/home/cph/bqn-test/test.bqn" -fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn" - -ArrayFormation ← { ∨´𝕨⊸≡∘∾˘fn.Permutations𝕩 } - -# Tests -u.UnitTest ( ⟨1, 2, 3, 4⟩ ArrayFormation ⟨⟨2,3⟩, ⟨1⟩, ⟨4⟩⟩) ≡ 1 -u.UnitTest ( ⟨1, 2, 3, 4⟩ ArrayFormation ⟨⟨1,3⟩, ⟨2,4⟩⟩) ≡ 0 -u.UnitTest (⟨5, 8, 2, 9, 1⟩ ArrayFormation ⟨⟨9,1⟩, ⟨5,8⟩, ⟨2⟩⟩) ≡ 1 -u.UnitTest ( ⟨1, 2, 3⟩ ArrayFormation ⟨⟨1⟩, ⟨3⟩⟩) ≡ 0 -u.UnitTest ( ⟨7, 4, 6⟩ ArrayFormation ⟨⟨7,4,6⟩⟩) ≡ 1 diff --git a/stats/pwc-current.json b/stats/pwc-current.json index dc2b066842..d8dbd11042 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -115,6 +115,16 @@ ], "id" : "Vinod Kumar K", "name" : "Vinod Kumar K" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Wanderdoc", + "name" : "Wanderdoc" } ] }, @@ -183,13 +193,18 @@ "drilldown" : "Vinod Kumar K", "name" : "Vinod Kumar K", "y" : 2 + }, + { + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc", + "y" : 2 } ], "name" : "The Weekly Challenge - 344" } ], "subtitle" : { - "text" : "[Champions: 10] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 11] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge - 344" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 48adda9968..86f224d483 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 05e69b1f07..58320734af 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index e31758a8b8..2e27da8893 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 749cbb1dbb..c18922eb89 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index cd81d3ab54..98e98e27c2 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index 090d28b9eb..af0aeb97e9 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index f3596c9535..f279bf0f0c 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 13 + 15 ], [ "Raku", @@ -781,7 +781,7 @@ { "drilldown" : "344", "name" : "344", - "y" : 23 + "y" : 25 }, { "drilldown" : "343", @@ -993,7 +993,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 35968e7229..3fd1b2124a 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,7 +10,7 @@ "data" : [ [ "Perl", - 17712 + 17714 ], [ "Raku", @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 792788e182..a9cad95856 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -497,21 +497,21 @@ { "data" : [ [ - "Raku", - 352 + "Perl", + 354 ], [ "Blog", 2 ] ], - "id" : "Robert Ransbottom", - "name" : "Robert Ransbottom" + "id" : "Wanderdoc", + "name" : "Wanderdoc" }, { "data" : [ [ - "Perl", + "Raku", 352 ], [ @@ -519,8 +519,8 @@ 2 ] ], - "id" : "Wanderdoc", - "name" : "Wanderdoc" + "id" : "Robert Ransbottom", + "name" : "Robert Ransbottom" }, { "data" : [ @@ -950,13 +950,13 @@ "y" : 736 }, { - "drilldown" : "Robert Ransbottom", - "name" : "32: Robert Ransbottom", - "y" : 708 + "drilldown" : "Wanderdoc", + "name" : "32: Wanderdoc", + "y" : 712 }, { - "drilldown" : "Wanderdoc", - "name" : "33: Wanderdoc", + "drilldown" : "Robert Ransbottom", + "name" : "33: Robert Ransbottom", "y" : 708 }, { @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index f596baaa1c..392e57ad98 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index 5980b681f1..4d0e0b5433 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index cc18d866ce..2cccb50825 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-181-210.json b/stats/pwc-summary-181-210.json index 07ab34b03d..10ffbfaa7a 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-211-240.json b/stats/pwc-summary-211-240.json index d5356cc89d..4879d24bbe 100644 --- a/stats/pwc-summary-211-240.json +++ b/stats/pwc-summary-211-240.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-241-270.json b/stats/pwc-summary-241-270.json index 3b47b8d587..10988ecf6c 100644 --- a/stats/pwc-summary-241-270.json +++ b/stats/pwc-summary-241-270.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-271-300.json b/stats/pwc-summary-271-300.json index a8e3021e5c..be39d5c63b 100644 --- a/stats/pwc-summary-271-300.json +++ b/stats/pwc-summary-271-300.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-301-330.json b/stats/pwc-summary-301-330.json index 304d010e5f..1ed1a19b2c 100644 --- a/stats/pwc-summary-301-330.json +++ b/stats/pwc-summary-301-330.json @@ -30,7 +30,7 @@ 4, 504, 87, - 352, + 354, 1, 3, 3, @@ -109,7 +109,7 @@ } ], "subtitle" : { - "text" : "[Champions: 28] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 28] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-31-60.json b/stats/pwc-summary-31-60.json index ae4e1d8547..07e13d4a40 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-61-90.json b/stats/pwc-summary-61-90.json index eaa6ebb8e5..ae8723264e 100644 --- a/stats/pwc-summary-61-90.json +++ b/stats/pwc-summary-61-90.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-91-120.json b/stats/pwc-summary-91-120.json index ccc65f3b7d..6540a5eb0d 100644 --- a/stats/pwc-summary-91-120.json +++ b/stats/pwc-summary-91-120.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index 553cdac4c6..f746784a53 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -330,7 +330,7 @@ 2, 252, 44, - 186, + 187, 1, 3, 3, @@ -1009,7 +1009,7 @@ } ], "subtitle" : { - "text" : "[Champions: 328] Last updated at 2025-10-20 17:53:47 GMT" + "text" : "[Champions: 328] Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-yearly-language-summary.json b/stats/pwc-yearly-language-summary.json index 659f4b06c2..62dab01017 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 1935 + 1937 ], [ "Raku", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 3642 + "y" : 3644 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 17:53:47 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" }, "title" : { "text" : "The Weekly Challenge Language" -- cgit From 7d5548c7cae4b4013fa237d84516c044e59cec44 Mon Sep 17 00:00:00 2001 From: Luis Mochan Date: Mon, 20 Oct 2025 13:22:49 -0600 Subject: Solve PWC344 --- challenge-344/wlmb/blog.txt | 1 + challenge-344/wlmb/perl/ch-1.pl | 26 ++++++++++++++++++++++ challenge-344/wlmb/perl/ch-1a.pl | 33 ++++++++++++++++++++++++++++ challenge-344/wlmb/perl/ch-2.pl | 47 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 challenge-344/wlmb/blog.txt create mode 100755 challenge-344/wlmb/perl/ch-1.pl create mode 100755 challenge-344/wlmb/perl/ch-1a.pl create mode 100755 challenge-344/wlmb/perl/ch-2.pl diff --git a/challenge-344/wlmb/blog.txt b/challenge-344/wlmb/blog.txt new file mode 100644 index 0000000000..efd7294fa4 --- /dev/null +++ b/challenge-344/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2025/10/20/PWC344/ diff --git a/challenge-344/wlmb/perl/ch-1.pl b/challenge-344/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..8b8ead517a --- /dev/null +++ b/challenge-344/wlmb/perl/ch-1.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +# Perl weekly challenge 344 +# Task 1: Array Form Compute +# Array form->number->array form version +# +# See https://wlmb.github.io/2025/10/20/PWC344/#task-1-array-form-compute +use v5.36; +use feature qw(try); +use PDL; +die <<~"FIN" unless @ARGV && @ARGV%2==0; + Usage: $0 A0 I0 A1 I1... + to add the integer Ij to the integer in array form An + and print the array form of the result. + FIN +for my($string, $integer)(@ARGV){ + try { + die "Input should be space separated positive integers within square brackets: $string" + unless $string =~ /^\[(\d|\s)*]$/; + die "Input should be a positive integer" unless $integer=~/^\d+$/; + my $array=pdl($string); + my $number=($array*10**($array->nelem-1-$array->xvals))->sumover+$integer; + my $result=pdl([split "", $number]); + say "$string, $number -> $result"; + } + catch($e){ warn $e;} +} diff --git a/challenge-344/wlmb/perl/ch-1a.pl b/challenge-344/wlmb/perl/ch-1a.pl new file mode 100755 index 0000000000..79421e9f58 --- /dev/null +++ b/challenge-344/wlmb/perl/ch-1a.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# Perl weekly challenge 344 +# Task 1: Array Form Compute +# Number -> array form version +# +# See https://wlmb.github.io/2025/10/20/PWC344/#task-1-array-form-compute +use v5.36; +use feature qw(try); +use PDL; +die <<~"FIN" unless @ARGV && @ARGV%2==0; + Usage: $0 A0 I0 A1 I1... + to add the integer Ij to the integer in array form An + and print the array form of the result. + FIN +for my($string, $integer)(@ARGV){ + try { + die "Input should be space separated positive integers within square brackets: $string" + unless $string =~ /^\[(\d|\s)*]$/; + die "Input should be a positive integer" unless $integer=~/^\d+$/; + my @array=pdl($string)->list; + my @other=split "", $integer; + my @result=(); + my $carry=0; + while(@array||@other){ + my $sum=((pop @array)//0)+((pop @other)//0)+$carry; + $carry=floor($sum/10); + unshift @result, $sum%10; + } + unshift @result, $carry if $carry; + say "$string, $integer -> [@result]"; + } + catch($e){ warn $e;} +} diff --git a/challenge-344/wlmb/perl/ch-2.pl b/challenge-344/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..a6b58fe0f2 --- /dev/null +++ b/challenge-344/wlmb/perl/ch-2.pl @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +# Perl weekly challenge 344 +# Task 2: Array Formation +# +# See https://wlmb.github.io/2025/10/20/PWC344/#task-2-array-formation +use v5.36; +use feature qw(try); +use PDL; +use PDL::NiceSlice; +die <<~"FIN" unless @ARGV && @ARGV%2==0; + Usage: $0 S0 T0 S1 T1... + to match the source arrays Si to the target array Ti. + The sources are comma separated strings of the form "s0, s1..." where + each string contains an array of space separated numbers within square brackets + of the form "[n0 n1...]" + FIN +my $result; +for my($sources, $target)(@ARGV){ + try { + my @sources = map {pdl($_)} split /\s*,\s*/, $sources; + my $ptarget = pdl($target); + do{die "Expected 1D arrays of numbers: $_" unless $_->ndims==1;} for @sources, $ptarget; + $result=0, next unless pdl(map{$_->nelem} @sources)->sum == $ptarget->nelem; + my @tested=(); + while(@sources){ + $result = test([@tested],[@sources],$ptarget) and last; + push @tested, shift @sources; + } + } + catch($e){ warn $e; } +} +continue{ + say "$sources, $target -> ", $result?"True":"False"; +} +sub test($tested, $untested, $target){ + my @tested=@$tested; + my @untested=@$untested; + return 1 unless @untested; + while(@untested){ + my $current=shift @untested; + my $result=all($current==$target(0:$current->nelem-1)); # assume target is large enough + $result=test([], [@tested, @untested], $target($current->nelem:-1)) if $result; + return 1 if $result; + push @tested, $current; + } + return 0; +} -- cgit From 4ddca8aa5ba1d40a9764f3a0c764e8ab38f3638f Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 20 Oct 2025 20:34:32 +0100 Subject: - Added solutions by W. Luis Mochan. --- stats/pwc-current.json | 21 ++++++++++++++++++++- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 8 ++++---- stats/pwc-language-breakdown-summary.json | 6 +++--- stats/pwc-leaders.json | 8 ++++---- stats/pwc-summary-1-30.json | 2 +- stats/pwc-summary-121-150.json | 2 +- stats/pwc-summary-151-180.json | 2 +- stats/pwc-summary-181-210.json | 2 +- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 2 +- stats/pwc-summary-301-330.json | 6 +++--- stats/pwc-summary-31-60.json | 2 +- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 6 +++--- stats/pwc-yearly-language-summary.json | 8 ++++---- 23 files changed, 57 insertions(+), 38 deletions(-) diff --git a/stats/pwc-current.json b/stats/pwc-current.json index d8dbd11042..2610e5f92d 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -116,6 +116,20 @@ "id" : "Vinod Kumar K", "name" : "Vinod Kumar K" }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + }, { "data" : [ [ @@ -194,6 +208,11 @@ "name" : "Vinod Kumar K", "y" : 2 }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + }, { "drilldown" : "Wanderdoc", "name" : "Wanderdoc", @@ -204,7 +223,7 @@ } ], "subtitle" : { - "text" : "[Champions: 11] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 12] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge - 344" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 86f224d483..0724960da2 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 58320734af..1a5fe4b357 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 2e27da8893..9385198640 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index c18922eb89..3d3e8430d4 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 98e98e27c2..d0bc85e134 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index af0aeb97e9..7979da7e20 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index f279bf0f0c..2bc3358ad4 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 15 + 17 ], [ "Raku", @@ -16,7 +16,7 @@ ], [ "Blog", - 3 + 4 ] ], "id" : "344", @@ -781,7 +781,7 @@ { "drilldown" : "344", "name" : "344", - "y" : 25 + "y" : 28 }, { "drilldown" : "343", @@ -993,7 +993,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 3fd1b2124a..4368b4be13 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,7 +10,7 @@ "data" : [ [ "Perl", - 17714 + 17716 ], [ "Raku", @@ -18,7 +18,7 @@ ], [ "Blog", - 6347 + 6348 ] ], "dataLabels" : { @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index a9cad95856..657e296f32 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -158,7 +158,7 @@ "data" : [ [ "Perl", - 504 + 506 ], [ "Raku", @@ -166,7 +166,7 @@ ], [ "Blog", - 252 + 253 ] ], "id" : "W. Luis Mochan", @@ -842,7 +842,7 @@ { "drilldown" : "W. Luis Mochan", "name" : "10: W. Luis Mochan", - "y" : 1516 + "y" : 1522 }, { "drilldown" : "Dave Jacoby", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index 392e57ad98..714e90782e 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index 4d0e0b5433..fcb896f874 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index 2cccb50825..5584aadb13 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-181-210.json b/stats/pwc-summary-181-210.json index 10ffbfaa7a..28b18ae878 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-211-240.json b/stats/pwc-summary-211-240.json index 4879d24bbe..fbef31e28b 100644 --- a/stats/pwc-summary-211-240.json +++ b/stats/pwc-summary-211-240.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-241-270.json b/stats/pwc-summary-241-270.json index 10988ecf6c..c353906790 100644 --- a/stats/pwc-summary-241-270.json +++ b/stats/pwc-summary-241-270.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-271-300.json b/stats/pwc-summary-271-300.json index be39d5c63b..f67450f47e 100644 --- a/stats/pwc-summary-271-300.json +++ b/stats/pwc-summary-271-300.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-301-330.json b/stats/pwc-summary-301-330.json index 1ed1a19b2c..b791a89ad4 100644 --- a/stats/pwc-summary-301-330.json +++ b/stats/pwc-summary-301-330.json @@ -28,7 +28,7 @@ 36, 0, 4, - 504, + 506, 87, 354, 1, @@ -94,7 +94,7 @@ 0, 0, 0, - 252, + 253, 18, 2, 0, @@ -109,7 +109,7 @@ } ], "subtitle" : { - "text" : "[Champions: 28] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 28] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-31-60.json b/stats/pwc-summary-31-60.json index 07e13d4a40..059c724ee8 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-61-90.json b/stats/pwc-summary-61-90.json index ae8723264e..e767c61eb6 100644 --- a/stats/pwc-summary-61-90.json +++ b/stats/pwc-summary-61-90.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-91-120.json b/stats/pwc-summary-91-120.json index 6540a5eb0d..96fcb0a8cf 100644 --- a/stats/pwc-summary-91-120.json +++ b/stats/pwc-summary-91-120.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index f746784a53..d76daec9b1 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -328,7 +328,7 @@ 23, 0, 2, - 252, + 253, 44, 187, 1, @@ -994,7 +994,7 @@ 0, 0, 0, - 252, + 253, 18, 1, 0, @@ -1009,7 +1009,7 @@ } ], "subtitle" : { - "text" : "[Champions: 328] Last updated at 2025-10-20 18:28:01 GMT" + "text" : "[Champions: 328] Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-yearly-language-summary.json b/stats/pwc-yearly-language-summary.json index 62dab01017..748dcaf530 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 1937 + 1939 ], [ "Raku", @@ -16,7 +16,7 @@ ], [ "Blog", - 757 + 758 ] ], "id" : "2025", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 3644 + "y" : 3647 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 18:28:01 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 19:34:28 GMT" }, "title" : { "text" : "The Weekly Challenge Language" -- cgit From c2d200dc1178bfe0027e3afcec65d6209c65eaf0 Mon Sep 17 00:00:00 2001 From: Thomas Köhler Date: Mon, 20 Oct 2025 22:18:52 +0200 Subject: Add solution 344. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Köhler --- challenge-344/jeanluc2020/blog-1.txt | 1 + challenge-344/jeanluc2020/blog-2.txt | 1 + challenge-344/jeanluc2020/perl/ch-1.pl | 84 +++++++++++++++++++++++++++++ challenge-344/jeanluc2020/perl/ch-2.pl | 97 ++++++++++++++++++++++++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 challenge-344/jeanluc2020/blog-1.txt create mode 100644 challenge-344/jeanluc2020/blog-2.txt create mode 100755 challenge-344/jeanluc2020/perl/ch-1.pl create mode 100755 challenge-344/jeanluc2020/perl/ch-2.pl diff --git a/challenge-344/jeanluc2020/blog-1.txt b/challenge-344/jeanluc2020/blog-1.txt new file mode 100644 index 0000000000..e74423a11c --- /dev/null +++ b/challenge-344/jeanluc2020/blog-1.txt @@ -0,0 +1 @@ +http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/perl/theweeklychallenge-344-1.html diff --git a/challenge-344/jeanluc2020/blog-2.txt b/challenge-344/jeanluc2020/blog-2.txt new file mode 100644 index 0000000000..4bccdf926c --- /dev/null +++ b/challenge-344/jeanluc2020/blog-2.txt @@ -0,0 +1 @@ +http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/perl/theweeklychallenge-344-2.html diff --git a/challenge-344/jeanluc2020/perl/ch-1.pl b/challenge-344/jeanluc2020/perl/ch-1.pl new file mode 100755 index 0000000000..9221ed813e --- /dev/null +++ b/challenge-344/jeanluc2020/perl/ch-1.pl @@ -0,0 +1,84 @@ +#!/usr/bin/env perl +# https://theweeklychallenge.org/blog/perl-weekly-challenge-344/#TASK1 +# +# Task 1: Array Form Compute +# ========================== +# +# You are given an array of integers, @ints and an integer, $x. +# +# Write a script to add $x to the integer in the array-form. +# +### The array form of an integer is a digit-by-digit representation stored as +### an array, where the most significant digit is at the 0th index. +# +## Example 1 +## +## Input: @ints = (1, 2, 3, 4), $x = 12 +## Output: (1, 2, 4, 6) +# +# +## Example 2 +## +## Input: @ints = (2, 7, 4), $x = 181 +## Output: (4, 5, 5) +# +# +## Example 3 +## +## Input: @ints = (9, 9, 9), $x = 1 +## Output: (1, 0, 0, 0) +# +# +## Example 4 +## +## Input: @ints = (1, 0, 0, 0, 0), $x = 9999 +## Output: (1, 9, 9, 9, 9) +# +# +## Example 5 +## +## Input: @ints = (0), $x = 1000 +## Output: (1, 0, 0, 0) +# +############################################################ +## +## discussion +## +############################################################ +# +# We need to add from the end of the array, so we just reverse +# the array and the array we get out of splitting $x into digits. +# Then we add the current digits from both reverse arrays, plus any +# carry over that we get from the previous digits. We keep the last +# digit for our result array, and if there is a second digit, we keep +# it as our new carry over. In the end, if there is a carry over, but +# no more digits, we need to add this carry over to the result. + +use v5.36; + +array_form_compute([1, 2, 3, 4], 12); +array_form_compute([2, 7, 4], 181); +array_form_compute([9, 9, 9], 1); +array_form_compute([1, 0, 0, 0, 0], 9999); +array_form_compute([0], 1000); + +sub array_form_compute($ints, $x) { + say "Input: (" . join(", ", @$ints) . "), $x"; + my @rev_ints = reverse @$ints; + my @rev_x = reverse split //, $x; + my $carry = 0; + my @result = (); + while(@rev_ints or @rev_x) { + my $tmp = $carry; + $tmp += shift @rev_ints if @rev_ints; + $tmp += shift @rev_x if @rev_x; + if($tmp > 9) { + $carry = int($tmp / 10); + } else { + $carry = 0; + } + unshift @result, $tmp % 10; + } + unshift @result, $carry if $carry; + say "Output: (" . join(", ", @result) . ")"; +} diff --git a/challenge-344/jeanluc2020/perl/ch-2.pl b/challenge-344/jeanluc2020/perl/ch-2.pl new file mode 100755 index 0000000000..2b3c2ad095 --- /dev/null +++ b/challenge-344/jeanluc2020/perl/ch-2.pl @@ -0,0 +1,97 @@ +#!/usr/bin/env perl +# https://theweeklychallenge.org/blog/perl-weekly-challenge-344/#TASK2 +# +# Task 2: Array Formation +# ======================= +# +# You are given two list: @source and @target. +# +# Write a script to see if you can build the exact @target by putting these +# smaller lists from @source together in some order. You cannot break apart or +# change the order inside any of the smaller lists in @source. +# +## Example 1 +## +## Input: @source = ([2,3], [1], [4]) +## @target = (1, 2, 3, 4) +## Output: true +## +## Use in the order: [1], [2,3], [4] +# +# +## Example 2 +## +## Input: @source = ([1,3], [2,4]) +## @target = (1, 2, 3, 4) +## Output: false +# +# +## Example 3 +## +## Input: @source = ([9,1], [5,8], [2]) +## @target = (5, 8, 2, 9, 1) +## Output: true +## +## Use in the order: [5,8], [2], [9,1] +# +# +## Example 4 +## +## Input: @source = ([1], [3]) +## @target = (1, 2, 3) +## Output: false +## +## Missing number: 2 +# +# +## Example 5 +## +## Input: @source = ([7,4,6]) +## @target = (7, 4, 6) +## Output: true +## +## Use in the order: [7, 4, 6] +# +############################################################ +## +## discussion +## +############################################################ +# +# We check all possible permutations of the source arrays. If +# any permutation has all numbers in the same order than the +# target array, we can return true since we found a solution. +# Otherwise, we return false. + +use v5.36; +use Algorithm::Permute; + +array_formation([[2,3], [1], [4]], [1, 2, 3, 4]); +array_formation([[1,3], [2,4]], [1, 2, 3, 4]); +array_formation([[9,1], [5,8], [2]], [5, 8, 2, 9, 1]); +array_formation([[1], [3]], [1, 2, 3]); +array_formation([[7,4,6]], [7, 4, 6]); + +sub array_formation($source, $target) { + say "Input: (" . join(", ", map { "[" . join(", ", @$_) . "]" } @$source) + . "), (" . join(", ", @$target) . ")"; + my $p_iterator = Algorithm::Permute->new ( $source ); + while(my @perm = $p_iterator->next) { + my @tmp = (); + foreach my $list (@perm) { + push @tmp, @$list; + } + if(equals(\@tmp, $target)) { + return say "Output: true"; + } + } + say "Output: false"; +} + +sub equals($left, $right) { + return 0 unless scalar(@$left) == scalar(@$right); + foreach my $i (0..scalar(@$left)-1) { + return 0 if $left->[$i] != $right->[$i]; + } + return 1; +} -- cgit From 5bd4aa5c559492819e376a2c5c02a07c0405e67e Mon Sep 17 00:00:00 2001 From: Packy Anderson Date: Mon, 20 Oct 2025 21:05:13 -0400 Subject: Challenge 344 solutions by Packy Anderson * Raku that is finally Raku-ish * Perl * Python that kinda looks like Raku * Elixir that is starting to look like Elixir 1 blog post --- challenge-344/packy-anderson/README.md | 2 +- challenge-344/packy-anderson/blog.txt | 1 + challenge-344/packy-anderson/elixir/ch-1.exs | 34 ++++++++++++++++++ challenge-344/packy-anderson/elixir/ch-2.exs | 53 ++++++++++++++++++++++++++++ challenge-344/packy-anderson/perl/ch-1.pl | 28 +++++++++++++++ challenge-344/packy-anderson/perl/ch-2.pl | 36 +++++++++++++++++++ challenge-344/packy-anderson/python/ch-1.py | 24 +++++++++++++ challenge-344/packy-anderson/python/ch-2.py | 31 ++++++++++++++++ challenge-344/packy-anderson/raku/ch-1.raku | 26 ++++++++++++++ challenge-344/packy-anderson/raku/ch-2.raku | 33 +++++++++++++++++ 10 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 challenge-344/packy-anderson/blog.txt create mode 100755 challenge-344/packy-anderson/elixir/ch-1.exs create mode 100755 challenge-344/packy-anderson/elixir/ch-2.exs create mode 100755 challenge-344/packy-anderson/perl/ch-1.pl create mode 100755 challenge-344/packy-anderson/perl/ch-2.pl create mode 100755 challenge-344/packy-anderson/python/ch-1.py create mode 100755 challenge-344/packy-anderson/python/ch-2.py create mode 100755 challenge-344/packy-anderson/raku/ch-1.raku create mode 100755 challenge-344/packy-anderson/raku/ch-2.raku diff --git a/challenge-344/packy-anderson/README.md b/challenge-344/packy-anderson/README.md index 57c0477cd1..dfffb8191c 100644 --- a/challenge-344/packy-anderson/README.md +++ b/challenge-344/packy-anderson/README.md @@ -23,4 +23,4 @@ ## Blog Post -[Perl Weekly Challenge: Ze-ro the CHAMPIONS!](https://packy.dardan.com/b/cg) +[Perl Weekly Challenge: A-ray Sunshine!](https://packy.dardan.com/b/ct) diff --git a/challenge-344/packy-anderson/blog.txt b/challenge-344/packy-anderson/blog.txt new file mode 100644 index 0000000000..0201a9aca3 --- /dev/null +++ b/challenge-344/packy-anderson/blog.txt @@ -0,0 +1 @@ +https://packy.dardan.com/b/ct \ No newline at end of file diff --git a/challenge-344/packy-anderson/elixir/ch-1.exs b/challenge-344/packy-anderson/elixir/ch-1.exs new file mode 100755 index 0000000000..a47ca85f5d --- /dev/null +++ b/challenge-344/packy-anderson/elixir/ch-1.exs @@ -0,0 +1,34 @@ +#!/usr/bin/env elixir + +defmodule PWC do + def compute(ints, x) do + num = ints + |> Enum.join + |> String.to_integer + num + x + |> Integer.to_string + |> String.graphemes + end + + def solution(ints, x) do + joined = Enum.join(ints, ", ") + IO.puts("Input: @ints = (#{joined}), $x = #{x}") + joined = Enum.join(compute(ints, x), ", ") + IO.puts("Output: (#{joined})") + end +end + +IO.puts("Example 1:") +PWC.solution([1, 2, 3, 4], 12) + +IO.puts("\nExample 2:") +PWC.solution([2, 7, 4], 181) + +IO.puts("\nExample 3:") +PWC.solution([9, 9, 9], 1) + +IO.puts("\nExample 4:") +PWC.solution([1, 0, 0, 0, 0], 9999) + +IO.puts("\nExample 5:") +PWC.solution([0], 1000) diff --git a/challenge-344/packy-anderson/elixir/ch-2.exs b/challenge-344/packy-anderson/elixir/ch-2.exs new file mode 100755 index 0000000000..8668e599ab --- /dev/null +++ b/challenge-344/packy-anderson/elixir/ch-2.exs @@ -0,0 +1,53 @@ +#!/usr/bin/env elixir + +defmodule PWC do + def permutations([]), do: [[]] + + def permutations(list) do + for head <- list, rest <- permutations(list -- [head]), + do: [head|rest] + end + + def formation(source, target) do + source = Enum.map(source, fn s -> Enum.join(s, "") end) + target = Enum.join(target) + {_, result} = Enum.map_reduce( + permutations(s