From cffcf70aae86cd63c94bdad11dcefe27981ced7b Mon Sep 17 00:00:00 2001 From: Adam Russell Date: Sun, 15 Nov 2020 18:36:04 -0500 Subject: perl and prolog solutions for challenge 086 --- challenge-086/adam-russell/blog.txt | 1 + challenge-086/adam-russell/blog1.txt | 1 + challenge-086/adam-russell/perl/ch-1.pl | 36 +++++++++++++++++++++ challenge-086/adam-russell/prolog/ch-1.p | 34 ++++++++++++++++++++ challenge-086/adam-russell/prolog/ch-2.p | 54 ++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 challenge-086/adam-russell/blog.txt create mode 100644 challenge-086/adam-russell/blog1.txt create mode 100644 challenge-086/adam-russell/perl/ch-1.pl create mode 100644 challenge-086/adam-russell/prolog/ch-1.p create mode 100644 challenge-086/adam-russell/prolog/ch-2.p diff --git a/challenge-086/adam-russell/blog.txt b/challenge-086/adam-russell/blog.txt new file mode 100644 index 0000000000..4360236687 --- /dev/null +++ b/challenge-086/adam-russell/blog.txt @@ -0,0 +1 @@ +http://www.rabbitfarm.com/cgi-bin/blosxom/perl/2020/11/15 diff --git a/challenge-086/adam-russell/blog1.txt b/challenge-086/adam-russell/blog1.txt new file mode 100644 index 0000000000..ef84506468 --- /dev/null +++ b/challenge-086/adam-russell/blog1.txt @@ -0,0 +1 @@ +http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2020/11/15 diff --git a/challenge-086/adam-russell/perl/ch-1.pl b/challenge-086/adam-russell/perl/ch-1.pl new file mode 100644 index 0000000000..efc52a4f60 --- /dev/null +++ b/challenge-086/adam-russell/perl/ch-1.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; +## +# You are given an array of integers @N and an integer $A. +# Write a script to find find if there exists a pair of elements +# in the array whose difference is $A. +# Print 1 if exists otherwise 0. +## +use boolean; +use Math::Combinatorics; + +sub build_constraints{ + my @constraints; + my $a_not_equal_b = sub { $_[0] != $_[1] }; + my $difference_equal_n = sub { $_[0] - $_[1] == $_[2] }; + return ( + $a_not_equal_b, + $difference_equal_n + ); +} + +MAIN:{ + my $combinations = Math::Combinatorics->new( + count => 2, + data => [@ARGV[1 .. @ARGV - 1]], + ); + my $found = false; + my ($check_equal, $check_difference) = build_constraints(); + while(my @combination = $combinations->next_combination()){ + if($check_equal->(@combination) && $check_difference->(@combination, $ARGV[0])){ + $found = true; + print "1\n"; last; + } + } + print "0\n" if(!$found); +} \ No newline at end of file diff --git a/challenge-086/adam-russell/prolog/ch-1.p b/challenge-086/adam-russell/prolog/ch-1.p new file mode 100644 index 0000000000..a698d4bdc0 --- /dev/null +++ b/challenge-086/adam-russell/prolog/ch-1.p @@ -0,0 +1,34 @@ +:- use_module(library(optparse)). +/* + You are given an array of integers @N and an integer $A. + Write a script to find find if there exists a pair of elements + in the array whose difference is $A. + Print 1 if exists otherwise 0. +*/ +opts_spec( + [ + [opt(numbers), + default([10, 8, 12, 15, 5]), + longflags([numbers])], + + [opt(a), + default(7), + longflags([a])] + ]). + +ch_1(L, N):- + member(A, L), + member(B, L), + A =\= B, + D is A - B, + N = D, + writeln(1). + +ch_1(_, _):- + writeln(0). + +main:- + opts_spec(OptsSpec), + opt_arguments(OptsSpec, [numbers(L), a(A)], _AdditionalArguments), + ch_1(L, A), + halt. \ No newline at end of file diff --git a/challenge-086/adam-russell/prolog/ch-2.p b/challenge-086/adam-russell/prolog/ch-2.p new file mode 100644 index 0000000000..9c6d29d81d --- /dev/null +++ b/challenge-086/adam-russell/prolog/ch-2.p @@ -0,0 +1,54 @@ +:- use_module(library(clpfd)). + +sudoku(Puzzle, Solution) :- + Solution = Puzzle, + Puzzle = [S11, S12, S13, S14, S15, S16, S17, S18, S19, + S21, S22, S23, S24, S25, S26, S27, S28, S29, + S31, S32, S33, S34, S35, S36, S37, S38, S39, + S41, S42, S43, S44, S45, S46, S47, S48, S49, + S51, S52, S53, S54, S55, S56, S57, S58, S59, + S61, S62, S63, S64, S65, S66, S67, S68, S69, + S71, S72, S73, S74, S75, S76, S77, S78, S79, + S81, S82, S83, S84, S85, S86, S87, S88, S89, + S91, S92, S93, S94, S95, S96, S97, S98, S99], + + ins(Puzzle, 1..9), + + Row1 = [S11, S12, S13, S14, S15, S16, S17, S18, S19], + Row2 = [S21, S22, S23, S24, S25, S26, S27, S28, S29], + Row3 = [S31, S32, S33, S34, S35, S36, S37, S38, S39], + Row4 = [S41, S42, S43, S44, S45, S46, S47, S48, S49], + Row5 = [S51, S52, S53, S54, S55, S56, S57, S58, S59], + Row6 = [S61, S62, S63, S64, S65, S66, S67, S68, S69], + Row7 = [S71, S72, S73, S74, S75, S76, S77, S78, S79], + Row8 = [S81, S82, S83, S84, S85, S86, S87, S88, S89], + Row9 = [S91, S92, S93, S94, S95, S96, S97, S98, S99], + + Column1 = [S11, S21, S31, S41, S51, S61, S71, S81, S91], + Column2 = [S12, S22, S32, S42, S52, S62, S72, S82, S92], + Column3 = [S13, S23, S33, S43, S53, S63, S73, S83, S93], + Column4 = [S14, S24, S34, S44, S54, S64, S74, S84, S94], + Column5 = [S15, S25, S35, S45, S55, S65, S75, S85, S95], + Column6 = [S16, S26, S36, S46, S56, S66, S76, S86, S96], + Column7 = [S17, S27, S37, S47, S57, S67, S77, S87, S97], + Column8 = [S18, S28, S38, S48, S58, S68, S78, S88, S98], + Column9 = [S19, S29, S39, S49, S59, S69, S79, S89, S99], + + SubBox1 = [S11, S12, S13, S21, S22, S23, S31, S32, S33], + SubBox2 = [S41, S42, S43, S51, S52, S53, S61, S62, S63], + SubBox3 = [S71, S72, S73, S81, S82, S83, S91, S92, S93], + SubBox4 = [S14, S15, S16, S24, S25, S26, S34, S35, S36], + SubBox5 = [S44, S45, S46, S54, S55, S56, S64, S65, S66], + SubBox6 = [S74, S75, S76, S84, S85, S86, S94, S95, S96], + SubBox7 = [S17, S18, S19, S27, S28, S29, S37, S38, S39], + SubBox8 = [S47, S48, S49, S57, S58, S59, S67, S68, S69], + SubBox9 = [S77, S78, S79, S87, S88, S89, S97, S98, S99], + + valid([Row1, Row2, Row3, Row4, Row5, Row6, Row7, Row8, Row9, + Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8, Column9, + SubBox1, SubBox2, SubBox3, SubBox4, SubBox5, SubBox6, SubBox7, SubBox8, SubBox9]). + +valid([]). +valid([H|T]) :- + all_different(H), + valid(T). \ No newline at end of file -- cgit From b45a9772b88f4073af099c52c719f6adb3693a4e Mon Sep 17 00:00:00 2001 From: dcw Date: Sun, 15 Nov 2020 23:54:22 +0000 Subject: imported my solution to task 1, got stuck on suduko solver (hard problem!) --- challenge-086/duncan-c-white/README | 93 ++++++++++++++++++++++--------- challenge-086/duncan-c-white/perl/ch-1.pl | 65 +++++++++++++++++++++ 2 files changed, 131 insertions(+), 27 deletions(-) create mode 100755 challenge-086/duncan-c-white/perl/ch-1.pl diff --git a/challenge-086/duncan-c-white/README b/challenge-086/duncan-c-white/README index 53a59c4fc8..9d55f38591 100644 --- a/challenge-086/duncan-c-white/README +++ b/challenge-086/duncan-c-white/README @@ -1,50 +1,89 @@ -Task 1: "Triplet Sum +Task 1: "Pair Difference -You are given an array of real numbers greater than zero. +You are given an array of integers @N and an integer $A. -Write a script to find if there exists a triplet (a,b,c) such that 1 < -a+b+c < 2. Print 1 if you succeed otherwise 0. +Write a script to find find if there exists a pair of elements in the +array whose difference is $A. Print 1 if exists otherwise 0. Example 1: - Input: @R = (1.2, 0.4, 0.1, 2.5) - Output: 1 as 1 < 1.2 + 0.4 + 0.1 < 2 + Input: @N = (10, 8, 12, 15, 5) and $A = 7 + Output: 1 as 15 - 8 = 7 Example 2: - Input: @R = (0.2, 1.5, 0.9, 1.1) - Output: 0 + Input: @N = (1, 5, 2, 9, 7) and $A = 6 + Output: 1 as 7 - 1 = 6 Example 3: - Input: @R = (0.5, 1.1, 0.3, 0.7) - Output: 1 as 1 < 0.5 + 1.1 + 0.3 < 2 + Input: @N = (10, 30, 20, 50, 40) and $A = 15 + Output: 0 -My notes: simple, I think it means "pick any 3 elements a, b and c from the -array and determine if any a,b,c triple sums to between 1 and 2", although both -successful examples show 3 ADJACENT elements a, b and c... +My notes: simple and straightforward: try all pairs of elements looking +for abs(x-y)==A -Task 2: "Power of Two Integers +Task 2: "Sudoku Puzzle -You are given a positive integer $N. +You are given Sudoku puzzle (9x9). -Write a script to find if it can be expressed as a ** b where a > 0 and -b > 1. Print 1 if you succeed otherwise 0. +Write a script to complete the puzzle and must respect the following rules: +a) Each row must have the numbers 1-9 occuring just once. +b) Each column must have the numbers 1-9 occuring just once. +c) The numbers 1-9 must occur just once in each of the 9 sub-boxes (3x3) of the grid. -Example 1: +Example: -Input: 8 -Output: 1 as 8 = 2 ** 3 +[ _ _ _ 2 6 _ 7 _ 1 ] +[ 6 8 _ _ 7 _ _ 9 _ ] +[ 1 9 _ _ _ 4 5 _ _ ] +[ 8 2 _ 1 _ _ _ 4 _ ] +[ _ _ 4 6 _ 2 9 _ _ ] +[ _ 5 _ _ _ 3 _ 2 8 ] +[ _ _ 9 3 _ _ _ 7 4 ] +[ _ 4 _ _ 5 _ _ 3 6 ] +[ 7 _ 3 _ 1 8 _ _ _ ] -Example 2: +Output: -Input: 15 -Output: 0 +[ 4 3 5 2 6 9 7 8 1 ] +[ 6 8 2 5 7 1 4 9 3 ] +[ 1 9 7 8 3 4 5 6 2 ] +[ 8 2 6 1 9 5 3 4 7 ] +[ 3 7 4 6 8 2 9 1 5 ] +[ 9 5 1 7 4 3 6 2 8 ] +[ 5 1 9 3 2 6 8 7 4 ] +[ 2 4 8 9 5 7 1 3 6 ] +[ 7 6 3 4 1 8 2 5 9 ] -Example 3: +As the above puzzle respect the 3 rules including 9-sub-boxes as shown below: + +[ 4 3 5 ] [ 2 6 9 ] [ 7 8 1 ] +[ 6 8 2 ] [ 5 7 1 ] [ 4 9 3 ] +[ 1 9 7 ] [ 8 3 4 ] [ 5 6 2 ] + +[ 8 2 6 ] [ 1 9 5 ] [ 3 4 7 ] +[ 3 7 4 ] [ 6 8 2 ] [ 9 1 5 ] +[ 9 5 1 ] [ 7 4 3 ] [ 6 2 8 ] + +[ 5 1 9 ] [ 3 2 6 ] [ 8 7 4 ] +[ 2 4 8 ] [ 9 5 7 ] [ 1 3 6 ] +[ 7 6 3 ] [ 4 1 8 ] [ 2 5 9 ] + + +My notes: excuse me! a sudoku solver from scratch? that's hard! -Input: 125 -Output: 1 as 125 = 5 ** 3 +fortunately I had already written a sudoku solver, which did clever +deductions after working out the possible sets for each cell. But for +this, I tried something else: I threw away all the clever deductions +and wrote a brute force searcher: +- read the puzzle +- form the possible sets for each cell +- eliminate known cells from intersecting rows, columns and boxes +then solve by: +- finding an unknown cell (r,c) with possible values @possval +- for each @possval, clone the puzzle, set cell (r,c) to the chosen value and recurse -My notes: clearly defined, not quite sure how to do it so.. let's brute force +But sadly, I couldn't get it to work in the time I'd left myself (2.5 hours) - so +no submission for that. I may submit it late if I can get it to work later. diff --git a/challenge-086/duncan-c-white/perl/ch-1.pl b/challenge-086/duncan-c-white/perl/ch-1.pl new file mode 100755 index 0000000000..9281cebb0a --- /dev/null +++ b/challenge-086/duncan-c-white/perl/ch-1.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# +# Task 1: "Pair Difference +# +# You are given an array of integers @N and an integer $A. +# +# Write a script to find find if there exists a pair of elements in the +# array whose difference is $A. Print 1 if exists otherwise 0. +# +# Example 1: +# +# Input: @N = (10, 8, 12, 15, 5) and $A = 7 +# Output: 1 as 15 - 8 = 7 +# +# Example 2: +# +# Input: @N = (1, 5, 2, 9, 7) and $A = 6 +# Output: 1 as 7 - 1 = 6 +# +# Example 3: +# +# Input: @N = (10, 30, 20, 50, 40) and $A = 15 +# Output: 0 +# +# My notes: simple and straightforward: try all pairs of elements looking +# for abs(x-y)==A +# + +use strict; +use warnings; +use feature 'say'; +use Function::Parameters; +use Data::Dumper; +use Getopt::Long; + +my $debug = 0; +die "Usage: pair-diff [--debug] DIFF array\n" unless + GetOptions( "debug" => \$debug ) && + @ARGV>1; +my( $diff, @x ) = @ARGV; + +# +# my $found = finddiff( $diff, @x ); +# Attempt to find any two elements of @x with difference $diff; +# return 1 iff such a pair of elements exists (0 otherwise). +# +fun finddiff( $diff, @x ) +{ + foreach my $apos (0..$#x-1) + { + my $a = $x[$apos]; + foreach my $bpos ($apos+1..$#x) + { + my $b = $x[$bpos]; + next unless abs($a-$b) == $diff; + say "found $a and $b with diff $diff" if $debug; + return 1; + } + } + return 0; +} + + +my $found = finddiff( $diff, @x ); +say $found; -- cgit From c2e3491a7aebb0d7224d4c7caf969faf0227fcf6 Mon Sep 17 00:00:00 2001 From: dcw Date: Mon, 16 Nov 2020 00:31:07 +0000 Subject: aha, got it working now, 30 minutes late:-) --- challenge-086/duncan-c-white/README | 14 +- challenge-086/duncan-c-white/perl/ch-2.pl | 500 ++++++++++++++++++++++++++++++ 2 files changed, 508 insertions(+), 6 deletions(-) create mode 100755 challenge-086/duncan-c-white/perl/ch-2.pl diff --git a/challenge-086/duncan-c-white/README b/challenge-086/duncan-c-white/README index 9d55f38591..306809ff7f 100644 --- a/challenge-086/duncan-c-white/README +++ b/challenge-086/duncan-c-white/README @@ -77,13 +77,15 @@ My notes: excuse me! a sudoku solver from scratch? that's hard! fortunately I had already written a sudoku solver, which did clever deductions after working out the possible sets for each cell. But for this, I tried something else: I threw away all the clever deductions -and wrote a brute force searcher: -- read the puzzle -- form the possible sets for each cell -- eliminate known cells from intersecting rows, columns and boxes +and wrote a brute force searcher instead: +- read the puzzle (reused my existing code) +- form the possible sets for each cell (ditto) +- eliminate known cells from intersecting rows, columns and boxes (ditto) then solve by: - finding an unknown cell (r,c) with possible values @possval -- for each @possval, clone the puzzle, set cell (r,c) to the chosen value and recurse +- for each @possval, clone the puzzle, set cell (r,c) to the chosen value and recurse, + checking for consistency at each stage But sadly, I couldn't get it to work in the time I'd left myself (2.5 hours) - so -no submission for that. I may submit it late if I can get it to work later. +no submission for that before midnight. After about 30 minutes more work, I got +it working - there was a bug in the consistency checker. diff --git a/challenge-086/duncan-c-white/perl/ch-2.pl b/challenge-086/duncan-c-white/perl/ch-2.pl new file mode 100755 index 0000000000..eab723c310 --- /dev/null +++ b/challenge-086/duncan-c-white/perl/ch-2.pl @@ -0,0 +1,500 @@ +#!/usr/bin/perl +# +# Task 2: "Sudoku Puzzle +# +# You are given Sudoku puzzle (9x9). +# +# Write a script to complete the puzzle and must respect the following rules: +# a) Each row must have the numbers 1-9 occuring just once. +# b) Each column must have the numbers 1-9 occuring just once. +# c) The numbers 1-9 must occur just once in each of the 9 sub-boxes (3x3) of the grid. +# +# Example: +# +# [ _ _ _ 2 6 _ 7 _ 1 ] +# [ 6 8 _ _ 7 _ _ 9 _ ] +# [ 1 9 _ _ _ 4 5 _ _ ] +# [ 8 2 _ 1 _ _ _ 4 _ ] +# [ _ _ 4 6 _ 2 9 _ _ ] +# [ _ 5 _ _ _ 3 _ 2 8 ] +# [ _ _ 9 3 _ _ _ 7 4 ] +# [ _ 4 _ _ 5 _ _ 3 6 ] +# [ 7 _ 3 _ 1 8 _ _ _ ] +# +# Output: +# +# [ 4 3 5 2 6 9 7 8 1 ] +# [ 6 8 2 5 7 1 4 9 3 ] +# [ 1 9 7 8 3 4 5 6 2 ] +# [ 8 2 6 1 9 5 3 4 7 ] +# [ 3 7 4 6 8 2 9 1 5 ] +# [ 9 5 1 7 4 3 6 2 8 ] +# [ 5 1 9 3 2 6 8 7 4 ] +# [ 2 4 8 9 5 7 1 3 6 ] +# [ 7 6 3 4 1 8 2 5 9 ] +# +# As the above puzzle respect the 3 rules including 9-sub-boxes as shown below: +# +# [ 4 3 5 ] [ 2 6 9 ] [ 7 8 1 ] +# [ 6 8 2 ] [ 5 7 1 ] [ 4 9 3 ] +# [ 1 9 7 ] [ 8 3 4 ] [ 5 6 2 ] +# +# [ 8 2 6 ] [ 1 9 5 ] [ 3 4 7 ] +# [ 3 7 4 ] [ 6 8 2 ] [ 9 1 5 ] +# [ 9 5 1 ] [ 7 4 3 ] [ 6 2 8 ] +# +# [ 5 1 9 ] [ 3 2 6 ] [ 8 7 4 ] +# [ 2 4 8 ] [ 9 5 7 ] [ 1 3 6 ] +# [ 7 6 3 ] [ 4 1 8 ] [ 2 5 9 ] +# +# My notes: excuse me? write a sudoku solver in 2 and a half hours? no way! +# fortunately I already had a solver, which did clever deductions after +# working out the possible sets for each cell. But for this, I throw +# away all the clever deductions and wrote a brute force searcher: +# - read the puzzle +# - form the possible sets +# - eliminate known cells from intersecting rows, columns and boxes +# then solve by: +# - finding an unknown cell (r,c) with possible values @possval +# - for each @possval, clone the puzzle, set cell (r,c) to the chosen value and recurse +# + +use strict; +use warnings; +use Data::Dumper; +use feature 'say'; + +my $size = 9; # 9x9 puzzles always.. don't try changing this! + + +# +# my $puzref = readpuz( $fh ); +# read a puzzle from file handle $fh. +# return a puzzle arrayref +# +sub readpuz ($) +{ + my( $infh ) = @_; + + my @puz = (); + foreach (1..$size) + { + my $line = <$infh>; + chomp $line; + die "readpuz: line '$line' not $size chars long\n" + unless length($line)==$size; + die "readpuz: invalid line '$line'\n" unless + $line =~ /^(\d| ){$size}$/o; + my @x = split( //, $line ); + map { + $_ = "123456789" if $_ eq " "; + } @x; + push( @puz, \@x ); + } + #die "readpuz: puz = ". Dumper(\@puz); + + return \@puz; +} + + +# +# showpuz( $verbose, @puz ); +# show the puzzle prettily, verbosely if asked +# +sub showpuz ($@) +{ + my( $verbose, @puz ) = @_; + if( $verbose ) + { + my @rowlet = ( "A".."I" ); # row letters + foreach my $row (0..$size-1) + { + my $line1 = my $line2 = " |"; + if( $verbose ) + { + $line2 = "$rowlet[$row]|"; + } + foreach my $cell (@{$puz[$row]}) + { + if( $verbose ) + { + my $val = length($cell)==1 ? $cell : " "; # unknown if length()>1 + my $p1 = " "; + my $p2 = " "; + if( length($cell)>1 ) + { + my $p9 = substr( $cell." ", 0, 9 ); + $p9 =~ /^(....)(.*)$/; + $p1 = $1; + $p2 = $2; + } + $line1 .= " $val $p1 |"; + $line2 .= " $p2 |"; + } else + { + my $val = length($cell)==1 ? $cell : " "; # unknown if length()>1 + $line1 .= " $val |"; + } + } + print "$line1\n"; + next unless $verbose; + print "$line2\n"; + print " ".("| " x $size); + print "|\n"; + } + } else + { + foreach my $row (0..$size-1) + { + my $line1 = ""; + foreach my $cell (@{$puz[$row]}) + { + my $val = length($cell)==1 ? $cell : " "; # unknown if length()>1 + $line1 .= $val; + } + print "$line1\n"; + } + } +} + + +# +# my $changed = eliminateoneknown( $row, $col, $val, @puz ); +# cell (row,col) is a known value $val - so modify the rest of the puzzle @puz +# to reflect the things that we now know: that $val is not possible +# in all cells in the same row, all cells in the same column +# and all cells in the same box. +# Return 1 iff the puzzle changes. +# +sub eliminateoneknown ($$$@) +{ + my( $row, $col, $val, @puz ) = @_; + die "eliminateoneknown: bad args ($row,$col,$val) - puz($row,$col) != $val\n" + unless $puz[$row][$col] eq $val; + + my $changed = 0; + + # $val is not possible in col $col + foreach my $r (0..$size-1) + { + next if $r == $row; + my $cell = $puz[$r][$col]; + next if length($cell)==1; + if( $cell =~ /$val/ ) + { + $cell =~ s/$val//; + $puz[$r][$col] = $cell; + $changed = 1; + } + } + # $val is not possible in row $row + foreach my $c (0..$size-1) + { + next if $c == $col; + my $cell = $puz[$row][$c]; + next if length($cell)==1; + if( $cell =~ /$val/ ) + { + $cell =~ s/$val//; + $puz[$row][$c] = $cell; + $changed = 1; + } + } + # $val is not possible anywhere in the same box as (row,col) + my $boxr1 = $row - $row%3; + my $boxr2 = $boxr1 + 2; + my $boxc1 = $col - $col%3; + my $boxc2 = $boxc1 + 2; + foreach my $c ($boxc1..$boxc2) + { + foreach my $r ($boxr1..$boxr2) + { + next if $r == $row && $c == $col; + my $cell = $puz[$r][$c]; + next if length($cell)==1; + if( $cell =~ /$val/ ) + { + $cell =~ s/$val//; + $puz[$r][$c] = $cell; + $changed = 1; + } + } + } + return $changed; +} + + +# +# my $changed = eliminate( @puz ); +# locate all known cells, and eliminate each from +# overlapping rows, columns and boxes. +# Return 1 iff the puzzle changes. +# +sub eliminate +{ + my( @puz ) = @_; + my $changed = 0; + foreach my $row (0..$size-1) + { + foreach my $col (0..$size-1) + { + my $cell = $puz[$row][$col]; + next unless length($cell)==1; + $changed ||= eliminateoneknown( $row, $col, $cell, @puz ); + } + } + return $changed; +} + + +# +# my $unknowns = countunknowns( @puz ); +# Count how many unknowns there are in @puz. +# +sub countunknowns +{ + my( @puz ) = @_; + my $unknowns = 0; + foreach my $row (0..$size-1) + { + foreach my $col (0..$size-1) + { + my $cell = $puz[$row][$col]; + $unknowns++ if length($cell)>1; + } + } + return $unknowns; +} + + +# +# my( $r, c ) = findfirstunknown(@puz); +# Find the first unknown cell, returning it's row and column no. +# If there are no unknown cells, return (0,0) +# +sub findfirstunknown +{ + my( @puz ) = @_; + foreach my $row (0..$size-1) + { + foreach my $col (0..$size-1) + { + my $cell = $puz[$row][$col]; + return ($row,$col) if length($cell)>1; + } + } + return (0,0); +} + + +# +# my $maxfreq = maxfreqinbox( $boxrn,$boxcn,@puz); +# Check the contents of the box ($boxrn:0..2, $boxcn:0..2) +# to find the maximum frequency of all known elements in there. +# +sub maxfreqinbox +{ + my( $boxrn, $boxcn, @puz ) = @_; + + my $boxr1 = $boxrn*3; + my $boxr2 = $boxr1 + 2; + my $boxc1 = $boxcn*3; + my $boxc2 = $boxc1 + 2; + my %freq; + my $maxfreq = 0; + foreach my $c ($boxc1..$boxc2) + { + foreach my $r ($boxr1..$boxr2) + { + my $cell = $puz[$r][$c]; + next unless length($cell)==1; + $freq{$cell}++; + $maxfreq = $freq{$cell} if $freq{$cell}>$maxfreq; + } + } + return $maxfreq; +} + + +# +# my $isconsistent = consistent(@puz); +# Return 1 iff the puzzle @puz is consistent so far. +# Return 0 if there are any problems: +# - a cell with 0 possibilities +# - 2 cells in the same row/column/box with same value +# +sub consistent +{ + my( @puz ) = @_; + foreach my $row (0..$size-1) + { + foreach my $col (0..$size-1) + { + my $cell = $puz[$row][$col]; + return 0 if length($cell)==0; # no possibilities + } + } + + foreach my $row (0..$size-1) + { + # ok, find frequencies of all known values in this row + my %freq; + my $maxfreq=0; + foreach my $col (0..$size-1) + { + my $cell = $puz[$row][$col]; + next unless length($cell)==1; + $freq{$cell}++; + $maxfreq = $freq{$cell} if $freq{$cell}>$maxfreq; + } + + if( $maxfreq>1 ) + { + say "not consistent due to max freq $maxfreq in row $row"; + return 0; + } + } + + foreach my $col (0..$size-1) + { + # ok, find frequencies of all known values in this column + my %freq; + my $maxfreq=0; + foreach my $row (0..$size-1) + { + my $cell = $puz[$row][$col]; + next unless length($cell)==1; + $freq{$cell}++; + $maxfreq = $freq{$cell} if $freq{$cell}>$maxfreq; + } + + if( $maxfreq>1 ) + { + say "not consistent due to max freq $maxfreq in column $col"; + return 0; + } + } + + + foreach my $boxrn (0..2) + { + foreach my $boxcn (0..2) + { + # count maxfreq of items in box ($boxrn,$boxcn) + my $maxfreq = maxfreqinbox( $boxrn,$boxcn,@puz); + if( $maxfreq>1 ) + { + say "not consistent due to max freq $maxfreq in box $boxrn, $boxcn"; + return 0; + } + } + } + + # ok if we get to the end.. + say "consistent"; + return 1; +} + + +# +# my @clone = clonepuz( @puz ); +# Clone the entire puzzle. Return the new identical puzzle. +# +sub clonepuz +{ + my( @puz ) = @_; + my @result = map { [ @$_ ] } @puz; + return @result; +} + + +# +# my( $solved, @solvedpuz ) = solve( $pass, @puz ); +# Brute force solve @puz: locate the first unknown cell. +# Then, foreach possible value of that cell, clone the puzzle, +# set that cell to that value, and brute force again. +# Fail whenever a cell becomes empty; +# succeed whenever the puzzle has no unknowns. +# +sub solve +{ + my( $pass, @puz ) = @_; + + my( $r, $c ) = findfirstunknown(@puz); + my $poss = $puz[$r][$c]; + say "solve pass $pass: found unknown cell ($r,$c), possible values $poss"; + + my @poss = split(//,$poss); + foreach my $value (@poss) + { + my @clone = clonepuz( @puz ); + say "solve pass $pass: try cell ($r,$c)=$value"; + $clone[$r][$c] = $value; + + # eliminate until no changes.. + while( eliminate( @clone ) ) + { + } + + say "solve pass $pass: board is"; + showpuz( 1, @clone ); + + my $isconsistent = consistent(@clone); + unless( $isconsistent ) + { + say "solve pass $pass: not consistent"; + next; + } + + my $unknowns = countunknowns( @clone ); + print "\nthere are $unknowns unknowns\n"; + return (1, @clone) if $unknowns==0; + + my( $solved, @solvedpuz ) = solve( $pass+1,@clone ); + return (1, @solvedpuz) if $solved; + } + say "solve pass $pass: fail"; + return (0); +} + + +die "Usage: bruteforcesudokusolver inputfile\n" unless @ARGV == 1; + +my $puzfile = shift; +open( my $infh, '<', $puzfile ) || die; + +STDOUT->autoflush(1); +STDERR->autoflush(1); +STDIN->autoflush(1); + +#print "please enter your sudoku board:\n"; +my ( $puzref, @hint ) = readpuz($infh); +$infh->close; +my @puz = @$puzref; + +print "\n"; + +print "\ninitially puzzle is:\n\n"; +showpuz( 1, @puz ); + +# eliminate until no changes.. +while( eliminate( @puz ) ) +{ +} + +print "\nafter eliminations puzzle is:\n\n"; +showpuz( 1, @puz ); + +my $unknowns = countunknowns( @puz ); +print "\nthere are $unknowns unknowns\n"; + +my( $solved, @solvedpuz ) = solve( 1, @puz ); + +unless( $solved ) +{ + say "No solution found"; +} else +{ + print "\nafter brute force solving, puzzle is:\n\n"; + showpuz( 0, @solvedpuz ); +} -- cgit From 017fc9548d0bc9f75f4bbb77a1c0010c0e7b9b06 Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Mon, 16 Nov 2020 01:43:24 +0100 Subject: Add solution to 086/2 Sudoku Puzzle in C by E. Choroba --- challenge-086/e-choroba/c/ch-2.c | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 challenge-086/e-choroba/c/ch-2.c diff --git a/challenge-086/e-choroba/c/ch-2.c b/challenge-086/e-choroba/c/ch-2.c new file mode 100755 index 0000000000..81032e4431 --- /dev/null +++ b/challenge-086/e-choroba/c/ch-2.c @@ -0,0 +1,63 @@ +#include + +/* + Direct translation of the Perl code. Solves Arto Inkala's hardest + Sudoku 66 times faster on my machine. +*/ + +int maybe (int s[9][9], int y, int x, int try) { + for (int i = 0; i < 9; ++i) { + if (s[y][i] == try || s[i][x] == try) return 0; + } + int xs = x / 3; + int ys = y / 3; + for (int y1 = ys * 3; y1 <= ys * 3 + 2; ++y1) { + for (int x1 = xs * 3; x1 <= xs * 3 + 2; ++x1) { + if (s[y1][x1] == try) return 0; + } + } + return 1; +} + +int solve (int s[9][9]) { + for (int x = 0; x < 9; ++x) { + for (int y = 0; y < 9; ++y) { + if (s[y][x]) continue; + + for (int try = 1; try <= 9; ++try) { + if (maybe(s, y, x, try)) { + s[y][x] = try; + if (solve(s)) return 1; + } + } + s[y][x] = 0; + return 0; + } + } + return 1; +} + +void show(int s[9][9]) { + for (int y = 0; y < 9; ++y) { + for (int x = 0; x < 9; ++x) { + printf(" %d", s[y][x]); + } + printf("\n"); + } +} + +int main() { + int s[9][9] = { + 0, 0, 0, 2, 6, 0, 7, 0, 1, + 6, 8, 0, 0, 7, 0, 0, 9, 0, + 1, 9, 0, 0, 0, 4, 5, 0, 0, + 8, 2, 0, 1, 0, 0, 0, 4, 0, + 0, 0, 4, 6, 0, 2, 9, 0, 0, + 0, 5, 0, 0, 0, 3, 0, 2, 8, + 0, 0, 9, 3, 0, 0, 0, 7, 4, + 0, 4, 0, 0, 5, 0, 0, 3, 6, + 7, 0, 3, 0, 1, 8, 0, 0, 0 }; + solve(s); + show(s); + return 0; +} -- cgit From b0eb13cac0f5c8f6d209e7b9dfdfda0f7b9fb7df Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 16 Nov 2020 04:19:18 +0000 Subject: - Added solutions by Adam Russell. --- stats/pwc-current.json | 537 +++++++++++++------------- stats/pwc-language-breakdown-summary.json | 74 ++-- stats/pwc-language-breakdown.json | 606 +++++++++++++++--------------- stats/pwc-leaders.json | 382 +++++++++---------- stats/pwc-summary-1-30.json | 26 +- stats/pwc-summary-121-150.json | 24 +- stats/pwc-summary-151-180.json | 36 +- stats/pwc-summary-181-210.json | 90 ++--- stats/pwc-summary-31-60.json | 94 ++--- stats/pwc-summary-61-90.json | 34 +- stats/pwc-summary-91-120.json | 34 +- stats/pwc-summary.json | 46 +-- 12 files changed, 1001 insertions(+), 982 deletions(-) diff --git a/stats/pwc-current.json b/stats/pwc-current.json index c288440c94..5b0598fe6f 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,203 +1,9 @@ { - "legend" : { - "enabled" : 0 - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "title" : { - "text" : "Perl Weekly Challenge - 086" - }, - "chart" : { - "type" : "column" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - } - } - }, - "subtitle" : { - "text" : "[Champions: 32] Last updated at 2020-11-16 04:14:11 GMT" - }, - "series" : [ - { - "colorByPoint" : 1, - "data" : [ - { - "name" : "Abigail", - "y" : 4, - "drilldown" : "Abigail" - }, - { - "name" : "Alexander Pankoff", - "y" : 2, - "drilldown" : "Alexander Pankoff" - }, - { - "name" : "Andinus", - "y" : 2, - "drilldown" : "Andinus" - }, - { - "drilldown" : "Andrew Shitov", - "y" : 1, - "name" : "Andrew Shitov" - }, - { - "y" : 5, - "drilldown" : "Arne Sommer", - "name" : "Arne Sommer" - }, - { - "name" : "Athanasius", - "y" : 4, - "drilldown" : "Athanasius" - }, - { - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung", - "y" : 3 - }, - { - "name" : "Cristina Heredia", - "drilldown" : "Cristina Heredia", - "y" : 1 - }, - { - "name" : "Daniel Bowling", - "y" : 1, - "drilldown" : "Daniel Bowling" - }, - { - "name" : "Dave Jacoby", - "y" : 2, - "drilldown" : "Dave Jacoby" - }, - { - "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" - }, - { - "name" : "Feng Chang", - "drilldown" : "Feng Chang", - "y" : 2 - }, - { - "y" : 4, - "drilldown" : "Flavio Poletti", - "name" : "Flavio Poletti" - }, - { - "name" : "Jan Krnavek", - "y" : 1, - "drilldown" : "Jan Krnavek" - }, - { - "name" : "Jorg Sommrey", - "drilldown" : "Jorg Sommrey", - "y" : 2 - }, - { - "name" : "Julio de Castro", - "y" : 4, - "drilldown" : "Julio de Castro" - }, - { - "y" : 2, - "drilldown" : "Kai Burgdorf", - "name" : "Kai Burgdorf" - }, - { - "name" : "Kang-min Liu", - "y" : 2, - "drilldown" : "Kang-min Liu" - }, - { - "drilldown" : "Lubos Kolouch", - "y" : 2, - "name" : "Lubos Kolouch" - }, - { - "drilldown" : "Mark Anderson", - "y" : 2, - "name" : "Mark Anderson" - }, - { - "name" : "Myoungjin Jeon", - "y" : 5, - "drilldown" : "Myoungjin Jeon" - }, - { - "name" : "Nuno Vieira", - "drilldown" : "Nuno Vieira", - "y" : 2 - }, - { - "drilldown" : "Philip Hood", - "y" : 2, - "name" : "Philip Hood" - }, - { - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West", - "y" : 4 - }, - { - "name" : "Shawn Wagner", - "y" : 2, - "drilldown" : "Shawn Wagner" - }, - { - "y" : 2, - "drilldown" : "Simon Green", - "name" : "Simon Green" - }, - { - "name" : "Simon Proctor", - "drilldown" : "Simon Proctor", - "y" : 2 - }, - { - "name" : "Stuart Little", - "y" : 2, - "drilldown" : "Stuart Little" - }, - { - "drilldown" : "Tejas", - "y" : 2, - "name" : "Tejas" - }, - { - "name" : "Ulrich Rieke", - "y" : 3, - "drilldown" : "Ulrich Rieke" - }, - { - "name" : "Walt Mankowski", - "drilldown" : "Walt Mankowski", - "y" : 2 - }, - { - "drilldown" : "Wanderdoc", - "y" : 2, - "name" : "Wanderdoc" - } - ], - "name" : "Perl Weekly Challenge - 086" - } - ], "drilldown" : { "series" : [ { - "name" : "Abigail", "id" : "Abigail", + "name" : "Abigail", "data" : [ [ "Perl", @@ -210,17 +16,30 @@ ] }, { - "id" : "Alexander Pankoff", + "id" : "Adam Russell", + "name" : "Adam Russell", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Blog", + 2 + ] + ] + }, + { "data" : [ [ "Perl", 2 ] ], - "name" : "Alexander Pankoff" + "name" : "Alexander Pankoff", + "id" : "Alexander Pankoff" }, { - "id" : "Andinus", "data" : [ [ "Perl", @@ -231,20 +50,20 @@ 1 ] ], - "name" : "Andinus" + "name" : "Andinus", + "id" : "Andinus" }, { - "name" : "Andrew Shitov", "data" : [ [ "Raku", 1 ] ], + "name" : "Andrew Shitov", "id" : "Andrew Shitov" }, { - "name" : "Arne Sommer", "id" : "Arne Sommer", "data" : [ [ @@ -259,11 +78,10 @@ "Blog", 1 ] - ] + ], + "name" : "Arne Sommer" }, { - "name" : "Athanasius", - "id" : "Athanasius", "data" : [ [ "Perl", @@ -273,10 +91,11 @@ "Raku", 2 ] - ] + ], + "name" : "Athanasius", + "id" : "Athanasius" }, { - "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", @@ -287,60 +106,62 @@ 1 ] ], + "name" : "Cheok-Yin Fung", "id" : "Cheok-Yin Fung" }, { - "id" : "Cristina Heredia", + "name" : "Cristina Heredia", "data" : [ [ "Perl", 1 ] ], - "name" : "Cristina Heredia" + "id" : "Cristina Heredia" }, { "id" : "Daniel Bowling", + "name" : "Daniel Bowling", "data" : [ [ "Raku", 1 ] - ], - "name" : "Daniel Bowling" + ] }, { "id" : "Dave Jacoby", + "name" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] - ], - "name" : "Dave Jacoby" + ] }, { + "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "id" : "E. Choroba", - "name" : "E. Choroba" + "id" : "E. Choroba" }, { - "name" : "Feng Chang", - "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Feng Chang", + "id" : "Feng Chang" }, { "id" : "Flavio Poletti", + "name" : "Flavio Poletti", "data" : [ [ "Perl", @@ -350,30 +171,30 @@ "Blog", 2 ] - ], - "name" : "Flavio Poletti" + ] }, { - "name" : "Jan Krnavek", "data" : [ [ "Raku", 1 ] ], + "name" : "Jan Krnavek", "id" : "Jan Krnavek" }, { + "id" : "Jorg Sommrey", "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] - ], - "id" : "Jorg Sommrey" + ] }, { + "name" : "Julio de Castro", "data" : [ [ "Perl", @@ -384,32 +205,31 @@ 2 ] ], - "id" : "Julio de Castro", - "name" : "Julio de Castro" + "id" : "Julio de Castro" }, { + "id" : "Kai Burgdorf", "name" : "Kai Burgdorf", "data" : [ [ "Perl", 2 ] - ], - "id" : "Kai Burgdorf" + ] }, { + "name" : "Kang-min Liu", "data" : [ [ "Raku", 2 ] ], - "id" : "Kang-min Liu", - "name" : "Kang-min Liu" + "id" : "Kang-min Liu" }, { - "name" : "Lubos Kolouch", "id" : "Lubos Kolouch", + "name" : "Lubos Kolouch", "data" : [ [ "Perl", @@ -419,16 +239,17 @@ }, { "name" : "Mark Anderson", - "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Mark Anderson" }, { "id" : "Myoungjin Jeon", + "name" : "Myoungjin Jeon", "data" : [ [ "Perl", @@ -442,31 +263,29 @@ "Blog", 1 ] - ], - "name" : "Myoungjin Jeon" + ] }, { + "name" : "Nuno Vieira", "data" : [ [ "Perl", 2 ] ], - "id" : "Nuno Vieira", - "name" : "Nuno Vieira" + "id" : "Nuno Vieira" }, { "id" : "Philip Hood", + "name" : "Philip Hood", "data" : [ [ "Raku", 2 ] - ], - "name" : "Philip Hood" + ] }, { - "name" : "Roger Bell_West", "id" : "Roger Bell_West", "data" : [ [ @@ -481,21 +300,22 @@ "Blog", 1 ] - ] + ], + "name" : "Roger Bell_West" }, { + "id" : "Shawn Wagner", "name" : "Shawn Wagner", "data" : [ [ "Perl", 2 ] - ], - "id" : "Shawn Wagner" + ] }, { - "name" : "Simon Green", "id" : "Simon Green", + "name" : "Simon Green", "data" : [ [ "Perl", @@ -524,21 +344,20 @@ 2 ] ], - "id" : "Stuart Little", - "name" : "Stuart Little" + "name" : "Stuart Little", + "id" : "Stuart Little" }, { - "name" : "Tejas", - "id" : "Tejas", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Tejas", + "id" : "Tejas" }, { - "id" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -549,36 +368,236 @@ 1 ] ], - "name" : "Ulrich Rieke" + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke" }, { - "name" : "Walt Mankowski", - "id" : "Walt Mankowski", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Walt Mankowski", + "id" : "Walt Mankowski" }, { - "name" : "Wanderdoc", - "id" : "Wanderdoc", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Wanderdoc", + "id" : "Wanderdoc" } ] }, - "tooltip" : { - "pointFormat" : "{point.name}: {point.y:f}
", - "headerFormat" : "{series.name}
", - "followPointer" : 1 + "legend" : { + "enabled" : 0 + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } }, "xAxis" : { "type" : "category" + }, + "tooltip" : { + "followPointer" : 1, + "headerFormat" : "{series.name}
", + "pointFormat" : "{point.name}: {point.y:f}
" + }, + "title" : { + "text" : "Perl Weekly Challenge - 086" + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 086", + "data" : [ + { + "y" : 4, + "drilldown" : "Abigail", + "name" : "Abigail" + }, + { + "name" : "Adam Russell", + "y" : 3, + "drilldown" : "Adam Russell" + }, + { + "name" : "Alexander Pankoff", + "drilldown" : "Alexander Pankoff", + "y" : 2 + }, + { + "name" : "Andinus", + "drilldown" : "Andinus", + "y" : 2 + }, + { + "y" : 1, + "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov" + }, + { + "name" : "Arne Sommer", + "y" : 5, + "drilldown" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "y" : 4, + "drilldown" : "Athanasius" + }, + { + "name" : "Cheok-Yin Fung", + "drilldown" : "Cheok-Yin Fung", + "y" : 3 + }, + { + "drilldown" : "Cristina Heredia", + "y" : 1, + "name" : "Cristina Heredia" + }, + { + "y" : 1, + "drilldown" : "Daniel Bowling", + "name" : "Daniel Bowling" + }, + { + "name" : "Dave Jacoby", + "y" : 2, + "drilldown" : "Dave Jacoby" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "y" : 2, + "drilldown" : "Feng Chang", + "name" : "Feng Chang" + }, + { + "name" : "Flavio Poletti", + "drilldown" : "Flavio Poletti", + "y" : 4 + }, + { + "y" : 1, + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "y" : 2, + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "name" : "Julio de Castro", + "y" : 4, + "drilldown" : "Julio de Castro" + }, + { + "name" : "Kai Burgdorf", + "y" : 2, + "drilldown" : "Kai Burgdorf" + }, + { + "y" : 2, + "drilldown" : "Kang-min Liu", + "name" : "Kang-min Liu" + }, + { + "name" : "Lubos Kolouch", + "y" : 2, + "drilldown" : "Lubos Kolouch" + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 2 + }, + { + "name" : "Myoungjin Jeon", + "drilldown" : "Myoungjin Jeon", + "y" : 5 + }, + { + "name" : "Nuno Vieira", + "y" : 2, + "drilldown" : "Nuno Vieira" + }, + { + "name" : "Philip Hood", + "drilldown" : "Philip Hood", + "y" : 2 + }, + { + "name" : "Roger Bell_West", + "y" : 4, + "drilldown" : "Roger Bell_West" + }, + { + "name" : "Shawn Wagner", + "drilldown" : "Shawn Wagner", + "y" : 2 + }, + { + "name" : "Simon Green", + "drilldown" : "Simon Green", + "y" : 2 + }, + { + "drilldown" : "Simon Proctor", + "y" : 2, + "name" : "Simon Proctor" + }, + { + "y" : 2, + "drilldown" : "Stuart Little", + "name" : "Stuart Little" + }, + { + "drilldown" : "Tejas", + "y" : 2, + "name" : "Tejas" + }, + { + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Walt Mankowski", + "name" : "Walt Mankowski" + }, + { + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc", + "y" : 2 + } + ] + } + ], + "subtitle" : { + "text" : "[Champions: 33] Last updated at 2020-11-16 04:19:01 GMT" + }, + "chart" : { + "type" : "column" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index f5a4dd7d19..5b8d9a3e25 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "legend" : { - "enabled" : "false" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "chart" : { - "type" : "column" - }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, "tooltip" : { "pointFormat" : "{point.y:.0f}" }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } + }, + "subtitle" : { + "text" : "Last updated at 2020-11-16 04:19:00 GMT" + }, + "chart" : { + "type" : "column" + }, "series" : [ { - "dataLabels" : { - "enabled" : "true", - "format" : "{point.y:.0f}", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "align" : "right", - "rotation" : -90, - "color" : "#FFFFFF", - "y" : 10 - }, "data" : [ [ "Blog", - 1104 + 1106 ], [ "Perl", - 3832 + 3833 ], [ "Raku", 2463 ] ], - "name" : "Contributions" + "name" : "Contributions", + "dataLabels" : { + "format" : "{point.y:.0f}", + "enabled" : "true", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "y" : 10, + "color" : "#FFFFFF", + "align" : "right", + "rotation" : -90 + } } ], - "subtitle" : { - "text" : "Last updated at 2020-11-16 04:14:11 GMT" - }, - "xAxis" : { - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } + "yAxis" : { + "title" : { + "text" : null }, - "type" : "category" + "min" : 0 + }, + "legend" : { + "enabled" : "false" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 0833b405d4..b5be6a8bda 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,12 +1,25 @@ { - "xAxis" : { - "type" : "category" + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : "false" }, "drilldown" : { "series" : [ { "name" : "001", - "id" : "001", "data" : [ [ "Perl", @@ -20,10 +33,11 @@ "Blog", 11 ] - ] + ], + "id" : "001" }, { - "name" : "002", + "id" : "002", "data" : [ [ "Perl", @@ -38,11 +52,10 @@ 10 ] ], - "id" : "002" + "name" : "002" }, { "name" : "003", - "id" : "003", "data" : [ [ "Perl", @@ -56,9 +69,12 @@ "Blog", 9 ] - ] + ], + "id" : "003" }, { + "id" : "004", + "name" : "004", "data" : [ [ "Perl", @@ -72,11 +88,10 @@ "Blog", 10 ] - ], - "id" : "004", - "name" : "004" + ] }, { + "name" : "005", "data" : [ [ "Perl", @@ -91,8 +106,7 @@ 12 ] ], - "id" : "005", - "name" : "005" + "id" : "005" }, { "data" : [ @@ -109,10 +123,12 @@ 7 ] ], - "id" : "006", - "name" : "006" + "name" : "006", + "id" : "006" }, { + "id" : "007", + "name" : "007", "data" : [ [ "Perl", @@ -126,12 +142,10 @@ "Blog", 10 ] - ], - "id" : "007", - "name" : "007" + ] }, { - "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -146,7 +160,7 @@ 12 ] ], - "name" : "008" + "id" : "008" }, { "data" : [ @@ -163,10 +177,11 @@ 13 ] ], - "id" : "009", - "name" : "009" + "name" : "009", + "id" : "009" }, { + "name" : "010", "data" : [ [ "Perl", @@ -181,12 +196,9 @@ 11 ] ], - "id" : "010", - "name" : "010" + "id" : "010" }, { - "name" : "011", - "id" : "011", "data" : [ [ "Perl", @@ -200,9 +212,12 @@ "Blog", 10 ] - ] + ], + "name" : "011", + "id" : "011" }, { + "id" : "012", "data" : [ [ "Perl", @@ -217,7 +232,6 @@ 11 ] ], - "id" : "012", "name" : "012" }, { @@ -235,10 +249,12 @@ 13 ] ], - "id" : "013", - "name" : "013" + "name" : "013", + "id" : "013" }, { + "id" : "014", + "name" : "014", "data" : [ [ "Perl", @@ -252,12 +268,9 @@ "Blog", 15 ] - ], - "id" : "014", - "name" : "014" + ] }, { - "name" : "015", "data" : [ [ "Perl", @@ -272,9 +285,12 @@ 15 ] ], + "name" : "015", "id" : "015" }, { + "id" : "016", + "name" : "016", "data" : [ [ "Perl", @@ -288,13 +304,11 @@ "Blog", 12 ] - ], - "id" : "016", - "name" : "016" + ] }, { - "name" : "017", "id" : "017", + "name" : "017", "data" : [ [ "Perl", @@ -329,7 +343,6 @@ "id" : "018" }, { - "name" : "019", "id" : "019", "data" : [ [ @@ -344,10 +357,10 @@ "Blog", 13 ] - ] + ], + "name" : "019" }, { - "name" : "020", "data" : [ [ "Perl", @@ -362,6 +375,7 @@ 13 ] ], + "name" : "020", "id" : "020" }, { @@ -379,12 +393,11 @@ 10 ] ], - "id" : "021", - "name" : "021" + "name" : "021", + "id" : "021" }, { "name" : "022", - "id" : "022", "data" : [ [ "Perl", @@ -398,10 +411,11 @@ "Blog", 10 ] - ] + ], + "id" : "022" }, { - "id" : "023", + "name" : "023", "data" : [ [ "Perl", @@ -416,10 +430,11 @@ 12 ] ], - "name" : "023" + "id" : "023" }, { "id" : "024", + "name" : "024", "data" : [ [ "Perl", @@ -433,8 +448,7 @@ "Blog", 11 ] - ], - "name" : "024" + ] }, { "name" : "025", @@ -473,7 +487,6 @@ "id" : "026" }, { - "name" : "027", "id" : "027", "data" : [ [ @@ -488,11 +501,11 @@ "Blog", 9 ] - ] + ], + "name" : "027" }, { "name" : "028", - "id" : "028", "data" : [ [ "Perl", @@ -506,7 +519,8 @@ "Blog", 9 ] - ] + ], + "id" : "028" }, { "id" : "029", @@ -527,7 +541,7 @@ "name" : "029" }, { - "id" : "030", + "name" : "030", "data" : [ [ "Perl", @@ -542,10 +556,9 @@ 10 ] ], - "name" : "030" + "id" : "030" }, { - "id" : "031", "data" : [ [ "Perl", @@ -560,10 +573,10 @@ 9 ] ], - "name" : "031" + "name" : "031", + "id" : "031" }, { - "name" : "032", "data" : [ [ "Perl", @@ -578,10 +591,11 @@ 10 ] ], + "name" : "032", "id" : "032" }, { - "id" : "033", + "name" : "033", "data" : [ [ "Perl", @@ -596,11 +610,11 @@ 10 ] ], - "name" : "033" + "id" : "033" }, { - "name" : "034", "id" : "034", + "name" : "034", "data" : [ [ "Perl", @@ -617,7 +631,7 @@ ] }, { - "id" : "035", + "name" : "035", "data" : [ [ "Perl", @@ -632,9 +646,10 @@ 9 ] ], - "name" : "035" + "id" : "035" }, { + "id" : "036", "name" : "036", "data" : [ [ @@ -649,12 +664,11 @@ "Blog", 11 ] - ], - "id" : "036" + ] }, { - "name" : "037", "id" : "037", + "name" : "037", "data" : [ [ "Perl", @@ -671,7 +685,7 @@ ] }, { - "name" : "038", + "id" : "038", "data" : [ [ "Perl", @@ -686,10 +700,9 @@ 12 ] ], - "id" : "038" + "name" : "038" }, { - "id" : "039", "data" : [ [ "Perl", @@ -704,10 +717,10 @@ 12 ] ], - "name" : "039" + "name" : "039", + "id" : "039" }, { - "id" : "040", "data" : [ [ "Perl", @@ -722,10 +735,11 @@ 10 ] ], - "name" : "040" + "name" : "040", + "id" : "040" }, { - "name" : "041", + "id" : "041", "data" : [ [ "Perl", @@ -740,10 +754,11 @@ 9 ] ], - "id" : "041" + "name" : "041" }, { "id" : "042", + "name" : "042", "data" : [ [ "Perl", @@ -757,11 +772,10 @@ "Blog", 11 ] - ], - "name" : "042" + ] }, { - "name" : "043", + "id" : "043", "data" : [ [ "Perl", @@ -776,10 +790,9 @@ 11 ] ], - "id" : "043" + "name" : "043" }, { - "name" : "044", "data" : [ [ "Perl", @@ -794,6 +807,7 @@ 11 ] ], + "name" : "044", "id" : "044" }, { @@ -815,6 +829,7 @@ "id" : "045" }, { + "id" : "046", "data" : [ [ "Perl", @@ -829,11 +844,10 @@ 10 ] ], - "id" : "046", "name" : "046" }, { - "id" : "047", + "name" : "047", "data" : [ [ "Perl", @@ -848,10 +862,10 @@ 10 ] ], - "name" : "047" + "id" : "047" }, { - "name" : "048", + "id" : "048", "data" : [ [ "Perl", @@ -866,7 +880,7 @@ 12 ] ], - "id" : "048" + "name" : "048" }, { "data" : [ @@ -883,11 +897,11 @@ 12 ] ], - "id" : "049", - "name" : "049" + "name" : "049", + "id" : "049" }, { - "id" : "050", + "name" : "050", "data" : [ [ "Perl", @@ -902,7 +916,7 @@ 12 ] ], - "nam