From f1cf90e9fc15df46ec9fa332826174697fd74854 Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Mon, 27 May 2024 14:36:51 +0200 Subject: Add solutions to 271: Maximum Ones & Sort by 1 bits by E. Choroba --- challenge-271/e-choroba/perl/ch-1.pl | 28 ++++++++++++++++++++++++++++ challenge-271/e-choroba/perl/ch-2.pl | 21 +++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 challenge-271/e-choroba/perl/ch-1.pl create mode 100755 challenge-271/e-choroba/perl/ch-2.pl diff --git a/challenge-271/e-choroba/perl/ch-1.pl b/challenge-271/e-choroba/perl/ch-1.pl new file mode 100755 index 0000000000..4e96f45bbc --- /dev/null +++ b/challenge-271/e-choroba/perl/ch-1.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +use PDL; + +sub maximum_ones($matrix) { + my $p = pdl($matrix); + my $sum = $p->sumover; + my $max = $sum->max; + return ($sum == $max)->which->unpdl->[0] + 1 +} + +use Test2::V0 qw{ plan is }; # Conflict with PDL::float. +plan(3 + 1); + +is maximum_ones([[0, 1], [1, 0]]), 1, 'Example 1'; +is maximum_ones([[0, 0, 0], [1, 0, 1]]), 2, 'Example 2'; +is maximum_ones([[0, 0], [1, 1], [0, 0]]), 2, 'Example 3'; + + +is maximum_ones([[0, 0, 0, 0], + [1, 1, 0, 1], + [0, 0, 1, 0], + [1, 0, 0, 0], + [0, 1, 1, 1]]), + 2, 'Example 4'; diff --git a/challenge-271/e-choroba/perl/ch-2.pl b/challenge-271/e-choroba/perl/ch-2.pl new file mode 100755 index 0000000000..561be4b901 --- /dev/null +++ b/challenge-271/e-choroba/perl/ch-2.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +sub sort_by_1_bits(@ints) { + map $_->[1], + sort { $a->[0] <=> $b->[0] + || + $a->[1] <=> $b->[1] + } map [unpack('%32b*', pack 'N', $_), $_], + @ints +} + +use Test2::V0; +plan(2); + +is [sort_by_1_bits(0, 1, 2, 3, 4, 5, 6, 7, 8)], [0, 1, 2, 4, 8, 3, 5, 6, 7], + 'Example 1'; +is [sort_by_1_bits(1024, 512, 256, 128, 64)], [64, 128, 256, 512, 1024], + 'Example 2'; -- cgit From d566230bbb40621647e3ce65a3d9015f85881f77 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 3 Jun 2024 04:16:03 +0000 Subject: Challenge 272 Solutions (Raku) --- challenge-272/mark-anderson/raku/ch-1.raku | 5 +++++ challenge-272/mark-anderson/raku/ch-2.raku | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 challenge-272/mark-anderson/raku/ch-1.raku create mode 100644 challenge-272/mark-anderson/raku/ch-2.raku diff --git a/challenge-272/mark-anderson/raku/ch-1.raku b/challenge-272/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..aa2c4bab50 --- /dev/null +++ b/challenge-272/mark-anderson/raku/ch-1.raku @@ -0,0 +1,5 @@ +#!/usr/bin/env raku +use Test; + +is '1.1.1.1' .subst('.', '[.]', :g), '1[.]1[.]1[.]1'; +is '255.101.1.0'.subst('.', '[.]', :g), '255[.]101[.]1[.]0'; diff --git a/challenge-272/mark-anderson/raku/ch-2.raku b/challenge-272/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..7a42ee768b --- /dev/null +++ b/challenge-272/mark-anderson/raku/ch-2.raku @@ -0,0 +1,11 @@ +#!/usr/bin/env raku +use Test; + +is string-score("hello"), 13; +is string-score("perl"), 30; +is string-score("raku"), 37; + +sub string-score($str) +{ + [+] map { abs(.[0] - .[1]) }, $str.comb>>.ord.rotor(2 => -1) +} -- cgit From 165c442c42e9cefa806b2ec6ba2c550592e0dd16 Mon Sep 17 00:00:00 2001 From: Niels van Dijke Date: Mon, 3 Jun 2024 07:27:40 +0000 Subject: w272 - Task 1 & 2 --- challenge-272/perlboy1967/perl/ch1.pl | 38 +++++++++++++++++++++++++++++++++ challenge-272/perlboy1967/perl/ch2.pl | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 challenge-272/perlboy1967/perl/ch1.pl create mode 100755 challenge-272/perlboy1967/perl/ch2.pl diff --git a/challenge-272/perlboy1967/perl/ch1.pl b/challenge-272/perlboy1967/perl/ch1.pl new file mode 100755 index 0000000000..39142f5b2f --- /dev/null +++ b/challenge-272/perlboy1967/perl/ch1.pl @@ -0,0 +1,38 @@ +#!/bin/perl + +=pod + +The Weekly Challenge - 272 +- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 + +Author: Niels 'PerlBoy' van Dijke + +Task 1: Defrang IP Address +Submitted by: Mohammad Sajid Anwar + +You are given a valid IPv4 address. + +Write a script to return the defranged version of the given IP address. + +|| A defranged IP address replaces every period “.” with “[.]". + +=cut + +use v5.32; +use feature qw(signatures); +use common::sense; + +use Test2::V0 qw(-no_srand);; + +use Net::IP qw(ip_is_ipv4); + +sub defrangIpAddress ($ipv4) { + ip_is_ipv4($ipv4) ? $ipv4 =~ s#\.#[.]#gr : $ipv4; +} + +is(defrangIpAddress('1.1.1.1'),'1[.]1[.]1[.]1','Example 1'); +is(defrangIpAddress('255.101.1.0'),'255[.]101[.]1[.]0','Example 2'); +is(defrangIpAddress('dead::beaf'),'dead::beaf','Own example'); + +done_testing; + diff --git a/challenge-272/perlboy1967/perl/ch2.pl b/challenge-272/perlboy1967/perl/ch2.pl new file mode 100755 index 0000000000..6f877bffa4 --- /dev/null +++ b/challenge-272/perlboy1967/perl/ch2.pl @@ -0,0 +1,40 @@ +#!/bin/perl + +=pod + +The Weekly Challenge - 272 +- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 + +Author: Niels 'PerlBoy' van Dijke + +Task 2: String Score +Submitted by: Mohammad Sajid Anwar + +You are given a string, $str. + +Write a script to return the score of the given string. + +|| The score of a string is defined as the sum of the absolute difference +|| between the ASCII values of adjacent characters. + +=cut + +use v5.32; +use feature qw(signatures); +use common::sense; + +use Test2::V0 qw(-no_srand);; + +use List::Util qw(sum0); +use List::MoreUtils qw(slide); + +sub stringScore ($str) { + sum0 slide { abs(ord($a) - ord($b)) } split //, $str; +} + +is(stringScore('hello'),13,'Example 1'); +is(stringScore('perl'),30,'Example 2'); +is(stringScore('raku'),37,'Example 3'); + +done_testing; + -- cgit From 61532a1b4c1ca4fa99d30262977f6167de2ebb90 Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Mon, 3 Jun 2024 09:36:31 +0200 Subject: Add solutions to 272: Defang IP Address & String Score by E. Choroba --- challenge-272/e-choroba/perl/ch-1.pl | 13 +++++++++++++ challenge-272/e-choroba/perl/ch-2.pl | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 challenge-272/e-choroba/perl/ch-1.pl create mode 100755 challenge-272/e-choroba/perl/ch-2.pl diff --git a/challenge-272/e-choroba/perl/ch-1.pl b/challenge-272/e-choroba/perl/ch-1.pl new file mode 100755 index 0000000000..e38b5da952 --- /dev/null +++ b/challenge-272/e-choroba/perl/ch-1.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +sub defang_ip_address($address) { + $address =~ s/[.]/[.]/gr +} + +use Test::More tests => 2; + +is defang_ip_address('1.1.1.1'), '1[.]1[.]1[.]1', 'Example 1'; +is defang_ip_address('255.101.1.0'), '255[.]101[.]1[.]0', 'Example 2'; diff --git a/challenge-272/e-choroba/perl/ch-2.pl b/challenge-272/e-choroba/perl/ch-2.pl new file mode 100755 index 0000000000..f0f4116061 --- /dev/null +++ b/challenge-272/e-choroba/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +sub string_score($str) { + my $score = 0; + + while ($str =~ /(.)(?=(.))/g) { + $score += abs(ord($1) - ord($2)); + } + return $score +} + +use Test::More tests => 3 + 2; + +is string_score('hello'), 13, 'Example 1'; +is string_score('perl'), 30, 'Example 2'; +is string_score('raku'), 37, 'Example 3'; + +is string_score(""), 0, 'Empty'; +is string_score('a'), 0, 'Single character'; -- cgit From 50574f8eb2b86e66894434860c3fab1f94b9efb9 Mon Sep 17 00:00:00 2001 From: 冯昶 Date: Mon, 3 Jun 2024 16:33:42 +0800 Subject: challenge 272, raku solutions --- challenge-272/feng-chang/raku/ch-1.raku | 5 +++++ challenge-272/feng-chang/raku/ch-2.raku | 5 +++++ challenge-272/feng-chang/raku/test.raku | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 challenge-272/feng-chang/raku/ch-1.raku create mode 100755 challenge-272/feng-chang/raku/ch-2.raku create mode 100755 challenge-272/feng-chang/raku/test.raku diff --git a/challenge-272/feng-chang/raku/ch-1.raku b/challenge-272/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..4a4f120329 --- /dev/null +++ b/challenge-272/feng-chang/raku/ch-1.raku @@ -0,0 +1,5 @@ +#!/bin/env raku + +unit sub MAIN(Str:D $s); + +put $s.subst(/\./, '[.]', :g); diff --git a/challenge-272/feng-chang/raku/ch-2.raku b/challenge-272/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..a8829e7dda --- /dev/null +++ b/challenge-272/feng-chang/raku/ch-2.raku @@ -0,0 +1,5 @@ +#!/bin/env raku + +unit sub MAIN(Str:D $s); + +put $s.comb».ord.rotor(2 => -1).map({ [-] $_ })».abs.sum; diff --git a/challenge-272/feng-chang/raku/test.raku b/challenge-272/feng-chang/raku/test.raku new file mode 100755 index 0000000000..89720db130 --- /dev/null +++ b/challenge-272/feng-chang/raku/test.raku @@ -0,0 +1,23 @@ +#!/bin/env raku + +# The Weekly Challenge 272 +use Test; + +sub pwc-test(Str:D $script, Bool :$deeply? = False, *@input) { + my ($expect, $assertion) = @input.splice(*-2, 2); + my $p = run $script, |@input, :out; + if $deeply { + is-deeply $p.out.slurp(:close).chomp.words.Bag, $expect, $assertion; + } else { + is $p.out.slurp(:close).chomp, $expect, $assertion; + } +} + +# Task 1, Defrang IP Address +pwc-test './ch-1.raku', '1.1.1.1', '1[.]1[.]1[.]1', 'Defrang IP Address: 1.1.1.1 => 1[.]1[.]1[.]1'; +pwc-test './ch-1.raku', '255.101.1.0', '255[.]101[.]1[.]0', 'Defrang IP Address: 255.101.1.0 => 255[.]101[.]1[.]0'; + +# Task 2, String Score +pwc-test './ch-2.raku', 'hello', 13, 'String Score: hello => 13'; +pwc-test './ch-2.raku', 'perl', 30, 'String Score: perl => 30'; +pwc-test './ch-2.raku', 'raku', 37, 'String Score: raku => 37'; -- cgit From b48721edf380a53de82783279dca7e99be626179 Mon Sep 17 00:00:00 2001 From: 冯昶 Date: Mon, 3 Jun 2024 16:43:10 +0800 Subject: fix --- challenge-272/feng-chang/raku/ch-1.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-272/feng-chang/raku/ch-1.raku b/challenge-272/feng-chang/raku/ch-1.raku index 4a4f120329..cfad2243be 100755 --- a/challenge-272/feng-chang/raku/ch-1.raku +++ b/challenge-272/feng-chang/raku/ch-1.raku @@ -2,4 +2,4 @@ unit sub MAIN(Str:D $s); -put $s.subst(/\./, '[.]', :g); +put $s.subst('.', '[.]', :g); -- cgit From d50ea9f9f461bcec9d50bd7cb0481576553393b0 Mon Sep 17 00:00:00 2001 From: Luis Mochan Date: Mon, 3 Jun 2024 07:04:39 -0600 Subject: Solve PWC272 --- challenge-272/wlmb/blog.txt | 1 + challenge-272/wlmb/perl/ch-1.pl | 17 +++++++++++++++++ challenge-272/wlmb/perl/ch-2.pl | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 challenge-272/wlmb/blog.txt create mode 100755 challenge-272/wlmb/perl/ch-1.pl create mode 100755 challenge-272/wlmb/perl/ch-2.pl diff --git a/challenge-272/wlmb/blog.txt b/challenge-272/wlmb/blog.txt new file mode 100644 index 0000000000..96f79fd181 --- /dev/null +++ b/challenge-272/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/06/03/PWC272/ diff --git a/challenge-272/wlmb/perl/ch-1.pl b/challenge-272/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..ffa55487ca --- /dev/null +++ b/challenge-272/wlmb/perl/ch-1.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Perl weekly challenge 272 +# Task 1: Defang IP Address +# +# See https://wlmb.github.io/2024/06/03/PWC272/#task-1-defang-ip-address +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 A1 A2... + to defang the IP addresses A1 A2... + FIN +my $ip=join '\.', ('\d{1,3}') x 4; +for(@ARGV){ + my $original=$_; + warn "Not a valid IP: $_", next unless /^$ip$/; + s/\./[.]/g; + say "$original -> $_"; +} diff --git a/challenge-272/wlmb/perl/ch-2.pl b/challenge-272/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..24c68607a0 --- /dev/null +++ b/challenge-272/wlmb/perl/ch-2.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +# Perl weekly challenge 272 +# Task 2: String Score +# +# See https://wlmb.github.io/2024/06/03/PWC272/#task-2-string-score +use v5.36; +use PDL; +use PDL::NiceSlice; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to find the score of the strings S1 S2... + i.e., the sum of the absolute value of + the difference of consecutive ascii values. + FIN +for(@ARGV){ + my $ords=pdl map {ord} split ""; + warn "Need at least two characters: $_", next unless $ords->nelem > 1; + say "$_ -> ",($ords(1:-1)-$ords(0:-2))->abs->sumover; +} -- cgit From 6006e625cdb6ccb9bf4bae4ff0b6bfff27ba2c59 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 3 Jun 2024 14:22:42 +0100 Subject: add solutions week 272 in python --- challenge-272/steven-wilson/python/ch-1.py | 20 ++++++++++++++++++++ challenge-272/steven-wilson/python/ch-2.py | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 challenge-272/steven-wilson/python/ch-1.py create mode 100644 challenge-272/steven-wilson/python/ch-2.py diff --git a/challenge-272/steven-wilson/python/ch-1.py b/challenge-272/steven-wilson/python/ch-1.py new file mode 100644 index 0000000000..145c0306da --- /dev/null +++ b/challenge-272/steven-wilson/python/ch-1.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + + +def defang_ip_address(address): + ''' Given a valid IPv4 address, return the defanged version of the given IP + address. + + A defanged IP address replaces every period “.” with “[.]". + >>> defang_ip_address('1.1.1.1') + '1[.]1[.]1[.]1' + >>> defang_ip_address('255.101.1.0') + '255[.]101[.]1[.]0' + ''' + return address.replace(".", "[.]") + + +if __name__ == "__main__": + import doctest + + doctest.testmod(verbose=True) diff --git a/challenge-272/steven-wilson/python/ch-2.py b/challenge-272/steven-wilson/python/ch-2.py new file mode 100644 index 0000000000..d33962b413 --- /dev/null +++ b/challenge-272/steven-wilson/python/ch-2.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + + +def string_score(string): + ''' Given a, string, return the score of the given string. + + The score of a string is defined as the sum of the absolute difference + between the ASCII values of adjacent characters. + >>> string_score('hello') + 13 + >>> string_score('perl') + 30 + >>> string_score('raku') + 37 + ''' + return sum(abs(ord(a) - ord(b)) for a, b in zip(string, string[1:])) + + +if __name__ == "__main__": + import doctest + + doctest.testmod(verbose=True) -- cgit From 7d9c761b8d7c2b7744ef64f8b9f2aa1bd12bda3d Mon Sep 17 00:00:00 2001 From: pme Date: Mon, 3 Jun 2024 17:31:24 +0200 Subject: challenge-272 --- challenge-272/peter-meszaros/perl/ch-1.pl | 45 +++++++++++++++ challenge-272/peter-meszaros/perl/ch-2.pl | 93 +++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100755 challenge-272/peter-meszaros/perl/ch-1.pl create mode 100755 challenge-272/peter-meszaros/perl/ch-2.pl diff --git a/challenge-272/peter-meszaros/perl/ch-1.pl b/challenge-272/peter-meszaros/perl/ch-1.pl new file mode 100755 index 0000000000..e28f4904ad --- /dev/null +++ b/challenge-272/peter-meszaros/perl/ch-1.pl @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +# +=head1 Task 1: Defang IP Address + +You are given a valid IPv4 address. + +Write a script to return the defanged version of the given IP address. + + A defanged IP address replaces every period "." with "[.]". + +=head2 Example 1 + + Input: $ip = "1.1.1.1" + Output: "1[.]1[.]1[.]1" + +=head2 Example 2 + + Input: $ip = "255.101.1.0" + Output: "255[.]101[.]1[.]0" +=cut + +use strict; +use warnings; +use Test2::V0 -no_srand => 1; +use Data::Dumper; + +my $cases = [ + ['1.1.1.1', '1[.]1[.]1[.]1', 'Example 1'], + ['255.101.1.0', '255[.]101[.]1[.]0', 'Example 2'], +]; + +sub defang_ip_address +{ + my $ip = shift; + $ip =~ s/\./\[\.\]/g; + return $ip; +} + +for (@$cases) { + is(defang_ip_address($_->[0]), $_->[1], $_->[2]); +} + +done_testing(); + +exit 0; diff --git a/challenge-272/peter-meszaros/perl/ch-2.pl b/challenge-272/peter-meszaros/perl/ch-2.pl new file mode 100755 index 0000000000..5596168b31 --- /dev/null +++ b/challenge-272/peter-meszaros/perl/ch-2.pl @@ -0,0 +1,93 @@ +#!/usr/bin/env perl +# +=head1 Task 2: String Score + +You are given a string, $str. + +Write a script to return the score of the given string. + + The score of a string is defined as the sum of the absolute difference + between the ASCII values of adjacent characters. + +=head2 Example 1 + + Input: $str = "hello" + Output: 13 + + ASCII values of characters: + h = 104 + e = 101 + l = 108 + l = 108 + o = 111 + + Score => |104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| + => 3 + 7 + 0 + 3 + => 13 + +=head2 Example 2 + + Input: "perl" + Output: 30 + + ASCII values of characters: + p = 112 + e = 101 + r = 114 + l = 108 + + Score => |112 - 101| + |101 - 114| + |114 - 108| + => 11 + 13 + 6 + => 30 + +=head2 Example 3 + + Input: "raku" + Output: 37 + + ASCII values of characters: + r = 114 + a = 97 + k = 107 + u = 117 + + Score => |114 - 97| + |97 - 107| + |107 - 117| + => 17 + 10 + 10 + => 37 + +=cut + +use strict; +use warnings; +use Test2::V0 -no_srand => 1; +use Data::Dumper; + +my $cases = [ + ['hello', 13, 'Example 1'], + ['perl', 30, 'Example 2'], + ['raku', 37, 'Example 3'], + ['r', 0, 'Example 4'], + ['', 0, 'Example 5'], +]; + +sub string_score +{ + my $s = shift; + + my @s = split(//, $s); + + my $sum = 0; + for my $i (1..$#s) { + $sum += abs(ord($s[$i-1]) - ord($s[$i])); + } + + return $sum; +} + +for (@$cases) { + is(string_score($_->[0]), $_->[1], $_->[2]); +} +done_testing(); + +exit 0; + -- cgit From 013c5e64e40988f21dc5ab8e9d676b4b26e21cba Mon Sep 17 00:00:00 2001 From: Peter Campbell Smith Date: Mon, 3 Jun 2024 17:12:02 +0100 Subject: Week 272 - Fags and strings --- challenge-272/peter-campbell-smith/blog.txt | 1 + challenge-272/peter-campbell-smith/perl/ch-1.pl | 19 +++++++++++++++++++ challenge-272/peter-campbell-smith/perl/ch-2.pl | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 challenge-272/peter-campbell-smith/blog.txt create mode 100755 challenge-272/peter-campbell-smith/perl/ch-1.pl create mode 100755 challenge-272/peter-campbell-smith/perl/ch-2.pl diff --git a/challenge-272/peter-campbell-smith/blog.txt b/challenge-272/peter-campbell-smith/blog.txt new file mode 100644 index 0000000000..81a6479eed --- /dev/null +++ b/challenge-272/peter-campbell-smith/blog.txt @@ -0,0 +1 @@ +http://ccgi.campbellsmiths.force9.co.uk/challenge/272 diff --git a/challenge-272/peter-campbell-smith/perl/ch-1.pl b/challenge-272/peter-campbell-smith/perl/ch-1.pl new file mode 100755 index 0000000000..61e7b99633 --- /dev/null +++ b/challenge-272/peter-campbell-smith/perl/ch-1.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge + +use v5.26; # The Weekly Challenge - 3 June 2024 +use utf8; # Week 272 - task 1 - Defang IP address +use warnings; # Peter Campbell Smith +binmode STDOUT, ':utf8'; + +defang_ip_address('192.168.1.245'); +defang_ip_address('0.0.0.0'); +defang_ip_address('255.255.255.255'); +defang_ip_address('192.168.1.20'); + +sub defang_ip_address { + + $_[0] =~ m|(\d+).(\d+).(\d+).(\d+)|; + say qq{\nInput: \$ip = "$_[0]"\nOutput: "$1\[.]$2\[.]$3\[.]$4"}; +} diff --git a/challenge-272/peter-campbell-smith/perl/ch-2.pl b/challenge-272/peter-campbell-smith/perl/ch-2.pl new file mode 100755 index 0000000000..081e8fab49 --- /dev/null +++ b/challenge-272/peter-campbell-smith/perl/ch-2.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge + +use v5.26; # The Weekly Challenge - 3 June 2024 +use utf8; # Week 272 - task 2 - String score +use warnings; # Peter Campbell Smith +binmode STDOUT, ':utf8'; + +string_score('hello'); +string_score('supercalifragilisticexpialidocious'); +string_score('The Weekly Challenge'); +string_score('aĐbđcĒeēfĔgĕh🞱'); + +sub string_score { + + my ($score); + + $score += abs(ord(substr($_[0], $_, 1)) - + ord(substr($_[0], $_ - 1, 1))) + for 1 .. length($_[0]) - 1; + say qq[\nInput: $_[0]\nOutput: $score]; +} -- cgit From 8beb924b637ccd743fe1c5c916ed07deec3af63f Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Mon, 3 Jun 2024 12:26:56 -0400 Subject: Week 272 --- challenge-272/zapwai/c/ch-1.c | 29 +++++++++++++++++++++++++++++ challenge-272/zapwai/c/ch-2.c | 24 ++++++++++++++++++++++++ challenge-272/zapwai/javascript/ch-1.js | 11 +++++++++++ challenge-272/zapwai/javascript/ch-2.js | 19 +++++++++++++++++++ challenge-272/zapwai/perl/ch-1.pl | 12 ++++++++++++ challenge-272/zapwai/perl/ch-2.pl | 15 +++++++++++++++ challenge-272/zapwai/python/ch-1.py | 15 +++++++++++++++ challenge-272/zapwai/python/ch-2.py | 18 ++++++++++++++++++ challenge-272/zapwai/rust/ch-1.rs | 18 ++++++++++++++++++ challenge-272/zapwai/rust/ch-2.rs | 21 +++++++++++++++++++++ 10 files changed, 182 insertions(+) create mode 100644 challenge-272/zapwai/c/ch-1.c create mode 100644 challenge-272/zapwai/c/ch-2.c create mode 100644 challenge-272/zapwai/javascript/ch-1.js create mode 100644 challenge-272/zapwai/javascript/ch-2.js create mode 100644 challenge-272/zapwai/perl/ch-1.pl create mode 100644 challenge-272/zapwai/perl/ch-2.pl create mode 100644 challenge-272/zapwai/python/ch-1.py create mode 100644 challenge-272/zapwai/python/ch-2.py create mode 100644 challenge-272/zapwai/rust/ch-1.rs create mode 100644 challenge-272/zapwai/rust/ch-2.rs diff --git a/challenge-272/zapwai/c/ch-1.c b/challenge-272/zapwai/c/ch-1.c new file mode 100644 index 0000000000..5e1fad79bf --- /dev/null +++ b/challenge-272/zapwai/c/ch-1.c @@ -0,0 +1,29 @@ +#include +#include +#include + +void proc(char* ip) { + char* out = malloc(100 * sizeof(char)); + int j = 0; + for (int i = 0; i < strlen(ip); i++) { + if (ip[i] == '.') { + out[j++] = '['; + out[j++] = '.'; + out[j] = ']'; + } else { + out[j] = ip[i]; + } + j++; + } + out[j] = '\0'; + printf( "Input: %s\n", ip); + printf( "Output: %s\n", out); + free(out); +} + +int main() { + char* ip = "1.1.1.1"; + proc(ip); + char* ip2 = "255.101.1.0"; + proc(ip2); +} diff --git a/challenge-272/zapwai/c/ch-2.c b/challenge-272/zapwai/c/ch-2.c new file mode 100644 index 0000000000..8f93ad2cd6 --- /dev/null +++ b/challenge-272/zapwai/c/ch-2.c @@ -0,0 +1,24 @@ +#include +#include +#include + +void proc(char* str) { + int sum = 0; + int prev = str[0]; + for (int i = 1; i < strlen(str); i++) { + int diff = abs(str[i] - prev); + sum += diff; + prev = str[i]; + } + printf("Input: %s\n", str); + printf("Output: %d\n", sum); +} + +int main() { + char* str1 = "hello"; + proc(str1); + char* str2 = "perl"; + proc(str2); + char* str3 = "raku"; + proc(str3); +} diff --git a/challenge-272/zapwai/javascript/ch-1.js b/challenge-272/zapwai/javascript/ch-1.js new file mode 100644 index 0000000000..024387a534 --- /dev/null +++ b/challenge-272/zapwai/javascript/ch-1.js @@ -0,0 +1,11 @@ +let ip = "1.1.1.1"; +proc(ip); +ip = "255.101.1.0"; +proc(ip); + +function proc(ip) { + let nums = ip.split('\.'); + let out = nums.join("[.]"); + console.log( "Input:", ip); + console.log( "Output:", out); +} diff --git a/challenge-272/zapwai/javascript/ch-2.js b/challenge-272/zapwai/javascript/ch-2.js new file mode 100644 index 0000000000..7d944f651c --- /dev/null +++ b/challenge-272/zapwai/javascript/ch-2.js @@ -0,0 +1,19 @@ +let str = "hello"; +proc(str); +str = "perl"; +proc(str); +str = "raku"; +proc(str); + +function proc(str) { + let ords = []; + for (let i = 0; i < str.length; i++) { + ords.push(str.charCodeAt(i)); + } + let sum = 0; + for (let i = 0; i < ords.length - 1; i++) { + sum += Math.abs(ords[i] - ords[i + 1]); + } + console.log( "Input:", str); + console.log( "Output:", sum); +} diff --git a/challenge-272/zapwai/perl/ch-1.pl b/challenge-272/zapwai/perl/ch-1.pl new file mode 100644 index 0000000000..ef46d3822f --- /dev/null +++ b/challenge-272/zapwai/perl/ch-1.pl @@ -0,0 +1,12 @@ +use v5.38; +my $ip = "1.1.1.1"; +proc($ip); +$ip = "255.101.1.0"; +proc($ip); + +sub proc($ip) { + my @nums = split '\.', $ip; + my $out = join "[.]", @nums; + say "Input: $ip"; + say "Output: $out"; +} diff --git a/challenge-272/zapwai/perl/ch-2.pl b/challenge-272/zapwai/perl/ch-2.pl new file mode 100644 index 0000000000..4676c3ee0a --- /dev/null +++ b/challenge-272/zapwai/perl/ch-2.pl @@ -0,0 +1,15 @@ +use v5.38; +my $str = "hello"; +proc($str); +$str = "perl"; +proc($str); +$str = "raku"; +proc($str); + +sub proc($str) { + my @ord = map { ord $_ } split "", $str; + my $sum = 0; + $sum += abs($ord[$_] - $ord[$_ + 1]) for (0 .. $#ord - 1); + say "Input: $str"; + say "Output: $sum"; +} diff --git a/challenge-272/zapwai/python/ch-1.py b/challenge-272/zapwai/python/ch-1.py new file mode 100644 index 0000000000..d254cbd0ac --- /dev/null +++ b/challenge-272/zapwai/python/ch-1.py @@ -0,0 +1,15 @@ +def proc(ip): + nums = ip.split('.') + out = '' + for i in range(len(nums)): + str = nums[i] + if i < len(nums) - 1: + str += "[.]" + out += str + print("Input:", ip) + print("Output:", out) + +ip = "1.1.1.1" +proc(ip) +ip = "255.101.1.0" +proc(ip) diff --git a/challenge-272/zapwai/python/ch-2.py b/challenge-272/zapwai/python/ch-2.py new file mode 100644 index 0000000000..4d488a2ab5 --- /dev/null +++ b/challenge-272/zapwai/python/ch-2.py @@ -0,0 +1,18 @@ +def proc(str): + chars = list(str) + num = [] + for c in chars: + num.append(ord(c)) + sum = 0 + for i in range(len(num) - 1): + sum += abs(num[i] - num[i + 1]) + print("Input:", str) + print("Output:", sum) + +str = "hello" +proc(str) +str = "perl" +proc(str) +str = "raku" +proc(str) + diff --git a/challenge-272/zapwai/rust/ch-1.rs b/challenge-272/zapwai/rust/ch-1.rs new file mode 100644 index 0000000000..fdea6f414f --- /dev/null +++ b/challenge-272/zapwai/rust/ch-1.rs @@ -0,0 +1,18 @@ +fn main() { + let ip = "1.1.1.1"; + proc(ip); + let ip2 = "255.101.1.0"; + proc(ip2); +} + +fn proc(ip : &str) { + let nums : Vec<&str> = ip.split(".").collect(); + let mut pie : String = String::new(); + for p in &nums { + pie += p; + pie += "[.]"; + } + let out = &pie[..pie.len()-3]; + println!( "Input: {ip}"); + println!( "Output: {out}"); +} diff --git a/challenge-272/zapwai/rust/ch-2.rs b/challenge-272/zapwai/rust/ch-2.rs new file mode 100644 index 0000000000..c78c8b1e14 --- /dev/null +++ b/challenge-272/zapwai/rust/ch-2.rs @@ -0,0 +1,21 @@ +fn main() { + let str = "hello"; + proc(str); + let str2 = "perl"; + proc(str2); + let str3 = "raku"; + proc(str3); +} + +fn proc(stri : &str) { + let mut sum = 0; + let strin : Vec = stri.chars().collect(); + let mut prev = strin[0]; + for i in 0 .. strin.len() { + let diff = strin[i] as i32 - prev as i32; + prev = strin[i]; + sum += diff.abs(); + } + println!( "Input: {stri}"); + println!( "Output: {sum}"); +} -- cgit From e74007a0298a28ce431df61a219086397a560901 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 3 Jun 2024 17:34:31 +0100 Subject: add some argument validation --- challenge-272/steven-wilson/python/ch-2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/challenge-272/steven-wilson/python/ch-2.py b/challenge-272/steven-wilson/python/ch-2.py index d33962b413..f92d1c2528 100644 --- a/challenge-272/steven-wilson/python/ch-2.py +++ b/challenge-272/steven-wilson/python/ch-2.py @@ -13,6 +13,9 @@ def string_score(string): >>> string_score('raku') 37 ''' + if len(string) < 2: + raise ValueError("String argument should have at least 2 characters.") + return sum(abs(ord(a) - ord(b)) for a, b in zip(string, string[1:])) -- cgit From 691fa0072d7f5f8b7e8d0c2c3922f336bdb71b0a Mon Sep 17 00:00:00 2001 From: Thomas Köhler Date: Mon, 3 Jun 2024 21:48:54 +0200 Subject: Add solution 272. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Köhler --- challenge-272/jeanluc2020/blog-1.txt | 1 + challenge-272/jeanluc2020/blog-2.txt | 1 + challenge-272/jeanluc2020/perl/ch-1.pl | 47 ++++++++++++++++++ challenge-272/jeanluc2020/perl/ch-2.pl | 90 ++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 challenge-272/jeanluc2020/blog-1.txt create mode 100644 challenge-272/jeanluc2020/blog-2.txt create mode 100755 challenge-272/jeanluc2020/perl/ch-1.pl create mode 100755 challenge-272/jeanluc2020/perl/ch-2.pl diff --git a/challenge-272/jeanluc2020/blog-1.txt b/challenge-272/jeanluc2020/blog-1.txt new file mode 100644 index 0000000000..11e85f2259 --- /dev/null +++ b/challenge-272/jeanluc2020/blog-1.txt @@ -0,0 +1 @@ +http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/perl/theweeklychallenge-272-1.html diff --git a/challenge-272/jeanluc2020/blog-2.txt b/challenge-272/jeanluc2020/blog-2.txt new file mode 100644 index 0000000000..f4bddaff24 --- /dev/null +++ b/challenge-272/jeanluc2020/blog-2.txt @@ -0,0 +1 @@ +http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/perl/theweeklychallenge-272-2.html diff --git a/challenge-272/jeanluc2020/perl/ch-1.pl b/challenge-272/jeanluc2020/perl/ch-1.pl new file mode 100755 index 0000000000..38ad0509cb --- /dev/null +++ b/challenge-272/jeanluc2020/perl/ch-1.pl @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +# https://theweeklychallenge.org/blog/perl-weekly-challenge-272/#TASK1 +# +# Task 1: Defang IP Address +# ========================= +# +# You are given a valid IPv4 address. +# +# Write a script to return the defanged version of the given IP address. +# +### A defanged IP address replaces every period “.” with “[.]". +# +## Example 1 +## +## Input: $ip = "1.1.1.1" +## Output: "1[.]1[.]1[.]1" +# +## Example 2 +## +## Input: $ip = "255.101.1.0" +## Output: "255[.]101[.]1[.]0" +# +############################################################ +## +## discussion +## +############################################################ +# +# There are two pretty simple approaches here. Either substitute +# all "." with "[.]" directly, or split the string at "." and +# join it using "[.]" as the glue. Both work fine. + +use strict; +use warnings; + +defang_ip_address("1.1.1.1"); +defang_ip_address("255.101.1.0"); + +sub defang_ip_address { + my $ip = shift; + print "Input: $ip\n"; + $ip =~ s/\./\[.\]/g; + # or: + # $ip = join("[.]", split/\./, $ip); + print "Output: $ip\n"; +} + diff --git a/challenge-272/jeanluc2020/perl/ch-2.pl b/challenge-272/jeanluc2020/perl/ch-2.pl new file mode 100755 index 0000000000..ee9a8dd196 --- /dev/null +++ b/challenge-272/jeanluc2020/perl/ch-2.pl @@ -0,0 +1,90 @@ +#!/usr/bin/env perl +# https://theweeklychallenge.org/blog/perl-weekly-challenge-272/#TASK2 +# +# Task 2: String Score +# ==================== +# +# You are given a string, $str. +# +# Write a script to return the score of the given string. +# +### The score of a string is defined as the sum of the absolute difference +### between the ASCII values of adjacent characters. +# +## Example 1 +## +## Input: $str = "hello" +## Output: 13 +## +## ASCII values of characters: +## h = 104 +## e = 101 +## l = 108 +## l = 108 +## o = 111 +## +## Score => |104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| +## => 3 + 7 + 0 + 3 +## => 13 +# +## Example 2 +## +## Input: "perl" +## Output: 30 +## +## ASCII values of characters: +## p = 112 +## e = 101 +## r = 114 +## l = 108 +## +## Score => |112 - 101| + |101 - 114| + |114 - 108| +## => 11 + 13 + 6 +## => 30 +# +## Example 3 +## +## Input: "raku" +## Output: 37 +## +## ASCII values of characters: +## r = 114 +## a = 97 +## k = 107 +## u = 117 +## +## Score => |114 - 97| + |97 - 107| + |107 - 117| +## => 17 + 10 + 10 +## => 37 +# +############################################################ +## +## discussion +## +############################################################ +# +# Split the string into an array of characters. Then start at +# index 1 and calculate the diff of the ASCII values of the +# character at the given index-1 and the given index, until the +# index reaches the index of the last element in the array. The +# ASCII value can be calculated by the ord() function, the absolute +# value of the diff will be revealed by the abs() function. + +use strict; +use warnings; + +string_score("hello"); +string_score("perl"); +string_score("raku"); + +sub string_score { + my $str = shift; + print "Input: '$str'\n"; + my @chars = split //, $str; + my $score = 0; + foreach my $i (1..$#chars) { + $score += abs(ord($chars[$i-1]) - ord($chars[$i])); + } + print "Output: $score\n"; +} + -- cgit From 9389727a0e5905882dbf2805d8ae4efcd579fed4 Mon Sep 17 00:00:00 2001 From: Dave Jacoby Date: Mon, 3 Jun 2024 16:03:14 -0400 Subject: DAJ 272 --- challenge-272/dave-jacoby/perl/ch-1.pl | 24 ++++++++++++++++++++++++ challenge-272/dave-jacoby/perl/ch-2.pl | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 challenge-272/dave-jacoby/perl/ch-1.pl create mode 100644 challenge-272/dave-jacoby/perl/ch-2.pl diff --git a/challenge-272/dave-jacoby/perl/ch-1.pl b/challenge-272/dave-jacoby/perl/ch-1.pl new file mode 100644 index 0000000000..abaa466aae --- /dev/null +++ b/challenge-272/dave-jacoby/perl/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use experimental qw{ bitwise fc postderef say signatures state }; + +use List::Util qw{max}; + +my @examples = ( + + "1.1.1.1", "255.101.1.0" +); +for my $example (@examples) { + my $output = defang_ipv4($example); + say <<"END"; + Input: \$ip = "$example" + Output: "$output" +END +} + +sub defang_ipv4 ( $address ) { + $address =~ s/\./[.]/gmx; + return $address; +} diff --git a/challenge-272/dave-jacoby/perl/ch-2.pl b/challenge-272/dave-jacoby/perl/ch-2.pl new file mode 100644 index 0000000000..79650b52d9 --- /dev/null +++ b/challenge-272/dave-jacoby/perl/ch-2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use experimental qw{ fc say postderef signatures state }; + +use List::Util qw{ sum0 }; + +my @examples = (qw{ hello perl raku weekly linux Perl PERL }); + +for my $example (@examples) { + my $output = string_score($example); + + say <<"END"; + Input: \$str = "$example" + Output: $output +END +} + +sub string_score ($str) { + my @str = split //, $str; + return sum0 + map { abs ord( $str[$_] ) - ord( $str[ 1 + $_ ] ) } + 0 .. -2 + scalar @str; +} -- cgit From 270a0c7dfb1bde453e34237e9b8c2c18b35baf78 Mon Sep 17 00:00:00 2001 From: "Jaldhar H. Vyas" Date: Mon, 3 Jun 2024 23:29:43 -0400 Subject: Challenge 272 by Jaldhar H. Vyas. --- challenge-272/jaldhar-h-vyas/blog.txt | 1 + challenge-272/jaldhar-h-vyas/perl/ch-1.sh | 3 +++ challenge-272/jaldhar-h-vyas/perl/ch-2.pl | 12 ++++++++++++ challenge-272/jaldhar-h-vyas/raku/ch-1.sh | 3 +++ challenge-272/jaldhar-h-vyas/raku/ch-2.raku | 14 ++++++++++++++ 5 files changed, 33 insertions(+) create mode 100644 challenge-272/jaldhar-h-vyas/blog.txt create mode 100755 challenge-272/jaldhar-h-vyas/perl/ch-1.sh create mode 100755 challenge-272/jaldhar-h-vyas/perl/ch-2.pl create mode 100755 challenge-272/jaldhar-h-vyas/raku/ch-1.sh create mode 100755 challenge-272/jaldhar-h-vyas/raku/ch-2.raku diff --git a/challenge-272/jaldhar-h-vyas/blog.txt b/challenge-272/jaldhar-h-vyas/blog.txt new file mode 100644 index 0000000000..71371aa4bb --- /dev/null +++ b/challenge-272/jaldhar-h-vyas/blog.txt @@ -0,0 +1 @@ +https://www.braincells.com/perl/2024/06/perl_weekly_challenge_week_272.html diff --git a/challenge-272/jaldhar-h-vyas/perl/ch-1.sh b/challenge-272/jaldhar-h-vyas/perl/ch-1.sh new file mode 100755 index 0000000000..9ded32b637 --- /dev/null +++ b/challenge-272/jaldhar-h-vyas/perl/ch-1.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +perl -E '$_=shift;s/\./[.]/g;say' "$@" diff --git a/challenge-272/jaldhar-h-vyas/perl/ch-2.pl b/challenge-272/jaldhar-h-vyas/perl/ch-2.pl new file mode 100755 index 0000000000..331c6174e8 --- /dev/null +++ b/challenge-272/jaldhar-h-vyas/perl/ch-2.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +use v5.38; + +my $str = shift; +my @chars = split //, $str; +my $score; + +for my $i (0 .. scalar @chars - 2) { + $score += abs(ord($chars[$i]) - ord($chars[$i + 1])); +} + +say $score; diff --git a/challenge-272/jaldhar-h-vyas/raku/ch-1.sh b/challenge-272/jaldhar-h-vyas/raku/ch-1.sh new file mode 100755 index 0000000000..ea29eb6c03 --- /dev/null +++ b/challenge-272/jaldhar-h-vyas/raku/ch-1.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +raku -e 'say @*ARGS[0].subst(".", "[.]",:g)' "$@" diff --git a/challenge-272/jaldhar-h-vyas/raku/ch-2.raku b/challenge-272/jaldhar-h-vyas/raku/ch-2.raku new file mode 100755 index 0000000000..16618ecccd --- /dev/null +++ b/challenge-272/jaldhar-h-vyas/raku/ch-2.raku @@ -0,0 +1,14 @@ +#!/usr/bin/raku + +sub MAIN( + $str +) { + my @chars = $str.comb; + my $score; + + for @chars.skip(1).keys -> $i { + $score += (@chars[$i].ord - @chars[$i + 1].ord).abs; + } + + say $score; +} \ No newline at end of file -- cgit From da49573769684a6facb64cdb6cb267b59086e76d Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Tue, 4 Jun 2024 02:33:34 -0400 Subject: TWC272 --- challenge-272/deadmarshal/blog.txt | 1 + challenge-272/deadmarshal/java/Ch1.java | 7 +++++ challenge-272/deadmarshal/java/Ch2.java | 16 ++++++++++++ challenge-272/deadmarshal/lua/ch-1.lua | 10 ++++++++ challenge-272/deadmarshal/lua/ch-2.lua | 16 ++++++++++++ challenge-272/deadmarshal/modula-3/ch1/src/Ch1.m3 | 30 ++++++++++++++++++++++ .../deadmarshal/modula-3/ch1/src/m3makefile | 5 ++++ challenge-272/deadmarshal/modula-3/ch2/src/Ch2.m3 | 19 ++++++++++++++ .../deadmarshal/modula-3/ch2/src/m3makefile | 5 ++++ challenge-272/deadmarshal/perl/ch-1.pl | 11 ++++++++ challenge-272/deadmarshal/perl/ch-2.pl | 14 ++++++++++ challenge-272/deadmarshal/raku/ch-1.raku | 10 ++++++++ challenge-272/deadmarshal/raku/ch-2.raku | 16 ++++++++++++ 13 files changed, 160 insertions(+) create mode 100644 challenge-272/deadmarshal/blog.txt create mode 100644 challenge-272/deadmarshal/java/Ch1.java create mode 100644 challenge-272/deadmarshal/java/Ch2.java create mode 100644 challenge-272/deadmarshal/lua/ch-1.lua create mode 100644 challenge-272/deadmarshal/lua/ch-2.lua create mode 100644 challenge-272/deadmarshal/modula-3/ch1/src/Ch1.m3 create mode 100644 challenge-272/deadmarshal/modula-3/ch1/src/m3makefile create mode 100644 challenge-272/deadmarshal/modula-3/ch2/src/Ch2.m3 create mode 100644 challenge-272/deadmarshal/modula-3/ch2/src/m3makefile create mode 100644 challenge-272/deadmarshal/perl/ch-1.pl create mode 100644 challenge-272/deadmarshal/perl/ch-2.pl create mode 100644 challenge-272/deadmarshal/raku/ch-1.raku create mode 100644 challenge-272/deadmarshal/raku/ch-2.raku diff --git a/challenge-272/deadmarshal/blog.txt b/challenge-272/deadmarshal/blog.txt new file mode 100644 index 0000000000..dbb200ed12 --- /dev/null +++ b/challenge-272/deadmarshal/blog.txt @@ -0,0 +1 @@ +https://deadmarshal.blogspot.com/2024/06/twc272.html diff --git a/challenge-272/deadmarshal/java/Ch1.java b/challenge-272/deadmarshal/java/Ch1.java new file mode 100644 index 0000000000..6f589b0407 --- /dev/null +++ b/challenge-272/deadmarshal/java/Ch1.java @@ -0,0 +1,7 @@ +public class Ch1 { + public static void main(String[] args) { + System.out.println("1.1.1.1".replaceAll("\\.", "[.]")); + System.out.println("255.101.1.0".replaceAll("\\.", "[.]")); + } +} + diff --git a/challenge-272/deadmarshal/java/Ch2.java b/challenge-272/deadmarshal/java/Ch2.java new file mode 100644 index 0000000000..91614ab462 --- /dev/null +++ b/challenge-272/deadmarshal/java/Ch2.java @@ -0,0 +1,16 @@ +public class Ch2 { + public static void main(String[] args) { + System.out.println(string_score("hello")); + System.out.println(string_score("perl")); + System.out.println(string_score("raku")); + } + + private static int string_score(String str) { + int sum = 0; + for (int i = 0; i < str.length() - 1; ++i) { + sum += Math.abs(str.charAt(i + 1) - str.charAt(i)); + } + return sum; + } +} + diff --git a/challenge-272/deadmarshal/lua/ch-1.lua b/challenge-272/deadmarshal/lua/ch-1.lua new file mode 100644 index 0000000000..0269798b42 --- /dev/null +++ b/challenge-272/deadmarshal/lua/ch-1.lua @@ -0,0 +1,10 @@ +#!/usr/bin/env lua + +local function defrag_ip_address(str) + assert(type(str) == 'string','str must be a string!') + return (str:gsub("%.","[.]")) +end + +print(defrag_ip_address('1.1.1.1')) +print(defrag_ip_address('255.101.1.0')) + diff --git a/challenge-272/deadmarshal/lua/ch-2.lua b/challenge-272/deadmarshal/lua/ch-2.lua new file mode 100644 index 0000000000..059197dbfd --- /dev/null +++ b/challenge-272/deadmarshal/lua/ch-2.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env lua + +local function string_score(str) + assert(type(str) == 'string','str must be a string!') + local sum = 0 + for i=1,#str-1 do + sum = sum + math.abs(string.byte(str:sub(i+1,i+1)) + - string.byte(str:sub(i,i))) + end + return sum +end + +print(string_score('hello')) +print(string_score('perl')) +print(string_score('raku')) + diff --git a/challenge-272/deadmarshal/modula-3/ch1/src/Ch1.m3 b/challenge-272/deadmarshal/modula-3/ch1/src/Ch1.m3 new file mode 100644 index 0000000000..57909c2830 --- /dev/null +++ b/challenge-272/deadmarshal/modula-3/ch1/src/Ch1.m3 @@ -0,0 +1,30 @@ +MODULE Ch1 EXPORTS Main; + +IMPORT SIO,Text,CharSeq; + +PROCEDURE DefragIpAddress(READONLY t:TEXT):TEXT = + VAR + Seq:CharSeq.T := NEW(CharSeq.T).init(Text.Length(t)); + A:REF ARRAY OF CHAR; + C:CHAR; + BEGIN + FOR I := 0 TO Text.Length(t)-1 DO + C := Text.GetChar(t,I); + IF C = '.' THEN + Seq.addhi('['); + Seq.addhi(C); + Seq.addhi(']') + ELSE + Seq.addhi(C) + END; + END; + A := NEW(REF ARRAY OF CHAR,Seq.size()); + FOR I := 0 TO Seq.size()-1 DO A[I] := Seq.get(I) END; + RETURN Text.FromChars(A^) + END DefragIpAddress; + +BEGIN + SIO.PutText(DefragIpAddress("1.1.1.1") & "\n"); + SIO.PutText(DefragIpAddress("255.101.1.0") & "\n"); +END Ch1. + diff --git a/challenge-272/deadmarshal/modula-3/ch1/src/m3makefile b/challenge-272/deadmarshal/modula-3/ch1/src/m3makefile new file mode 100644 index 0000000000..9f66e4a51f --- /dev/null +++ b/challenge-272/deadmarshal/modula-3/ch1/src/m3makefile @@ -0,0 +1,5 @@ +import("libm3") +import("libsio") +implementation("Ch1") +program("ch1") + diff --git a/challenge-272/deadmarshal/modula-3/ch2/src/Ch2.m3 b/challenge-272/deadmarshal/modula-3/ch2/src/Ch2.m3 new file mode 100644 index 0000000000..d59307e562 --- /dev/null +++ b/challenge-272/deadmarshal/modula-3/ch2/src/Ch2.m3 @@ -0,0 +1,19 @@ +MODULE Ch2 EXPORTS Main; + +IMPORT SIO,Text; + +PROCEDURE StringScore(READONLY t:TEXT):INTEGER = + VAR Sum:INTEGER := 0; + BEGIN + FOR I := 0 TO Text.Length(t)-2 DO + INC(Sum,ABS(ORD(Text.GetChar(t,I+1)) - ORD(Text.GetChar(t,I)))) + END; + RETURN Sum + END StringScore; + +BEGIN + SIO.PutInt(StringScore("hello")); SIO.Nl(); + SIO.PutInt(StringScore("perl")); SIO.Nl(); + SIO.PutInt(StringScore("raku")); SIO.Nl() +END Ch2. + diff --git a/challenge-272/deadmarshal/modula-3/ch2/src/m3makefile b/challenge-272/deadmarshal/modula-3/ch2/src/m3makefile new file mode 100644 index 0000000000..798c627ef3 --- /dev/null +++ b/challenge-272/deadmarshal/modula-3/ch2/src/m3makefile @@ -0,0 +1,5 @@ +import("libm3") +import("libsio") +implementation("Ch2") +program("ch2") + diff --git a/challenge-272/deadmarshal/perl/ch-1.pl b/challenge-272/deadmarshal/perl/ch-1.pl new file mode 100644 index 0000000000..cd1f537594 --- /dev/null +++ b/challenge-272/deadmarshal/perl/ch-1.pl @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +sub defrag_ip_address{ + $_[0] =~ s/\./\[\.\]/gr +} + +printf "%s\n",defrag_ip_address('1.1.1.1'); +printf "%s\n",defrag_ip_address('255.101.1.0'); + diff --git a/challenge-272/deadmarshal/perl/ch-2.pl b/challenge-272/deadmarshal/perl/ch-2.pl new file mode 100644 index 0000000000..bc0e36b06c --- /dev/null +++ b/challenge-272/deadmarshal/perl/ch-2.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use List::Util qw(sum0); +use List::MoreUtils qw(slide); + +sub string_score{ + sum0 slide {abs(ord($b) - ord($a))} split '',$_[0] +} + +printf "%d\n",string_score('hello'); +printf "%d\n",string_score('perl'); +printf "%d\n",string_score('raku'); + diff --git a/challenge-272/deadmarshal/raku/ch-1.raku b/challenge-272/deadmarshal/raku/ch-1.raku new file mode 100644 index 0000000000..1017df67ae --- /dev/null +++ b/challenge-272/deadmarshal/raku/ch-1.raku @@ -0,0 +1,10 @@ +#!/usr/bin/env raku + +sub defrag-ip-address($str) +{ + $str.subst('.','[.]',:g) +} + +say defrag-ip-address('1.1.1.1'); +say defrag-ip-address('255.101.1.0'); + diff --git a/challenge-272/deadmarshal/raku/ch-2.raku b/challenge-272/deadmarshal/raku/ch-2.raku new file mode 100644 index 0000000000..1760ab24a7 --- /dev/null +++ b/challenge-272/deadmarshal/raku/ch-2.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku + +sub string-score($str) +{ + my @arr = $str.ords; + my $sum = 0; + for 0..^@arr.end -> $i { + $sum += abs(@arr[$i+1] - @arr[$i]) + } + $sum +} + +say string-score('hello'); +say string-score('perl'); +say string-score('raku'); + -- cgit From aec548f13603c5b8d9c47c6baef4d6aa7ccb03d0 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 4 Jun 2024 11:38:41 +0100 Subject: add couple tests --- challenge-272/steven-wilson/python/ch-2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/challenge-272/steven-wilson/python/ch-2.py b/challenge-272/steven-wilson/python/ch-2.py index f92d1c2528..c7e8c2f102 100644 --- a/challenge-272/steven-wilson/python/ch-2.py +++ b/challenge-272/steven-wilson/python/ch-2.py @@ -12,10 +12,11 @@ def string_score(string): 30 >>> string_score('raku') 37 + >>> string_score('') + 0 + >>> string_score("*") + 0 ''' - if len(string) < 2: - raise ValueError("String argument should have at least 2 characters.") - return sum(abs(ord(a) - ord(b)) for a, b in zip(string, string[1:])) -- cgit From 6df20ab470a59710a2f39c47c88a3f73c716f57c Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 4 Jun 2024 11:39:01 +0100 Subject: - Added solutions by Mark Anderson. - Added solutions by Niels van Dijke. - Added solutions by Eric Cheung. - Added solutions by Laurent Rosenfeld. - Added solutions by E. Choroba. - Added solutions by Feng Chang. - Added solutions by W. Luis Mochan. - Added solutions by Steven Wilson. - Added solutions by Peter Meszaros. - Added solutions by Peter Campbell Smith. - Added solutions by David Ferrone. - Added solutions by Matthew Neleigh. - Added solutions by Thomas Kohler. - Added solutions by Ali Moradi. - Added solutions by Dave Jacoby. - Added solutions by Jaldhar H. Vyas. --- challenge-272/eric-cheung/python/ch-1.py | 7 + challenge-272/eric-cheung/python/ch-2.py | 9 + challenge-272/laurent-rosenfeld/blog.txt | 1 + challenge-272/laurent-rosenfeld/perl/ch-1.pl | 14 + challenge-272/laurent-rosenfeld/raku/ch-1.raku | 10 + challenge-272/perlboy1967/perl/ch-1.pl | 38 + challenge-272/perlboy1967/perl/ch-2.pl | 40 + challenge-272/perlboy1967/perl/ch1.pl | 38 - challenge-272/perlboy1967/perl/ch2.pl | 40 - stats/pwc-challenge-271.json | 646 ++++++++ stats/pwc-current.json | 493 +------ stats/pwc-language-breakdown-summary.json | 64 +- stats/pwc-language-breakdown.json | 1881 ++++++++++++------------ stats/pwc-leaders.json | 526 +++---- stats/pwc-summary-1-30.json | 114 +- stats/pwc-summary-121-150.json | 46 +- stats/pwc-summary-151-180.json | 54 +- stats/pwc-summary-181-210.json | 102 +- stats/pwc-summary-211-240.json | 106 +- stats/pwc-summary-241-270.json | 30 +- stats/pwc-summary-271-300.json | 108 +- stats/pwc-summary-301-330.json | 36 +- stats/pwc-summary-31-60.json | 32 +- stats/pwc-summary-61-90.json | 56 +- stats/pwc-summary-91-120.json | 52 +- stats/pwc-summary.json | 82 +- 26 files changed, 2499 insertions(+), 2126 deletions(-) create mode 100755 challenge-272/eric-cheung/python/ch-1.py create mode 100755 challenge-272/eric-cheung/python/ch-2.py create mode 100644 challenge-272/laurent-rosenfeld/blog.txt create mode 100644 challenge-272/laurent-rosenfeld/perl/ch-1.pl create mode 100644 challenge-272/laurent-rosenfeld/raku/ch-1.raku create mode 100755 challenge-272/perlboy1967/perl/ch-1.pl create mode 100755 challenge-272/perlboy1967/perl/ch-2.pl delete mode 100755 challenge-272/perlboy1967/perl/ch1.pl delete mode 100755 challenge-272/perlboy1967/perl/ch2.pl create mode 100644 stats/pwc-challenge-271.json diff --git a/challenge-272/eric-cheung/python/ch-1.py b/challenge-272/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..6ac6998ad4 --- /dev/null +++ b/challenge-272/eric-cheung/python/ch-1.py @@ -0,0 +1,7 @@ + +## strIP = "1.1.1.1" ## Example 1 +strIP = "255.101.1.0" ## Example 2 + +strOutput = strIP.replace(".", "[.]") + +print (strOutput) diff --git a/challenge-272/eric-cheung/python/ch-2.py b/challenge-272/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..52f8329ed9 --- /dev/null +++ b/challenge-272/eric-cheung/python/ch-2.py @@ -0,0 +1,9 @@ + +## strInput = "hello" ## Example 1 +## strInput = "perl" ## Example 2 +strInput = "raku" ## Example 3 + +arrCode = [ord(charLoop) for charLoop in strInput] +arrCodeAbsDiff = [abs(arrCode[nIndx] - arrCode[nIndx + 1]) for nIndx in range(len(arrCode) - 1)] + +print (sum(arrCodeAbsDiff)) diff --git a/challenge-272/laurent-rosenfeld/blog.txt b/challenge-272/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..6db0d8366f --- /dev/null +++ b/challenge-272/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +https://blogs.perl.org/users/laurent_r/2024/06/perl-weekly-challenge-272-defang-ip-address.html diff --git a/challenge-272/laurent-rosenfeld/perl/ch-1.pl b/challenge-272/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..41dd7d95fb --- /dev/null +++ b/challenge-272/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,14 @@ +use strict; +use warnings; +use feature 'say'; + +sub defang_ip { + $_[0] =~ s/\./[.]/g; + return $_[0] ; +} + +my @tests = ("1.1.1.1", "255.101.1.0", "255.255.255.255"); +for my $test (@tests) { + printf "%-16s => ", $test; + say defang_ip $test; +} diff --git a/challenge-272/laurent-rosenfeld/raku/ch-1.raku b/challenge-272/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..5059756751 --- /dev/null +++ b/challenge-272/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,10 @@ +sub defang-ip ($in is copy) { + $in ~~ s:g/\./[.]/; + return ~$in; +} + +my @tests = "1.1.1.1", "255.101.1.0", "255.255.255.255"; +for @tests -> $test { + printf "%-16s => ", $test; + say defang-ip $test; +} diff --git a/challenge-272/perlboy1967/perl/ch-1.pl b/challenge-272/perlboy1967/perl/ch-1.pl new file mode 100755 index 0000000000..39142f5b2f --- /dev/null +++ b/challenge-272/perlboy1967/perl/ch-1.pl @@ -0,0 +1,38 @@ +#!/bin/perl + +=pod + +The Weekly Challenge - 272 +- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 + +Author: Niels 'PerlBoy' van Dijke + +Task 1: Defrang IP Address +Submitted by: Mohammad Sajid Anwar + +You are given a valid IPv4 address. + +Write a script to return the defranged version of the given IP address. + +|| A defranged IP address replaces every period “.” with “[.]". + +=cut + +use v5.32; +use feature qw(signatures); +use common::sense; + +use Test2::V0 qw(-no_srand);; + +use Net::IP qw(ip_is_ipv4); + +sub defrangIpAddress ($ipv4) { + ip_is_ipv4($ipv4) ? $ipv4 =~ s#\.#[.]#gr : $ipv4; +} + +is(defrangIpAddress('1.1.1.1'),'1[.]1[.]1[.]1','Example 1'); +is(defrangIpAddress('255.101.1.0'),'255[.]101[.]1[.]0','Example 2'); +is(defrangIpAddress('dead::beaf'),'dead::beaf','Own example'); + +done_testing; + diff --git a/challenge-272/perlboy1967/perl/ch-2.pl b/challenge-272/perlboy1967/perl/ch-2.pl new file mode 100755 index 0000000000..6f877bffa4 --- /dev/null +++ b/challenge-272/perlboy1967/perl/ch-2.pl @@ -0,0 +1,40 @@ +#!/bin/perl + +=pod + +The Weekly Challenge - 272 +- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 + +Author: Niels 'PerlBoy' van Dijke + +Task 2: String Score +Submitted by: Mohammad Sajid Anwar + +You are given a string, $str. + +Write a script to return the score of the given string. + +|| The score of a string is defined as the sum of the absolute difference +|| between the ASCII values of adjacent characters. + +=cut + +use v5.32; +use feature qw(signatures); +use common::sense; + +use Test2::V0 qw(-no_srand);; + +use List::Util qw(sum0); +use List::MoreUtils qw(slide); + +sub stringScore ($str) { + sum0 slide { abs(ord($a) - ord($b)) } split //, $str; +} + +is(stringScore('hello'),13,'Example 1'); +is(stringScore('perl'),30,'Example 2'); +is(stringScore('raku'),37,'Example 3'); + +done_testing; + diff --git a/challenge-272/perlboy1967/perl/ch1.pl b/challenge-272/perlboy1967/perl/ch1.pl deleted file mode 100755 index 39142f5b2f..0000000000 --- a/challenge-272/perlboy1967/perl/ch1.pl +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/perl - -=pod - -The Weekly Challenge - 272 -- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 - -Author: Niels 'PerlBoy' van Dijke - -Task 1: Defrang IP Address -Submitted by: Mohammad Sajid Anwar - -You are given a valid IPv4 address. - -Write a script to return the defranged version of the given IP address. - -|| A defranged IP address replaces every period “.” with “[.]". - -=cut - -use v5.32; -use feature qw(signatures); -use common::sense; - -use Test2::V0 qw(-no_srand);; - -use Net::IP qw(ip_is_ipv4); - -sub defrangIpAddress ($ipv4) { - ip_is_ipv4($ipv4) ? $ipv4 =~ s#\.#[.]#gr : $ipv4; -} - -is(defrangIpAddress('1.1.1.1'),'1[.]1[.]1[.]1','Example 1'); -is(defrangIpAddress('255.101.1.0'),'255[.]101[.]1[.]0','Example 2'); -is(defrangIpAddress('dead::beaf'),'dead::beaf','Own example'); - -done_testing; - diff --git a/challenge-272/perlboy1967/perl/ch2.pl b/challenge-272/perlboy1967/perl/ch2.pl deleted file mode 100755 index 6f877bffa4..0000000000 --- a/challenge-272/perlboy1967/perl/ch2.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/perl - -=pod - -The Weekly Challenge - 272 -- https://theweeklychallenge.org/blog/perl-weekly-challenge-272 - -Author: Niels 'PerlBoy' van Dijke - -Task 2: String Score -Submitted by: Mohammad Sajid Anwar - -You are given a string, $str. - -Write a script to return the score of the given string. - -|| The score of a string is defined as the sum of the absolute difference -|| between the ASCII values of adjacent characters. - -=cut - -use v5.32; -use feature qw(signatures); -use common::sense; - -use Test2::V0 qw(-no_srand);; - -use List::Util qw(sum0); -use List::MoreUtils qw(slide); - -sub stringScore ($str) { - sum0 slide { abs(ord($a) - ord($b)) } split //, $str; -} - -is(stringScore('hello'),13,'Example 1'); -is(stringScore('perl'),30,'Example 2'); -is(stringScore('raku'),37,'Example 3'); - -done_testing; - diff --git a/stats/pwc-challenge-271.json b/stats/pwc-challenge-271.json new file mode 100644 index 0000000000..157181b85e --- /dev/null +++ b/stats/pwc-challenge-271.json @@ -0,0 +1,646 @@ +{ + "drilldown" : { + "series" : [ + { + "id" : "Ali Moradi", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Ali Moradi" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Arne Sommer", + "id" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Athanasius" + }, + { + "name" : "ATSchneider", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "ATSchneider" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "BarrOff", + "id" : "BarrOff" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Bob Lied", + "id" : "Bob Lied" + }, + { + "id" : "Bruce Gray", + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Bruce Gray" + }, + { + "id" : "Cheok-Yin Fung", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Cheok-Yin Fung" + }, + { + "id" : "Dave Jacoby", + "name" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "David Ferrone", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "David Ferrone" + }, + { + "id" : "E. Choroba", + "name" : "E. Choroba", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Feng Chang", + "id" : "Feng Chang" + }, + { + "name" : "Jaldhar H. Vyas", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jaldhar H. Vyas" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Jan Krnavek", + "id" : "Jan Krnavek" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Jorg Sommrey", + "id" : "Jorg Sommrey" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ], + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld" + }, + { + "id" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 9 + ] + ], + "name" : "Luca Ferrari" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Mariano Spadaccini", + "id" : "Mariano Spadaccini" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Mark Anderson", + "id" : "Mark Anderson" + }, + { + "id" : "Matthew Neleigh", + "name" : "Matthew Neleigh", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Matthias Muth", + "id" : "Matthias Muth" + }, + { + "id" : "Nelo Tovar", + "name" : "Nelo Tovar", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Niels van Dijke", + "name" : "Niels van Dijke", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Packy Anderson", + "id" : "Packy Anderson" + }, + { + "id" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Peter Campbell Smith" + }, + { + "id" : "Peter Meszaros", + "name" : "Peter Meszaros", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Reinier Maliepaard", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Reinier Maliepaard" + }, + { + "id" : "Robbie Hatley", + "name" : "Robbie Hatley", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Robert Ransbottom", + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Robert Ransbottom" + }, + { + "data" : [ + [ + "Perl", + 2 + ], +