From 832f991ce7c04c68d6a40279c17b6c2339f7df74 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 17 Aug 2020 05:08:11 -0700 Subject: Add some patterns to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 40a0244345..011bc9efd3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .DS_Store .vstags .*.swp +*~ +*.class -- cgit From 9d7d3140219f3ad3e3b9ca36f71e2518525eb721 Mon Sep 17 00:00:00 2001 From: wambash Date: Wed, 26 Aug 2020 11:37:47 +0200 Subject: Solution challenge 075 in progress --- challenge-075/wambash/raku/ch-1.raku | 69 ++++++++++++++++++++++++++++++++++++ challenge-075/wambash/raku/ch-2.raku | 18 ++++++++++ 2 files changed, 87 insertions(+) create mode 100644 challenge-075/wambash/raku/ch-1.raku create mode 100644 challenge-075/wambash/raku/ch-2.raku diff --git a/challenge-075/wambash/raku/ch-1.raku b/challenge-075/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..a21cc910f4 --- /dev/null +++ b/challenge-075/wambash/raku/ch-1.raku @@ -0,0 +1,69 @@ +use v6; + +class Attempt { + has @.coins; + has @.using; + has $.sum; +} + + +multi iter (Capture $c where *. == 0) { + $c, +} + +multi iter (Capture $c (:@coins,:$sum where * ≥ 0, :$used = bag()) ) { + \(|$c, sum => $sum-@coins.head, used => $used (+) @coins.head), + \(|$c, coins => @coins.skip), +} + + +multi iter (@a) { + @a + andthen .map: |*.&iter + andthen .grep: *..so + andthen .grep: *. ≥ 0 +} + +multi coins-sum (|c where *. == 0 --> Empty) {} +multi coins-sum (|c ) { + my $deep-to-sums-are-zero =c./c..min + c..elems; + (c,), *.&iter ... * + andthen .skip($deep-to-sums-are-zero) + andthen .head; + + #or this one, but it needs cache + #(c,), *.&iter.cache ... *.all. == 0 + #andthen .tail +} + +sub coins-sum-count ( :@coins!, :$sum! ) { + 0 xx *, + -> $a { + my $k=@coins[$++]; + |$a[^$k], $a[$k]+1, { @_[(++$)] + $a[($k+ ++$)] } ... * + } ... * + andthen .[@coins.elems;$sum] +} + +multi MAIN ( :$test!, :$log ) { + use Test; + + my $wi = &iter.wrap: -> $_ { + note .,.,..kxxv when Capture; + callsame() + } if $log; + + is coins-sum(:coins(1,2,4),:6sum).elems,6; + is-deeply coins-sum(:coins(1,13), :26sum).map( *.), ((1=>26).Bag, (13,1=>13).Bag, (13=>2).Bag); + $wi.restore() if $log; + ; + is coins-sum-count(:coins(1,2,4),:6sum) ,6; + is coins-sum-count(:coins(1,2,4,5),:120sum),8333; + for ^10 { + my @coins= (1..20).pick(3); + my $sum = ^100 .roll; + my $count = coins-sum-count(:@coins,:$sum); + is coins-sum(:@coins,:$sum).elems, $count, "elems = count = $count :{:@coins} :{:$sum}"; + } + done-testing(); +} diff --git a/challenge-075/wambash/raku/ch-2.raku b/challenge-075/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..b5baea0626 --- /dev/null +++ b/challenge-075/wambash/raku/ch-2.raku @@ -0,0 +1,18 @@ +use v6; + +sub largest-rectangle-histogram (+@a) { + @a, *.skip ...^ :!elems + andthen .map: { + $_.cache + andthen [\min] $_ + andthen 1..* Z* $_ + andthen .max + } andthen .max +} + +sub MAIN (:$test!) { + use Test; + is largest-rectangle-histogram( 2, 1, 4, 5, 3, 7 ), 12; + is largest-rectangle-histogram( 3, 2, 3, 5, 7, 5 ), 15; + done-testing(); +} -- cgit From 535f3755e029996ab915d8623fbd64c6de49336a Mon Sep 17 00:00:00 2001 From: PerlMonk Athanasius Date: Sat, 29 Aug 2020 04:56:29 -0700 Subject: Perl & Raku solutions to Tasks 1 & 2 of the Perl Weekly Challenge #075 On branch branch-for-challenge-075 Changes to be committed: new file: challenge-075/athanasius/perl/ch-1.pl new file: challenge-075/athanasius/perl/ch-2.pl new file: challenge-075/athanasius/raku/ch-1.raku new file: challenge-075/athanasius/raku/ch-2.raku --- challenge-075/athanasius/perl/ch-1.pl | 165 ++++++++++++++++++++++ challenge-075/athanasius/perl/ch-2.pl | 241 ++++++++++++++++++++++++++++++++ challenge-075/athanasius/raku/ch-1.raku | 155 ++++++++++++++++++++ challenge-075/athanasius/raku/ch-2.raku | 227 ++++++++++++++++++++++++++++++ 4 files changed, 788 insertions(+) create mode 100644 challenge-075/athanasius/perl/ch-1.pl create mode 100644 challenge-075/athanasius/perl/ch-2.pl create mode 100644 challenge-075/athanasius/raku/ch-1.raku create mode 100644 challenge-075/athanasius/raku/ch-2.raku diff --git a/challenge-075/athanasius/perl/ch-1.pl b/challenge-075/athanasius/perl/ch-1.pl new file mode 100644 index 0000000000..80426d36d0 --- /dev/null +++ b/challenge-075/athanasius/perl/ch-1.pl @@ -0,0 +1,165 @@ +#!perl + +################################################################################ +=comment + +Perl Weekly Challenge 075 +========================= + +Task #1 +------- +*Coins Sum* + +Submitted by: Mohammad S Anwar + +You are given a set of coins _@C_, assuming you have infinite amount of each +coin in the set. + +Write a script to find how many ways you make sum _$S_ using the coins from the +set _@C_. + +Example: + +Input: + @C = (1, 2, 4) + $S = 6 + +Output: 6 +There are 6 possible ways to make sum 6. +a) (1, 1, 1, 1, 1, 1) +b) (1, 1, 1, 1, 2) +c) (1, 1, 2, 2) +d) (1, 1, 4) +e) (2, 2, 2) +f) (2, 4) + +=cut +################################################################################ + +#--------------------------------------# +# Copyright © 2020 PerlMonk Athanasius # +#--------------------------------------# + + # Exports: +use strict; +use warnings; +use Const::Fast; # const() +use Getopt::Long; # GetOptions() +use Memoize; # memoize() +use Regexp::Common qw( number ); # %RE{num} + +const my $USAGE => +"Usage: + perl $0 [-S=] [ ...] + + -S= Target coin sum + [ ...] Non-empty set of coin denominations (Naturals <= S)\n"; + +#------------------------------------------------------------------------------- +BEGIN +#------------------------------------------------------------------------------- +{ + $| = 1; + print "\nChallenge 075, Task #1: Coins Sum (Perl)\n\n"; +} + +#=============================================================================== +MAIN: +#=============================================================================== +{ + my ($S, @C) = parse_command_line(); + + # Ensure that @C is a *set* by removing any duplicate coin values; also sort + # the values + + my %C = map { $_ => undef } @C; + @C = sort { $a <=> $b } keys %C; + + # For non-trivial cases, memoization vastly decreases computation time + + memoize('count_coin_combinations'); + + # Reversing the coin array -- so that the coins are processed in decreasing + # order, largest coins first, smallest coins last -- significantly reduces + # the total number of recursive calls to count_coin_combinations() + + my $total = count_coin_combinations($S, reverse @C); + + printf "There %s %s possible way%s to make the sum %s from the coin%s %s\n", + $total == 1 ? 'is' : 'are', + add_commas($total), + $total == 1 ? '' : 's', + add_commas($S), + scalar @C == 1 ? '' : 's', + join ', ', @C; +} + +#------------------------------------------------------------------------------- +sub count_coin_combinations # Recursive function +#------------------------------------------------------------------------------- +{ + my ($target, $coin, @coins) = @_; + my $sum = 0; + + if (scalar @coins) # There are more coins to process + { + for my $i (0 .. int($target / $coin)) + { + my $new_target = $target - ($i * $coin); + + if ($new_target == 0) # Base case 1: target already reached + { + ++$sum; + } + else # Recursive case + { + $sum += count_coin_combinations($new_target, @coins); + } + } + } + else # Base case 2: no more coins + { + $sum = 1 if $target % $coin == 0; + } + + return $sum; +} + +#------------------------------------------------------------------------------- +sub parse_command_line +#------------------------------------------------------------------------------- +{ + my $S; + + GetOptions('S=i' => \$S) or die $USAGE; + + my @C = @ARGV; + + scalar @C > 0 or die $USAGE; + is_natural($S) or die $USAGE; + is_natural($_) && $_ <= $S or die $USAGE for @C; + + return ($S, @C); +} + +#------------------------------------------------------------------------------- +sub is_natural +#------------------------------------------------------------------------------- +{ + my ($n) = @_; + + return defined($n) && $n =~ / \A $RE{num}{int} \z /x && $n > 0; +} + +#------------------------------------------------------------------------------- +sub add_commas +#------------------------------------------------------------------------------- +{ + my ($number) = @_; + + # Regex from perlfaq5: "How can I output my numbers with commas added?" + + return $number =~ s/(^\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/gr; +} + +################################################################################ diff --git a/challenge-075/athanasius/perl/ch-2.pl b/challenge-075/athanasius/perl/ch-2.pl new file mode 100644 index 0000000000..6bc930cc1b --- /dev/null +++ b/challenge-075/athanasius/perl/ch-2.pl @@ -0,0 +1,241 @@ +#!perl + +################################################################################ +=comment + +Perl Weekly Challenge 075 +========================= + +Task #2 +------- +*Largest Rectangle Histogram* + +Submitted by: Mohammad S Anwar + +You are given an array of positive numbers _@A_. + +Write a script to find the large[s]t rectangle histogram created by the given +array. + +BONUS: Try to print the histogram as shown in the example, if possible. + +Example 1: + +Input: @A = (2, 1, 4, 5, 3, 7) + + 7 # + 6 # + 5 # # + 4 # # # + 3 # # # # + 2 # # # # # + 1 # # # # # # + _ _ _ _ _ _ _ + 2 1 4 5 3 7 + +Looking at the above histogram, the largest rectangle (4 x 3) is formed by +columns (4, 5, 3 and 7). + +Output: 12 + +Example 2: + +Input: @A = (3, 2, 3, 5, 7, 5) + + 7 # + 6 # + 5 # # # + 4 # # # + 3 # # # # # + 2 # # # # # # + 1 # # # # # # + _ _ _ _ _ _ _ + 3 2 3 5 7 5 + +Looking at the above histogram, the largest rectangle (3 x 5) is formed by +columns (5, 7 and 5). + +Output: 15 + +=cut +################################################################################ + +#--------------------------------------# +# Copyright © 2020 PerlMonk Athanasius # +#--------------------------------------# + +use strict; +use warnings; +use Const::Fast; # Exports const() +use List::MoreUtils qw( pairwise ); +use List::Util qw( max ); +use Regexp::Common qw( number ); # Exports %RE{num} + +const my $USAGE => +"Usage: + perl $0 [ ...] + + [ ...] Non-empty sequence of positive integers\n"; + +const my $MAX_COLUMNS => 38; # (For my particular command-line screen setup) +const my $MAX_HEIGHT => 31; # N.B.: The logic in print_histogram() below + # assumes that $MAX_HEIGHT < 100 + +#------------------------------------------------------------------------------- +BEGIN +#------------------------------------------------------------------------------- +{ + $| = 1; + print "\nChallenge 075, Task #2: Largest Rectangle Histogram (Perl)\n\n"; +} + +#=============================================================================== +MAIN: +#=============================================================================== +{ + my @A = parse_command_line(); + + print_histogram(@A); + + my $rect = find_largest_rectangle(@A); + + if ($rect->{area} == 0) + { + print "\nThe histogram contains no rectangles\n\nArea: 0\n"; + } + else + { + printf "\nThe largest rectangle (%d x %d) has corners at (C%d, R1) " . + "and (C%d, R%d)\n\nArea: %d\n", + @{$rect}{ qw( width row_r col_l col_r row_r area ) }; + } +} + +#=============================================================================== +=comment + +Assumptions +----------- + +1. A single column (vertical bar) is a rectangle of width 1. +2. If two or more rectangles have the maximum area, only the first to be found + is given as "the largest rectangle". + +Algorithm +--------- + +In a histogram, all bars are anchored in the first row, from which it follows +that any candidate for largest rectangle must have 2 of its 4 corners in the +first row. (If the rectangle is a single bar, its left and right lower corners +are identical.) A rectangle can be uniquely specified by any 2 diagonally- +opposite corners. In the solution below, these are the bottom left and top right +corners. + +To check a given column C: for each row R in C, find the longest unbroken line +of non-empty squares to the immediate right of (C, R). Suppose the line for row +R ends in column D. Then the rectangle has corners (C, 1) and (D, R); the width +is D - C + 1; and the height is R. + +Any column C to the right of the first needs to be checked iff A[c] > A[c-1], +because otherwise it's already been included in a check for a previous column. +By the same logic, if column C does need to be checked at all, only those rows > +A[c-1] need be checked. + +=cut +#=============================================================================== + +#------------------------------------------------------------------------------- +sub find_largest_rectangle +#------------------------------------------------------------------------------- +{ + my @A = @_; + my @keys = qw( col_l col_r row_r width area ); + my %max = map { $_ => 0 } @keys; + + for my $col_l (0 .. $#A) + { + my $prev_row = $col_l ? $A[$col_l - 1] : 0; + my $this_row = $A[$col_l]; + + if ($col_l == 0 || $this_row > $prev_row) + { + for my $row ($prev_row + 1 .. $this_row) + { + my $width = 1; + my $col_r = $col_l; + + INNER: for my $col ($col_l + 1 .. $#A) + { + if ($A[$col] >= $row) + { + ++$col_r; + ++$width; + } + else + { + last INNER; + } + } + + if ((my $area = $width * $row) > $max{area}) + { + my @new = ($col_l + 1, $col_r + 1, $row, $width, $area); + %max = pairwise { $a => $b } @keys, @new; + } + } + } + } + + return \%max; +} + +#------------------------------------------------------------------------------- +sub print_histogram +#------------------------------------------------------------------------------- +{ + my @A = @_; + my $columns = scalar @A; + my $max_height = max @A; + + if ($columns <= $MAX_COLUMNS && + $max_height <= $MAX_HEIGHT) + { + for my $row (reverse 1 .. $max_height) + { + printf " %2d", $row; + print $_ >= $row ? ' #' : ' ' for @A; + print "\n"; + } + + printf " _%s\n", ' _' x $columns; + + if ($max_height < 10) + { + printf " %s\n", join ' ', @A; + } + else + { + printf " %s\n", join ' ', map { int($_ / 10) || ' ' } @A; + printf " %s\n", join ' ', map { $_ % 10 } @A; + } + } + else + { + printf "The histogram is too %s to print on a single screen\n", + $columns > $MAX_COLUMNS ? 'wide' : 'tall'; + } +} + +#------------------------------------------------------------------------------- +sub parse_command_line +#------------------------------------------------------------------------------- +{ + my @A = @ARGV; + + scalar @A > 0 or die $USAGE; + defined($_) && /\A$RE{num}{int}\z/ && $_ >= 0 or die $USAGE for @A; + + return @A; +} + +################################################################################ diff --git a/challenge-075/athanasius/raku/ch-1.raku b/challenge-075/athanasius/raku/ch-1.raku new file mode 100644 index 0000000000..ee196fe281 --- /dev/null +++ b/challenge-075/athanasius/raku/ch-1.raku @@ -0,0 +1,155 @@ +use v6d; + +################################################################################ +=begin comment + +Perl Weekly Challenge 075 +========================= + +Task #1 +------- +*Coins Sum* + +Submitted by: Mohammad S Anwar + +You are given a set of coins _@C_, assuming you have infinite amount of each +coin in the set. + +Write a script to find how many ways you make sum _$S_ using the coins from the +set _@C_. + +Example: + +Input: + @C = (1, 2, 4) + $S = 6 + +Output: 6 +There are 6 possible ways to make sum 6. +a) (1, 1, 1, 1, 1, 1) +b) (1, 1, 1, 1, 2) +c) (1, 1, 2, 2) +d) (1, 1, 4) +e) (2, 2, 2) +f) (2, 4) + +=end comment +################################################################################ + +#--------------------------------------# +# Copyright © 2020 PerlMonk Athanasius # +#--------------------------------------# + +use Memoize; + +subset Natural of UInt where * > 0; + +#------------------------------------------------------------------------------- +BEGIN +#------------------------------------------------------------------------------- +{ + "\nChallenge 075, Task #1: Coins Sum (Raku)\n".put; +} + +##============================================================================== +sub MAIN +( + Natural:D :$S, #= Target coin sum + *@C where { @C.elems > 0 && #= Non-empty set of coin + @C.all ~~ Natural:D && #= denominations (Naturals <= S) + @C.all <= $S } +) +##============================================================================== +{ + # Ensure that @C is a *set* by removing any duplicate coin values; also sort + # the values + + my Nil %C = @C.map: { $_ => Nil }; + + @C = %C.keys.sort( { .Int } ).map: { .UInt }; + + # For non-trivial cases, memoization vastly decreases computation time + + memoize(&count-coin-combinations); + + # Reversing the coin array -- so that the coins are processed in decreasing + # order, largest coins first, smallest coins last -- significantly reduces + # the total number of recursive calls to count_coin_combinations() + + my UInt $total = count-coin-combinations($S, [ @C.reverse ]); + + "There %s %s possible way%s to make the sum %s from the coin%s %s\n".printf: + $total == 1 ?? 'is' !! 'are', + add-commas($total), + $total == 1 ?? '' !! 's', + add-commas($S), + @C.elems == 1 ?? '' !! 's', + @C.join: ', '; +} + +#------------------------------------------------------------------------------- +sub count-coin-combinations +( + Natural:D $target, + Array:D[Natural:D] $coins, +--> UInt:D +) +#------------------------------------------------------------------------------- +{ + my UInt $sum = 0; + + my Natural $coin = $coins.shift; + + if $coins.elems > 0 # There are more coins to process + { + for 0 .. floor($target / $coin) -> UInt $i + { + my UInt $new-target = $target - ($i * $coin); + + if $new-target == 0 # Base case 1: target already reached + { + ++$sum; + } + else # Recursive case + { + # Note: $coins is an Array object, and therefore a reference; to + # pass it by value -- as required here -- it is necessary to + # make a copy (clone); otherwise, the effect of shift() above + # will propagate to recursive calls higher (i.e., earlier) in + # the call hierarchy, leaving $coins in an incorrect state when + # those calls are eventually made. + + $sum += count-coin-combinations($new-target, $coins.clone); + } + } + } + else # Base case 2: no more coins + { + $sum = 1 if $target % $coin == 0; + } + + return $sum; +} + +#------------------------------------------------------------------------------- +sub USAGE() +#------------------------------------------------------------------------------- +{ + my Str $usage = $*USAGE; + + $usage ~~ s/ ($*PROGRAM-NAME) /raku $0/; + $usage.put; +} + +#------------------------------------------------------------------------------- +sub add-commas(UInt:D $number --> Str:D) +#------------------------------------------------------------------------------- +{ + # From https://rosettacode.org/wiki/Commatizing_numbers#Raku + + return $number.subst: :1st, + / <[ 1 .. 9 ]> <[ 0 .. 9 ]>* /, + *.flip.comb( /<{ '. ** 1..3' }>/ ).join( ',' ).flip; +} + +################################################################################ diff --git a/challenge-075/athanasius/raku/ch-2.raku b/challenge-075/athanasius/raku/ch-2.raku new file mode 100644 index 0000000000..c13c132541 --- /dev/null +++ b/challenge-075/athanasius/raku/ch-2.raku @@ -0,0 +1,227 @@ +use v6d; + +################################################################################ +=begin comment + +Perl Weekly Challenge 075 +========================= + +Task #2 +------- +*Largest Rectangle Histogram* + +Submitted by: Mohammad S Anwar + +You are given an array of positive numbers _@A_. + +Write a script to find the large[s]t rectangle histogram created by the given +array. + +BONUS: Try to print the histogram as shown in the example, if possible. + +Example 1: + +Input: @A = (2, 1, 4, 5, 3, 7) + + 7 # + 6 # + 5 # # + 4 # # # + 3 # # # # + 2 # # # # # + 1 # # # # # # + _ _ _ _ _ _ _ + 2 1 4 5 3 7 + +Looking at the above histogram, the largest rectangle (4 x 3) is formed by +columns (4, 5, 3 and 7). + +Output: 12 + +Example 2: + +Input: @A = (3, 2, 3, 5, 7, 5) + + 7 # + 6 # + 5 # # # + 4 # # # + 3 # # # # # + 2 # # # # # # + 1 # # # # # # + _ _ _ _ _ _ _ + 3 2 3 5 7 5 + +Looking at the above histogram, the largest rectangle (3 x 5) is formed by +columns (5, 7 and 5). + +Output: 15 + +=end comment +################################################################################ + +#--------------------------------------# +# Copyright © 2020 PerlMonk Athanasius # +#--------------------------------------# + +use List::UtilsBy ; + +my UInt constant $MAX-COLUMNS = 38; # (For my particular command-line setup) +my UInt constant $MAX-HEIGHT = 31; # N.B.: The logic in print-histogram() + # below assumes $MAX-HEIGHT < 100 + +#------------------------------------------------------------------------------- +BEGIN +#------------------------------------------------------------------------------- +{ + "\nChallenge 075, Task #2: Largest Rectangle Histogram (Raku)\n".put; +} + +##============================================================================== +sub MAIN +( + *@A where { @A.elems > 0 && #= Non-empty sequence of positive integers + @A.all ~~ UInt:D } +) +##============================================================================== +{ + print-histogram(@A); + + my UInt %rect = find-largest-rectangle(@A); + + if %rect == 0 + { + "\nThe histogram contains no rectangles\n\nArea: 0".put; + } + else + { + ("\nThe largest rectangle (%d x %d) has corners at " ~ + "(C%d, R1) and (C%d, R%d)\n\nArea: %d\n").printf: + %rect; + } +} + +#=============================================================================== +=begin comment + +Assumptions +----------- + +1. A single column (vertical bar) is a rectangle of width 1. +2. If two or more rectangles have the maximum area, only the first to be found + is given as "the largest rectangle". + +Algorithm +--------- + +In a histogram, all bars are anchored in the first row, from which it follows +that any candidate for largest rectangle must have 2 of its 4 corners in the +first row. (If the rectangle is a single bar, its left and right lower corners +are identical.) A rectangle can be uniquely specified by any 2 diagonally- +opposite corners. In the solution below, these are the bottom left and top right +corners. + +To check a given column C: for each row R in C, find the longest unbroken line +of non-empty squares to the immediate right of (C, R). Suppose the line for row +R ends in column D. Then the rectangle has corners (C, 1) and (D, R); the width +is D - C + 1; and the height is R. + +Any column C to the right of the first needs to be checked iff A[c] > A[c-1], +because otherwise it's already been included in a check for a previous column. +By the same logic, if column C does need to be checked at all, only those rows > +A[c-1] need be checked. + +=end comment +#=============================================================================== + +#------------------------------------------------------------------------------- +sub find-largest-rectangle(Array:D[UInt:D] $A --> Hash:D[UInt:D]) +#------------------------------------------------------------------------------- +{ + my Str @keys = ; + my UInt %max = @keys.map: { $_ => 0 }; + + for 0 .. $A.end -> UInt $col-l + { + my UInt $prev-row = $col-l ?? $A[$col-l - 1] !! 0; + my UInt $this-row = $A[$col-l]; + + if ($col-l == 0 || $this-row > $prev-row) + { + for $prev-row + 1 .. $this-row -> UInt $row + { + my UInt $width = 1; + my UInt $col-r = $col-l; + + INNER: for $col-l + 1 .. $A.end -> UInt $col + { + if $A[$col] >= $row + { + ++$col-r; + ++$width; + } + else + { + last INNER; + } + } + + if (my UInt $area = $width * $row) > %max + { + %max = zip_by { |@_ }, @keys, ($col-l + 1, $col-r + 1, $row, + $width, $area); + } + } + } + } + + return %max; +} + +#------------------------------------------------------------------------------- +sub print-histogram(Array:D[UInt:D] $A) +#------------------------------------------------------------------------------- +{ + my UInt $columns = $A.elems; + my UInt $max-height = $A.max; + + if $columns <= $MAX-COLUMNS && + $max-height <= $MAX-HEIGHT + { + for (1 .. $max-height).reverse -> UInt $row + { + ' %2d'.printf: $row; + ' %s' .printf: $_ >= $row ?? '#' !! ' ' for $A.list; + ''.put; + } + + " _%s\n".printf: ' _' x $columns; + + if $max-height < 10 + { + " %s\n".printf: $A.join: ' '; + } + else + { + " %s\n".printf: $A.map( { ($_ / 10).floor || ' ' } ).join: ' '; + " %s\n".printf: $A.map( { $_ % 10 } ).join: ' '; + } + } + else + { + "The histogram is too %s to print on a single screen\n".printf: + $columns > $MAX-COLUMNS ?? 'wide' !! 'tall'; + } +} + +#------------------------------------------------------------------------------- +sub USAGE() +#------------------------------------------------------------------------------- +{ + my Str $usage = $*USAGE; + + $usage ~~ s/ ($*PROGRAM-NAME) /raku $0/; + $usage.put; +} + +################################################################################ -- cgit From f65bfda1d2ec835040e5c531639dcc672a0197ef Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 24 Aug 2020 03:51:23 -0700 Subject: Challenge 075 solutions in perl --- challenge-075/shawn-wagner/perl/ch-1.pl | 44 +++++++++++++++++++++++++++++++++ challenge-075/shawn-wagner/perl/ch-2.pl | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 challenge-075/shawn-wagner/perl/ch-1.pl create mode 100755 challenge-075/shawn-wagner/perl/ch-2.pl diff --git a/challenge-075/shawn-wagner/perl/ch-1.pl b/challenge-075/shawn-wagner/perl/ch-1.pl new file mode 100755 index 0000000000..51e2afceef --- /dev/null +++ b/challenge-075/shawn-wagner/perl/ch-1.pl @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +use warnings; +use strict; +use feature qw/say/; +use List::Util qw/sum0/; + +sub solve { + my ($C, $S) = @_; + if ($S == 0) { + return ([]); + } + my @solutions; + for my $coin (@$C) { + if ($S - $coin >= 0) { + push @solutions, grep { sum0(@$_) == $S } + map { [ $coin, @$_ ] } solve($C, $S - $coin); + } + } + return @solutions; +} + +sub task1 :prototype(\@$) { + my ($C, $S) = @_; + my @solutions = solve $C, $S; + # Get rid of duplicates. There's gotta be a cleaner way than this... + my %canonical; + local $" = ", "; + for my $solution (@solutions) { + my @sorted = sort { $a <=> $b } @$solution; + $canonical{"@sorted"}++; + } + @solutions = sort keys %canonical; + my $num = @solutions; + say "There are $num possible ways to make sum $S"; + my $id = "a"; + for my $solution (@solutions) { + say "$id) ($solution)"; + $id++; + } +} + +my @C = (1, 2, 4); +my $S = 6; +task1 @C, $S; diff --git a/challenge-075/shawn-wagner/perl/ch-2.pl b/challenge-075/shawn-wagner/perl/ch-2.pl new file mode 100755 index 0000000000..e95f1ec475 --- /dev/null +++ b/challenge-075/shawn-wagner/perl/ch-2.pl @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +use warnings; +use strict; +use utf8; +use open qw/:std encoding(UTF-8)/; +use feature qw/say/; +use List::Util qw/max/; + +# Fancy unicode histogram printer +sub histogram { + my @A = @_; + my $rows = max @A; + for my $row (reverse (1 .. $rows)) { + print $row, "│"; + for my $col (@A) { + print $col >= $row ? "█" : " ", " "; + } + print "\n"; + } + print " └", "──" x @A, "\n "; + print $_, " " for @A; + print "\n"; +} + +sub task2 { + my @A = @_; + histogram @A; + my $maxsize = 0; + for my $left (0 .. $#A) { + for my $top (1 .. $A[$left]) { + for my $right ($left+1 .. $#A) { + last if ($A[$right] < $top); + my $size = ($right - $left + 1) * $top; + $maxsize = max $maxsize, $size; + } + } + } + say "Largest rectangle area: $maxsize"; +} + +task2 2, 1, 4, 5, 3, 7; +print "\n"; +task2 3, 2, 3, 5, 7, 5; -- cgit From faabd66e0dfbb34f93f5fd65112c96cadd5887ad Mon Sep 17 00:00:00 2001 From: Shawn Date: Sat, 29 Aug 2020 10:19:55 -0700 Subject: Challenge 075 task1 solution in ocaml --- challenge-075/shawn-wagner/ocaml/ch-1.ml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 challenge-075/shawn-wagner/ocaml/ch-1.ml diff --git a/challenge-075/shawn-wagner/ocaml/ch-1.ml b/challenge-075/shawn-wagner/ocaml/ch-1.ml new file mode 100644 index 0000000000..05d4052ff0 --- /dev/null +++ b/challenge-075/shawn-wagner/ocaml/ch-1.ml @@ -0,0 +1,28 @@ +let sum = List.fold_left (+) 0 + +let rec solve coins s = + if s = 0 then + [[]] + else begin + let solutions = ref [] in + List.iter (function coin -> + let f solution = if (sum solution) + coin = s then + Some (coin :: solution) + else + None in + if s - coin >= 0 then + solutions := + List.append (List.filter_map f (solve coins (s - coin))) + !solutions) coins; + !solutions + end + +let task1 coins s = + let solutions= solve coins s in + let solutions = List.map (List.sort Int.compare) solutions in + let solutions = List.sort_uniq compare solutions in + Printf.printf "There are %d possible ways to make sum %d\n" (List.length solutions) s + +let _ = + task1 [1;2;4] 6 + -- cgit From 4f4b54d683c76b76b1e2066994019da471adb684 Mon Sep 17 00:00:00 2001 From: E7-87-83 Date: Sun, 30 Aug 2020 13:11:12 +0800 Subject: condense ch-2.pl and add blogpost of the second task --- challenge-075/cheok-yin-fung/BLOG.txt | 1 + challenge-075/cheok-yin-fung/perl/ch-2.pl | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/challenge-075/cheok-yin-fung/BLOG.txt b/challenge-075/cheok-yin-fung/BLOG.txt index 34c511b87d..4f7a0093a8 100644 --- a/challenge-075/cheok-yin-fung/BLOG.txt +++ b/challenge-075/cheok-yin-fung/BLOG.txt @@ -1 +1,2 @@ http://blogs.perl.org/users/c_y_fung/2020/08/tc.html +http://blogs.perl.org/users/c_y_fung/2020/08/how-and-what.html diff --git a/challenge-075/cheok-yin-fung/perl/ch-2.pl b/challenge-075/cheok-yin-fung/perl/ch-2.pl index 4429637893..b41bfb5a29 100644 --- a/challenge-075/cheok-yin-fung/perl/ch-2.pl +++ b/challenge-075/cheok-yin-fung/perl/ch-2.pl @@ -11,9 +11,7 @@ my @A; if (@ARGV) {@A = @ARGV;} else {@A = (3, 2, 3, 5, 7, 5);} sub subtract1 { - my @in = @_; - my @temp = map { $_ != 0 ? $_-1 : 0 } @in; - return @temp; + return map { $_ != 0 ? $_-1 : 0 } @_; } sub subtract_to_max { @@ -63,7 +61,7 @@ sub lrh { $j++; } } - if ( defined($h) && defined($t)) && (!exists $areas{"$h,$t"}) ) { + if ( defined($h) && defined($t) && (!exists $areas{"$h,$t"}) ) { $areas{"$h,$t"} = ($t-$h+1)*($MAX_-$i); } $j++; -- cgit From f62e3ef0511d0f07bef7a6b718f27ab4709ba7ab Mon Sep 17 00:00:00 2001 From: Fung Cheok Yin <61836418+E7-87-83@users.noreply.github.com> Date: Sun, 30 Aug 2020 13:17:39 +0800 Subject: Add files via upload --- challenge-075/cheok-yin-fung/common-lisp/ch-2.lsp | 115 ++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 challenge-075/cheok-yin-fung/common-lisp/ch-2.lsp diff --git a/challenge-075/cheok-yin-fung/common-lisp/ch-2.lsp b/challenge-075/cheok-yin-fung/common-lisp/ch-2.lsp new file mode 100644 index 0000000000..a448284a13 --- /dev/null +++ b/challenge-075/cheok-yin-fung/common-lisp/ch-2.lsp @@ -0,0 +1,115 @@ +; Perl Weekly Challenge #075 Task 2 Largest Rectangle Histogram +; task statement: +; https://perlweeklychallenge.org/blog/perl-weekly-challenge-075/ + +(setf ARR (list 3 2 3 5 7 5)) + + + + +(defun largest (a) + (if (> (length a) 2) + (max (first a) (largest (rest a))) + (if (= (length a) 2) (max (first a) (cadr a)) (car a) )) +) + + +(defun smallest (a) + (if (> (length a) 2) + (min (first a) (smallest (rest a))) + (if (= (length a) 2) (min (first a) (cadr a)) (car a) )) +) + +(defun subtract1 (A) + (mapcar #'(lambda (term) (if (zerop term) (quote 0) (- term 1) ) ) + A )) + + +(defun generate-pos-in-line (line) + (setf pos-in-line nil) + (setf temp nil) + (loop for i from 0 to (- (length ARR) 1) do + (if (zerop (nth i line)) + (progn (setf temp (reverse temp)) (if (not (not temp)) (push temp pos-in-line)) (setf temp nil) ) + (push i temp)) + ) + (if (not (not temp)) (push temp pos-in-line) ()) + pos-in-line +) + + +(setf maxARR (largest ARR)) +(setf minARR (smallest ARR)) + + +(setf twoD nil) +(push ARR twoD) +(loop for i from 0 to (- maxARR 1) do + (setf temp-line (subtract1 (first twoD))) + (push temp-line twoD) +) + + +(setf *maxarea* (* (smallest ARR) (length ARR) )) + + +(setf *current-height* maxARR) + +(setf already-computed-poss nil) + + + +(defun blck (diagram-index) + (mapcar #'(lambda (arg) (nth arg (nth (- *current-height* 1) twoD))) diagram-index )) + +(defun testmax-from-pos ( diagram-index ) + (setf area-of-blck (* (length diagram-index) *current-height* )) + (if (not (member diagram-index already-computed-poss :test #'equal)) + (progn + (if ( > area-of-blck *maxarea* ) (setf *maxarea* area-of-blck) + ) + (push diagram-index already-computed-poss) + ))) + + + +(loop for i from 1 to (- maxARR minARR) do + (dolist (poss (generate-pos-in-line (nth i twoD))) + (testmax-from-pos poss)) + (decf *current-height*) + ) + +(format t "answer: ") +(format t (write-to-string *maxarea*)) +(format t "~%") +(format t "~%") + +(defun print-histogram () + (format t '"histogram~%" ) + + (loop for h from 1 to maxARR do + (format t (write-to-string (+ (- maxARR h) 1) )) + (format t " ") + (loop for i from 0 to (- (length ARR) 1) do + (if (equal 0 (nth i (nth h twoD) )) + (format t " ") + (format t "# ")) + ) + (format t "~%") + ) + + + (loop for i from 1 to (length ARR) do + (format t "_ ") + ) + (format t "_ ~%") + + (format t " ") + (dolist (n ARR) + (format t (write-to-string n)) + (format t " ") + ) +) + + +(print-histogram) -- cgit From 40ef0fcb1172a1ee32658ae94b90a24fe83a103d Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 30 Aug 2020 06:52:57 +0100 Subject: - Added solutions by Athanasius. --- stats/pwc-current.json | 441 +++++++++--------- stats/pwc-language-breakdown-summary.json | 64 +-- stats/pwc-language-breakdown.json | 562 +++++++++++----------- stats/pwc-leaders.json | 752 +++++++++++++++--------------- stats/pwc-summary-1-30.json | 46 +- stats/pwc-summary-121-150.json | 102 ++-- stats/pwc-summary-151-180.json | 50 +- stats/pwc-summary-181-210.json | 46 +- stats/pwc-summary-31-60.json | 116 ++--- stats/pwc-summary-61-90.json | 44 +- stats/pwc-summary-91-120.json | 116 ++--- stats/pwc-summary.json | 42 +- 12 files changed, 1200 insertions(+), 1181 deletions(-) diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 5e77492f00..9f18cefd47 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,191 +1,30 @@ { - "title" : { - "text" : "Perl Weekly Challenge - 075" - }, - "tooltip" : { - "headerFormat" : "{series.name}
", - "pointFormat" : "{point.name}: {point.y:f}
", - "followPointer" : 1 - }, - "xAxis" : { - "type" : "category" - }, - "series" : [ - { - "name" : "Perl Weekly Challenge - 075", - "data" : [ - { - "drilldown" : "Alex Mauney", - "name" : "Alex Mauney", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Alexander Pankoff", - "name" : "Alexander Pankoff" - }, - { - "drilldown" : "Andrew Shitov", - "name" : "Andrew Shitov", - "y" : 4 - }, - { - "y" : 3, - "drilldown" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" - }, - { - "name" : "Colin Crain", - "drilldown" : "Colin Crain", - "y" : 1 - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "E. Choroba", - "name" : "E. Choroba" - }, - { - "y" : 2, - "name" : "James Smith", - "drilldown" : "James Smith" - }, - { - "y" : 2, - "name" : "Jason Messer", - "drilldown" : "Jason Messer" - }, - { - "y" : 5, - "drilldown" : "Javier Luque", - "name" : "Javier Luque" - }, - { - "name" : "Jorg Sommrey", - "drilldown" : "Jorg Sommrey", - "y" : 2 - }, - { - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld", - "y" : 5 - }, - { - "name" : "Lubos Kolouch", - "drilldown" : "Lubos Kolouch", - "y" : 2 - }, - { - "y" : 4, - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari" - }, - { - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson", - "y" : 2 - }, - { - "name" : "Markus Holzer", - "drilldown" : "Markus Holzer", - "y" : 2 - }, - { - "name" : "Mohammad S Anwar", - "drilldown" : "Mohammad S Anwar", - "y" : 6 - }, - { - "drilldown" : "Myoungjin Jeon", - "name" : "Myoungjin Jeon", - "y" : 4 - }, - { - "name" : "Noud Aldenhoven", - "drilldown" : "Noud Aldenhoven", - "y" : 2 - }, - { - "drilldown" : "Nuno Vieira", - "name" : "Nuno Vieira", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Pete Houston", - "name" : "Pete Houston" - }, - { - "y" : 5, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" - }, - { - "drilldown" : "Shahed Nooshmand", - "name" : "Shahed Nooshmand", - "y" : 3 - }, - { - "y" : 3, - "name" : "Simon Green", - "drilldown" : "Simon Green" - }, - { - "y" : 2, - "name" : "Simon Proctor", - "drilldown" : "Simon Proctor" - }, - { - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke", - "y" : 2 - }, - { - "y" : 3, - "name" : "Walt Mankowski", - "drilldown" : "Walt Mankowski" - } - ], - "colorByPoint" : 1 - } - ], "legend" : { "enabled" : 0 }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, "drilldown" : { "series" : [ { "id" : "Alex Mauney", - "name" : "Alex Mauney", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Alex Mauney" }, { "name" : "Alexander Pankoff", - "id" : "Alexander Pankoff", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Alexander Pankoff" }, { - "name" : "Andrew Shitov", - "id" : "Andrew Shitov", "data" : [ [ "Raku", @@ -195,11 +34,26 @@ "Blog", 2 ] + ], + "name" : "Andrew Shitov", + "id" : "Andrew Shitov" + }, + { + "id" : "Athanasius", + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] ] }, { "name" : "Cheok-Yin Fung", - "id" : "Cheok-Yin Fung", "data" : [ [ "Perl", @@ -209,31 +63,32 @@ "Blog", 1 ] - ] + ], + "id" : "Cheok-Yin Fung" }, { - "name" : "Colin Crain", "id" : "Colin Crain", "data" : [ [ "Blog", 1 ] - ] + ], + "name" : "Colin Crain" }, { "name" : "Dave Jacoby", - "id" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Dave Jacoby" }, { - "name" : "E. Choroba", "id" : "E. Choroba", + "name" : "E. Choroba", "data" : [ [ "Perl", @@ -252,18 +107,16 @@ "id" : "James Smith" }, { + "name" : "Jason Messer", "data" : [ [ "Raku", 2 ] ], - "name" : "Jason Messer", "id" : "Jason Messer" }, { - "id" : "Javier Luque", - "name" : "Javier Luque", "data" : [ [ "Perl", @@ -277,20 +130,21 @@ "Blog", 1 ] - ] + ], + "name" : "Javier Luque", + "id" : "Javier Luque" }, { + "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] ], - "name" : "Jorg Sommrey", "id" : "Jorg Sommrey" }, { - "id" : "Laurent Rosenfeld", "name" : "Laurent Rosenfeld", "data" : [ [ @@ -305,17 +159,18 @@ "Blog", 1 ] - ] + ], + "id" : "Laurent Rosenfeld" }, { - "name" : "Lubos Kolouch", - "id" : "Lubos Kolouch", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Lubos Kolouch", + "id" : "Lubos Kolouch" }, { "id" : "Luca Ferrari", @@ -338,20 +193,21 @@ 2 ] ], - "id" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "id" : "Mark Anderson" }, { "name" : "Markus Holzer", - "id" : "Markus Holzer", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Markus Holzer" }, { + "name" : "Mohammad S Anwar", "data" : [ [ "Perl", @@ -366,10 +222,10 @@ 2 ] ], - "id" : "Mohammad S Anwar", - "name" : "Mohammad S Anwar" + "id" : "Mohammad S Anwar" }, { + "name" : "Myoungjin Jeon", "data" : [ [ "Perl", @@ -380,42 +236,39 @@ 2 ] ], - "id" : "Myoungjin Jeon", - "name" : "Myoungjin Jeon" + "id" : "Myoungjin Jeon" }, { + "name" : "Noud Aldenhoven", "data" : [ [ "Raku", 2 ] ], - "name" : "Noud Aldenhoven", "id" : "Noud Aldenhoven" }, { "id" : "Nuno Vieira", - "name" : "Nuno Vieira", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Nuno Vieira" }, { "id" : "Pete Houston", - "name" : "Pete Houston", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Pete Houston" }, { - "id" : "Roger Bell_West", - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -429,9 +282,12 @@ "Blog", 1 ] - ] + ], + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" }, { + "name" : "Shahed Nooshmand", "data" : [ [ "Raku", @@ -442,12 +298,10 @@ 1 ] ], - "name" : "Shahed Nooshmand", "id" : "Shahed Nooshmand" }, { "id" : "Simon Green", - "name" : "Simon Green", "data" : [ [ "Perl", @@ -457,31 +311,32 @@ "Blog", 1 ] - ] + ], + "name" : "Simon Green" }, { "id" : "Simon Proctor", - "name" : "Simon Proctor", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Simon Proctor" }, { - "name" : "Ulrich Rieke", "id" : "Ulrich Rieke", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Ulrich Rieke" }, { - "name" : "Walt Mankowski", "id" : "Walt Mankowski", + "name" : "Walt Mankowski", "data" : [ [ "Perl", @@ -498,16 +353,180 @@ "chart" : { "type" : "column" }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Alex Mauney", + "y" : 2, + "name" : "Alex Mauney" + }, + { + "drilldown" : "Alexander Pankoff", + "y" : 2, + "name" : "Alexander Pankoff" + }, + { + "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov", + "y" : 4 + }, + { + "name" : "Athanasius", + "y" : 4, + "drilldown" : "Athanasius" + }, + { + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung", + "y" : 3 + }, + { + "y" : 1, + "name" : "Colin Crain", + "drilldown" : "Colin Crain" + }, + { + "name" : "Dave Jacoby", + "y" : 2, + "drilldown" : "Dave Jacoby" + }, + { + "name" : "E. Choroba", + "y" : 2, + "drilldown" : "E. Choroba" + }, + { + "name" : "James Smith", + "y" : 2, + "drilldown" : "James Smith" + }, + { + "drilldown" : "Jason Messer", + "y" : 2, + "name" : "Jason Messer" + }, + { + "drilldown" : "Javier Luque", + "name" : "Javier Luque", + "y" : 5 + }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 2 + }, + { + "y" : 5, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "drilldown" : "Lubos Kolouch", + "y" : 2, + "name" : "Lubos Kolouch" + }, + { + "y" : 4, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "name" : "Mark Anderson", + "y" : 2, + "drilldown" : "Mark Anderson" + }, + { + "y" : 2, + "name" : "Markus Holzer", + "drilldown" : "Markus Holzer" + }, + { + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", + "y" : 6 + }, + { + "name" : "Myoungjin Jeon", + "y" : 4, + "drilldown" : "Myoungjin Jeon" + }, + { + "y" : 2, + "name" : "Noud Aldenhoven", + "drilldown" : "Noud Aldenhoven" + }, + { + "y" : 2, + "name" : "Nuno Vieira", + "drilldown" : "Nuno Vieira" + }, + { + "y" : 2, + "name" : "Pete Houston", + "drilldown" : "Pete Houston" + }, + { + "drilldown" : "Roger Bell_West", + "y" : 5, + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Shahed Nooshmand", + "y" : 3, + "name" : "Shahed Nooshmand" + }, + { + "drilldown" : "Simon Green", + "y" : 3, + "name" : "Simon Green" + }, + { + "drilldown" : "Simon Proctor", + "y" : 2, + "name" : "Simon Proctor" + }, + { + "name" : "Ulrich Rieke", + "y" : 2, + "drilldown" : "Ulrich Rieke" + }, + { + "drilldown" : "Walt Mankowski", + "y" : 3, + "name" : "Walt Mankowski" + } + ], + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 075" + } + ], + "tooltip" : { + "headerFormat" : "{series.name}
", + "followPointer" : 1, + "pointFormat" : "{point.name}: {point.y:f}
" + }, + "title" : { + "text" : "Perl Weekly Challenge - 075" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "xAxis" : { + "type" : "category" + }, "subtitle" : { - "text" : "[Champions: 27] Last updated at 2020-08-29 10:52:25 GMT" + "text" : "[Champions: 28] Last updated at 2020-08-30 05:52:33 GMT" }, "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 + "enabled" : 1, + "format" : "{point.y}" + } } } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 187a6752c9..e02bd34998 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,12 +1,36 @@ { + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + }, + "type" : "category" + }, "yAxis" : { + "min" : 0, "title" : { "text" : null - }, - "min" : 0 + } + }, + "subtitle" : { + "text" : "Last updated at 2020-08-30 05:52:33 GMT" }, "series" : [ { + "dataLabels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "align" : "right", + "rotation" : -90, + "format" : "{point.y:.0f}", + "y" : 10, + "color" : "#FFFFFF", + "enabled" : "true" + }, "data" : [ [ "Blog", @@ -14,50 +38,26 @@ ], [ "Perl", - 3136 + 3138 ], [ "Raku", - 2043 + 2045 ] ], - "name" : "Contributions", - "dataLabels" : { - "y" : 10, - "enabled" : "true", - "rotation" : -90, - "color" : "#FFFFFF", - "format" : "{point.y:.0f}", - "align" : "right", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } + "name" : "Contributions" } ], "legend" : { "enabled" : "false" }, + "chart" : { + "type" : "column" + }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, "tooltip" : { "pointFormat" : "{point.y:.0f}" - }, - "xAxis" : { - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - }, - "type" : "category" - }, - "subtitle" : { - "text" : "Last updated at 2020-08-29 10:52:25 GMT" - }, - "chart" : { - "type" : "column" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index abf404a156..6abff69970 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,46 +1,61 @@ { - "title" : { - "text" : "Perl Weekly Challenge Language" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } }, - "tooltip" : { - "pointFormat" : "Challenge {point.name}: {point.y:f}
", - "headerFormat" : "", - "followPointer" : "true" + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-08-30 05:52:33 GMT" }, "xAxis" : { "type" : "category" }, - "legend" : { - "enabled" : "false" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "title" : { + "text" : "Perl Weekly Challenge Language" + }, + "tooltip" : { + "pointFormat" : "Challenge {point.name}: {point.y:f}
", + "followPointer" : "true", + "headerFormat" : "" }, "series" : [ { + "colorByPoint" : "true", "name" : "Perl Weekly Challenge Languages", "data" : [ { + "y" : 142, "name" : "#001", - "drilldown" : "001", - "y" : 142 + "drilldown" : "001" }, { - "drilldown" : "002", + "y" : 109, "name" : "#002", - "y" : 109 + "drilldown" : "002" }, { - "name" : "#003", "drilldown" : "003", + "name" : "#003", "y" : 71 }, { + "y" : 91, "name" : "#004", - "drilldown" : "004", - "y" : 91 + "drilldown" : "004" }, { - "y" : 72, + "drilldown" : "005", "name" : "#005", - "drilldown" : "005" + "y" : 72 }, { "y" : 52, @@ -48,34 +63,34 @@ "drilldown" : "006" }, { - "y" : 59, "drilldown" : "007", - "name" : "#007" + "name" : "#007", + "y" : 59 }, { + "name" : "#008", "y" : 72, - "drilldown" : "008", - "name" : "#008" + "drilldown" : "008" }, { "y" : 68, - "drilldown" : "009", - "name" : "#009" + "name" : "#009", + "drilldown" : "009" }, { "drilldown" : "010", - "name" : "#010", - "y" : 60 + "y" : 60, + "name" : "#010" }, { "name" : "#011", - "drilldown" : "011", - "y" : 79 + "y" : 79, + "drilldown" : "011" }, { - "drilldown" : "012", "name" : "#012", - "y" : 83 + "y" : 83, + "drilldown" : "012" }, { "y" : 76, @@ -84,58 +99,58 @@ }, { "y" : 96, - "drilldown" : "014", - "name" : "#014" + "name" : "#014", + "drilldown" : "014" }, { - "y" : 93, "drilldown" : "015", + "y" : 93, "name" : "#015" }, { - "y" : 66, "name" : "#016", + "y" : 66, "drilldown" : "016" }, { + "drilldown" : "017", "y" : 79, - "name" : "#017", - "drilldown" : "017" + "name" : "#017" }, { "name" : "#018", - "drilldown" : "018", - "y" : 76 + "y" : 76, + "drilldown" : "018" }, { + "y" : 97, "name" : "#019", - "drilldown" : "019", - "y" : 97 + "drilldown" : "019" }, { + "name" : "#020", "y" : 95, - "drilldown" : "020", - "name" : "#020" + "drilldown" : "020" }, { "name" : "#021", - "drilldown" : "021", - "y" : 67 + "y" : 67, + "drilldown" : "021" }, { - "y" : 63, "drilldown" : "022", + "y" : 63, "name" : "#022" }, { "y" : 91, - "drilldown" : "023", - "name" : "#023" + "name" : "#023", + "drilldown" : "023" }, { "drilldown" : "024", - "name" : "#024", - "y" : 70 + "y" : 70, + "name" : "#024" }, { "y" : 55, @@ -143,29 +158,29 @@ "drilldown" : "025" }, { - "name" : "#026", "drilldown" : "026", - "y" : 70 + "y" : 70, + "name" : "#026" }, { + "name" : "#027", "y" : 58, - "drilldown" : "027", - "name" : "#027" + "drilldown" : "027" }, { "