aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyoungjin JEON <jeongoon@gmail.com>2020-11-16 02:50:57 +1100
committerMyoungjin JEON <jeongoon@gmail.com>2020-11-16 02:50:57 +1100
commiteea0d9773b9c81ab2a9e2b2cead1574c950c0d0b (patch)
treef331be7f60d3a33b714cc5a9725fac81b04d2a9c
parent898a3c151807dabd03d093311a5a54f39ae1a341 (diff)
parent4c31310c2fcdcc28b67276d0d5a90fdf820d8b48 (diff)
downloadperlweeklychallenge-club-eea0d9773b9c81ab2a9e2b2cead1574c950c0d0b.tar.gz
perlweeklychallenge-club-eea0d9773b9c81ab2a9e2b2cead1574c950c0d0b.tar.bz2
perlweeklychallenge-club-eea0d9773b9c81ab2a9e2b2cead1574c950c0d0b.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--challenge-086/abigail/blog.txt1
-rw-r--r--challenge-086/abigail/blog1.txt1
-rw-r--r--challenge-086/abigail/c/ch-1.c126
-rw-r--r--challenge-086/abigail/node/ch-1.js47
-rw-r--r--challenge-086/abigail/perl/ch-1.pl61
-rw-r--r--challenge-086/abigail/perl/ch-2.pl531
-rw-r--r--challenge-086/abigail/sql/ch-1.sql14
-rw-r--r--challenge-086/abigail/sql/ch-1.table4
-rw-r--r--challenge-086/abigail/t/input-1-16
-rw-r--r--challenge-086/abigail/t/input-1-218
-rw-r--r--challenge-086/abigail/t/input-1-32
-rw-r--r--challenge-086/abigail/t/input-1-44
-rw-r--r--challenge-086/abigail/t/input-2-19
-rw-r--r--challenge-086/abigail/t/input-2-29
-rw-r--r--challenge-086/abigail/t/input-2-39
-rw-r--r--challenge-086/abigail/t/input-2-44
-rw-r--r--challenge-086/abigail/t/input-2-516
-rw-r--r--challenge-086/abigail/t/input-2-66
-rw-r--r--challenge-086/abigail/t/input-2-715
-rw-r--r--challenge-086/abigail/t/input-2-89
-rw-r--r--challenge-086/abigail/t/output-1-1.exp4
-rw-r--r--challenge-086/abigail/t/output-1-2.exp10
-rw-r--r--challenge-086/abigail/t/output-1-3.exp2
-rw-r--r--challenge-086/abigail/t/output-1-4.exp3
-rw-r--r--challenge-086/abigail/t/output-2-1.exp10
-rw-r--r--challenge-086/abigail/t/output-2-2.exp10
-rw-r--r--challenge-086/abigail/t/output-2-3.exp10
-rw-r--r--challenge-086/abigail/t/output-2-4.exp5
-rw-r--r--challenge-086/abigail/t/output-2-5.exp18
-rw-r--r--challenge-086/abigail/t/output-2-6.exp7
-rw-r--r--challenge-086/abigail/t/output-2-7.exp13
-rw-r--r--challenge-086/abigail/t/output-2-8.exp11
-rwxr-xr-xchallenge-086/abigail/test.pl279
-rw-r--r--challenge-086/arne-sommer/blog.txt1
-rwxr-xr-xchallenge-086/arne-sommer/perl/ch-1.pl27
-rwxr-xr-xchallenge-086/arne-sommer/perl/ch-2.pl142
-rwxr-xr-xchallenge-086/arne-sommer/perl/pair-difference-perl27
-rwxr-xr-xchallenge-086/arne-sommer/perl/sudoku-solver-perl142
-rwxr-xr-xchallenge-086/arne-sommer/raku/ch-1.raku5
-rwxr-xr-xchallenge-086/arne-sommer/raku/ch-2.raku98
-rwxr-xr-xchallenge-086/arne-sommer/raku/pair-difference5
-rwxr-xr-xchallenge-086/arne-sommer/raku/pair-difference-verbose7
-rwxr-xr-xchallenge-086/arne-sommer/raku/sudoku-solver89
-rwxr-xr-xchallenge-086/arne-sommer/raku/sudoku-solver-exit98
-rw-r--r--challenge-086/arne-sommer/sample-sudoku-error.txt9
-rw-r--r--challenge-086/arne-sommer/sample-sudoku.txt9
-rwxr-xr-xchallenge-086/cristian-heredia/perl/ch-1.pl44
-rw-r--r--challenge-086/gugod/README5
-rw-r--r--challenge-086/gugod/board.txt9
-rw-r--r--challenge-086/gugod/raku/ch-1.raku18
-rw-r--r--challenge-086/gugod/raku/ch-2.raku70
-rw-r--r--challenge-086/hstejas/README1
-rw-r--r--challenge-086/hstejas/cpp/ch-1.cpp43
-rw-r--r--challenge-086/hstejas/cpp/ch-2.cpp210
-rwxr-xr-xchallenge-086/hstejas/perl/ch-1.pl38
-rwxr-xr-xchallenge-086/hstejas/perl/ch-2.pl105
-rw-r--r--challenge-086/jo-37/perl/ch-1.md179
-rwxr-xr-xchallenge-086/jo-37/perl/ch-1.pl32
-rwxr-xr-xchallenge-086/jo-37/perl/ch-2.pl94
-rw-r--r--challenge-086/juliodcs/perl/ch-1.pl24
-rw-r--r--challenge-086/juliodcs/perl/ch-2.pl174
-rw-r--r--challenge-086/juliodcs/raku/ch-1.raku20
-rw-r--r--challenge-086/juliodcs/raku/ch-2.raku144
-rw-r--r--challenge-086/lubos-kolouch/perl/ch-1.pl48
-rw-r--r--challenge-086/lubos-kolouch/python/ch-1.py39
-rw-r--r--challenge-086/mark-anderson/raku/ch-1.p62
-rw-r--r--challenge-086/mark-anderson/raku/ch-2.p635
-rw-r--r--challenge-086/nunovieira220/js/ch-1.js20
-rw-r--r--challenge-086/nunovieira220/js/ch-2.js114
-rw-r--r--challenge-086/nunovieira220/perl/ch-1.pl27
-rw-r--r--challenge-086/nunovieira220/perl/ch-2.pl133
-rwxr-xr-xchallenge-086/pkmnx/raku/ch-2.raku172
-rw-r--r--challenge-086/polettix/blog.txt1
-rw-r--r--challenge-086/polettix/blog1.txt1
-rw-r--r--challenge-086/polettix/perl/ch-1.pl19
-rw-r--r--challenge-086/polettix/perl/ch-2.pl194
-rw-r--r--challenge-086/roger-bell-west/blog.txt1
-rw-r--r--challenge-086/swaggboi/README1
-rwxr-xr-xchallenge-086/swaggboi/raku/ch-1.raku29
-rw-r--r--challenge-086/tyler-wardhaugh/clojure/src/tw/weekly/c86/t1.clj11
-rw-r--r--challenge-086/tyler-wardhaugh/lua/README.md1
-rwxr-xr-xchallenge-086/tyler-wardhaugh/lua/ch-1.lua28
-rwxr-xr-xchallenge-086/tyler-wardhaugh/lua/ch-2.lua250
-rwxr-xr-xchallenge-086/tyler-wardhaugh/lua/run.lua9
-rwxr-xr-xchallenge-086/tyler-wardhaugh/lua/test.lua23
-rw-r--r--challenge-086/ulrich-rieke/haskell/ch-1.hs12
-rw-r--r--challenge-086/ulrich-rieke/perl/ch-1.pl31
-rw-r--r--challenge-086/ulrich-rieke/perl/ch-2.pl163
-rw-r--r--challenge-086/ulrich-rieke/raku/ch-1.raku25
-rw-r--r--members.json2
-rw-r--r--stats/pwc-current.json343
-rw-r--r--stats/pwc-language-breakdown-summary.json76
-rw-r--r--stats/pwc-language-breakdown.json600
-rw-r--r--stats/pwc-leaders.json464
-rw-r--r--stats/pwc-summary-1-30.json42
-rw-r--r--stats/pwc-summary-121-150.json60
-rw-r--r--stats/pwc-summary-151-180.json64
-rw-r--r--stats/pwc-summary-181-210.json54
-rw-r--r--stats/pwc-summary-31-60.json60
-rw-r--r--stats/pwc-summary-61-90.json110
-rw-r--r--stats/pwc-summary-91-120.json42
-rw-r--r--stats/pwc-summary.json90
102 files changed, 5450 insertions, 1089 deletions
diff --git a/challenge-086/abigail/blog.txt b/challenge-086/abigail/blog.txt
new file mode 100644
index 0000000000..9cab9b37f2
--- /dev/null
+++ b/challenge-086/abigail/blog.txt
@@ -0,0 +1 @@
+https://wp.me/pcxd30-3w
diff --git a/challenge-086/abigail/blog1.txt b/challenge-086/abigail/blog1.txt
new file mode 100644
index 0000000000..b97c4ee817
--- /dev/null
+++ b/challenge-086/abigail/blog1.txt
@@ -0,0 +1 @@
+https://wp.me/pcxd30-4C
diff --git a/challenge-086/abigail/c/ch-1.c b/challenge-086/abigail/c/ch-1.c
new file mode 100644
index 0000000000..f081b5e098
--- /dev/null
+++ b/challenge-086/abigail/c/ch-1.c
@@ -0,0 +1,126 @@
+/*
+ * Challenge
+ *
+ * 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.
+ */
+
+# include <stdlib.h>
+# include <stdio.h>
+# include <stdbool.h>
+# include <math.h>
+
+# define DEFAULT_BUF_SIZE 128
+# define BUF_INCREMENT 1.25 /* Increment the buffer size by *
+ * a quarter each time we run out *
+ * of memory space. */
+/*
+ * Compare two integer values, returning -1, 0, 1 if the first
+ * is smaller, equal, or larger than the second.
+ */
+int cmp (const void * a, const void * b) {
+ long diff = * (long *) a - * (long *) b;
+ return diff < 0 ? -1
+ : diff > 0 ? 1
+ : 0;
+}
+
+/*
+ * Binary search: return true if target is in array,
+ * with index i, min <= i < max.
+ */
+bool bin_search (long * array, long target, size_t min, size_t max) {
+ size_t mid = (min + max) / 2; /* In C, dividing integers yields an *
+ * integer, so there is no need for *
+ * flooring. */
+
+ return min >= max ? false
+ : array [mid] == target ? true
+ : array [mid] > target ?
+ bin_search (array, target, min, mid)
+ : bin_search (array, target, mid + 1, max);
+}
+
+
+int main (void) {
+ /* Arguments for getline () */
+ char * line = NULL;
+ size_t len = 0;
+
+ /* We'll store the numbers in array, which we will reuse for each *
+ * line we're processing. We also need to keep track of how much *
+ * memory we have allocated for the array. */
+ long * array = NULL;
+ size_t buf_size = DEFAULT_BUF_SIZE;
+
+ /* The target difference */
+ long target;
+
+ /* Give the array some starting memory to work with. */
+ if ((array = (long *) malloc (buf_size * sizeof (long))) == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ return (1);
+ }
+
+ /*
+ * Iterate over the input, reading one line at a time
+ * Every odd line will be a sequence of integers, every
+ * even line will be a single integer. We'll do processing
+ * after each even line.
+ */
+ bool is_even = true;
+ size_t size = 0; /* Number of integers in array. */
+ while (getline (&line, &len, stdin) != -1) {
+ int offset;
+ char * line_ptr = line;
+
+ is_even = !is_even;
+
+ if (!is_even) {
+ size = 0; /* Reset size of array */
+ long input; /* Each long read from the line */
+
+ /* Scan the line just read, one long at a time */
+ while (sscanf (line_ptr, "%ld%n", &input, &offset) == 1) {
+ line_ptr += offset;
+
+ if (++ size >= buf_size) {
+ /* Get some more memory. */
+ buf_size = (size_t) floorf (buf_size * BUF_INCREMENT);
+ if ((array = (long *) realloc (array,
+ buf_size * sizeof (long))) == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ return (1);
+ }
+ }
+
+ /* Store it */
+ array [size - 1] = input;
+ }
+
+ /* Quick sort to sort the array */
+ qsort (array, size, sizeof (long), cmp);
+ }
+ else {
+ char * endptr;
+ target = labs (strtol (line, &endptr, 10));
+
+ /*
+ * Iterate over the array, and check whether further down
+ * the array we find a number equal to target + array [i] --
+ * if so, there is a pair whose difference is target.
+ */
+ bool winner = false;
+ for (size_t i = 0; i < size && !winner; i ++) {
+ winner = bin_search (array, target + array [i], i + 1, size);
+ }
+ printf ("%d\n", winner ? 1 : 0);
+ }
+ }
+ free (line);
+ free (array);
+}
diff --git a/challenge-086/abigail/node/ch-1.js b/challenge-086/abigail/node/ch-1.js
new file mode 100644
index 0000000000..2a376d9a67
--- /dev/null
+++ b/challenge-086/abigail/node/ch-1.js
@@ -0,0 +1,47 @@
+//
+// Read STDIN. Split on newlines, then on whitespace, and turn the results
+// into numbers. Since the input will be newline terminated, we have an
+// empty line to filter out.
+//
+let lines = require ("fs")
+ . readFileSync (0) // Read all.
+ . toString () // Turn it into a string.
+ . split ("\n"); // Split on newlines.
+
+
+//
+// Iterate pair wise over the lines
+//
+for (let i = 0; i < lines . length - 1; i += 2) {
+ //
+ // First line is a set of integers, split on
+ // white space, and store the numbers in a hash.
+ //
+ let data = lines [i] . split (" ")
+ . reduce ((acc, val) => {
+ acc [val] = acc [val] ? acc [val] + 1 : 1;
+ return acc;
+ }, {});
+
+ //
+ // Second line is the target difference
+ //
+ let diff = +lines [i + 1];
+
+ //
+ // For each number in the array, check whether there is
+ // another number so their difference is that target
+ // difference. Special care has to be taken if the target
+ // difference is 0.
+ //
+ let winner = 0;
+ Object . keys (data) . forEach ((number) => {
+ if (!winner) {
+ let target = number - diff;
+ if (data [target] && (diff || data [target] > 1)) {
+ winner = 1;
+ }
+ }
+ });
+ console . log (winner);
+}
diff --git a/challenge-086/abigail/perl/ch-1.pl b/challenge-086/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..2b06f9ef59
--- /dev/null
+++ b/challenge-086/abigail/perl/ch-1.pl
@@ -0,0 +1,61 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;