diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-05-23 16:38:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-23 16:38:06 +0100 |
| commit | 0a814d196f273441bafcb2e9c1275b071b2f03f0 (patch) | |
| tree | ecafb97da54e8b589bf9eba82a30a9d262f3c639 | |
| parent | d4414682bc99c43c2f15301fa8c9e5202ec406e9 (diff) | |
| parent | 194e0de26203c1460061faa3c50b12a884d296cf (diff) | |
| download | perlweeklychallenge-club-0a814d196f273441bafcb2e9c1275b071b2f03f0.tar.gz perlweeklychallenge-club-0a814d196f273441bafcb2e9c1275b071b2f03f0.tar.bz2 perlweeklychallenge-club-0a814d196f273441bafcb2e9c1275b071b2f03f0.zip | |
Merge pull request #4118 from arnesom/branch-for-challenge-113
Arne Sommer
| -rw-r--r-- | challenge-113/arne-sommer/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree1.dot | 16 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree1.svg | 119 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree2.dot | 16 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree2.svg | 109 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree3.dot | 16 | ||||
| -rw-r--r-- | challenge-113/arne-sommer/misc/tree3.svg | 119 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/perl/ch-1.pl | 37 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/perl/ch-2.pl | 29 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/perl/recreate-binary-tree-perl | 29 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/perl/represent-integer-perl | 37 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/ch-1.raku | 19 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/ch-2.raku | 98 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/recreate-binary-tree | 18 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/recreate-binary-tree-truly | 87 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/recreate-binary-tree-truly2 | 98 | ||||
| -rwxr-xr-x | challenge-113/arne-sommer/raku/represent-integer | 19 |
17 files changed, 867 insertions, 0 deletions
diff --git a/challenge-113/arne-sommer/blog.txt b/challenge-113/arne-sommer/blog.txt new file mode 100644 index 0000000000..a116d654dc --- /dev/null +++ b/challenge-113/arne-sommer/blog.txt @@ -0,0 +1 @@ +https://raku-musings.com/re-re.html diff --git a/challenge-113/arne-sommer/misc/tree1.dot b/challenge-113/arne-sommer/misc/tree1.dot new file mode 100644 index 0000000000..24fbd39802 --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree1.dot @@ -0,0 +1,16 @@ +digraph foogrph { + node [shape = record,height=.1]; + node27[label = "<left> |<center> 27|<right> "]; + "node27":left -> "node26":center; + node26[label = "<left> |<center> 26|<right> "]; + "node26":left -> "node24":center; + node24[label = "<left> |<center> 24|<right> "]; + "node24":right -> "node21":center; + node21[label = "<left> |<center> 21|<right> "]; + "node27":right -> "node25":center; + node25[label = "<left> |<center> 25|<right> "]; + "node25":left -> "node23":center; + node23[label = "<left> |<center> 23|<right> "]; + "node25":right -> "node22":center; + node22[label = "<left> |<center> 22|<right> "]; +} diff --git a/challenge-113/arne-sommer/misc/tree1.svg b/challenge-113/arne-sommer/misc/tree1.svg new file mode 100644 index 0000000000..f0099653c7 --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree1.svg @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<!-- Generated by graphviz version 2.43.0 (0) + --> +<!-- Title: foogrph Pages: 1 --> +<svg width="254pt" height="212pt" + viewBox="0.00 0.00 254.00 212.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> +<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 208)"> +<title>foogrph</title> +<polygon fill="white" stroke="transparent" points="-4,4 -4,-208 250,-208 250,4 -4,4"/> +<!-- node27 --> +<g id="node1" class="node"> +<title>node27</title> +<polygon fill="none" stroke="black" points="69,-180.5 69,-203.5 139,-203.5 139,-180.5 69,-180.5"/> +<text text-anchor="middle" x="79" y="-188.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="89,-180.5 89,-203.5 "/> +<text text-anchor="middle" x="104" y="-188.3" font-family="Times,serif" font-size="14.00">27</text> +<polyline fill="none" stroke="black" points="119,-180.5 119,-203.5 "/> +<text text-anchor="middle" x="129" y="-188.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node26 --> +<g id="node2" class="node"> +<title>node26</title> +<polygon fill="none" stroke="black" points="25,-120.5 25,-143.5 95,-143.5 95,-120.5 25,-120.5"/> +<text text-anchor="middle" x="35" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="45,-120.5 45,-143.5 "/> +<text text-anchor="middle" x="60" y="-128.3" font-family="Times,serif" font-size="14.00">26</text> +<polyline fill="none" stroke="black" points="75,-120.5 75,-143.5 "/> +<text text-anchor="middle" x="85" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node27->node26 --> +<g id="edge1" class="edge"> +<title>node27:left->node26:center</title> +<path fill="none" stroke="black" d="M79,-180C79,-166.01 67.63,-162.95 62.48,-153.91"/> +<polygon fill="black" stroke="black" points="65.83,-152.85 60,-144 59.04,-154.55 65.83,-152.85"/> +</g> +<!-- node25 --> +<g id="node5" class="node"> +<title>node25</title> +<polygon fill="none" stroke="black" points="113,-120.5 113,-143.5 183,-143.5 183,-120.5 113,-120.5"/> +<text text-anchor="middle" x="123" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="133,-120.5 133,-143.5 "/> +<text text-anchor="middle" x="148" y="-128.3" font-family="Times,serif" font-size="14.00">25</text> +<polyline fill="none" stroke="black" points="163,-120.5 163,-143.5 "/> +<text text-anchor="middle" x="173" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node27->node25 --> +<g id="edge4" class="edge"> +<title>node27:right->node25:center</title> +<path fill="none" stroke="black" d="M129,-180C129,-166.01 140.37,-162.95 145.52,-153.91"/> +<polygon fill="black" stroke="black" points="148.96,-154.55 148,-144 142.17,-152.85 148.96,-154.55"/> +</g> +<!-- node24 --> +<g id="node3" class="node"> +<title>node24</title> +<polygon fill="none" stroke="black" points="0,-60.5 0,-83.5 70,-83.5 70,-60.5 0,-60.5"/> +<text text-anchor="middle" x="10" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="20,-60.5 20,-83.5 "/> +<text text-anchor="middle" x="35" y="-68.3" font-family="Times,serif" font-size="14.00">24</text> +<polyline fill="none" stroke="black" points="50,-60.5 50,-83.5 "/> +<text text-anchor="middle" x="60" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node26->node24 --> +<g id="edge2" class="edge"> +<title>node26:left->node24:center</title> +<path fill="none" stroke="black" d="M35,-120C35,-108 35,-102.75 35,-94.12"/> +<polygon fill="black" stroke="black" points="38.5,-94 35,-84 31.5,-94 38.5,-94"/> +</g> +<!-- node21 --> +<g id="node4" class="node"> +<title>node21</title> +<polygon fill="none" stroke="black" points="25,-0.5 25,-23.5 95,-23.5 95,-0.5 25,-0.5"/> +<text text-anchor="middle" x="35" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="45,-0.5 45,-23.5 "/> +<text text-anchor="middle" x="60" y="-8.3" font-family="Times,serif" font-size="14.00">21</text> +<polyline fill="none" stroke="black" points="75,-0.5 75,-23.5 "/> +<text text-anchor="middle" x="85" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node24->node21 --> +<g id="edge3" class="edge"> +<title>node24:right->node21:center</title> +<path fill="none" stroke="black" d="M60,-60C60,-48 60,-42.75 60,-34.12"/> +<polygon fill="black" stroke="black" points="63.5,-34 60,-24 56.5,-34 63.5,-34"/> +</g> +<!-- node23 --> +<g id="node6" class="node"> +<title>node23</title> +<polygon fill="none" stroke="black" points="88,-60.5 88,-83.5 158,-83.5 158,-60.5 88,-60.5"/> +<text text-anchor="middle" x="98" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="108,-60.5 108,-83.5 "/> +<text text-anchor="middle" x="123" y="-68.3" font-family="Times,serif" font-size="14.00">23</text> +<polyline fill="none" stroke="black" points="138,-60.5 138,-83.5 "/> +<text text-anchor="middle" x="148" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node25->node23 --> +<g id="edge5" class="edge"> +<title>node25:left->node23:center</title> +<path fill="none" stroke="black" d="M123,-120C123,-108 123,-102.75 123,-94.12"/> +<polygon fill="black" stroke="black" points="126.5,-94 123,-84 119.5,-94 126.5,-94"/> +</g> +<!-- node22 --> +<g id="node7" class="node"> +<title>node22</title> +<polygon fill="none" stroke="black" points="176,-60.5 176,-83.5 246,-83.5 246,-60.5 176,-60.5"/> +<text text-anchor="middle" x="186" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="196,-60.5 196,-83.5 "/> +<text text-anchor="middle" x="211" y="-68.3" font-family="Times,serif" font-size="14.00">22</text> +<polyline fill="none" stroke="black" points="226,-60.5 226,-83.5 "/> +<text text-anchor="middle" x="236" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node25->node22 --> +<g id="edge6" class="edge"> +<title>node25:right->node22:center</title> +<path fill="none" stroke="black" d="M173,-120C173,-100.92 198.57,-104.57 207.76,-93.66"/> +<polygon fill="black" stroke="black" points="211.14,-94.59 211,-84 204.5,-92.37 211.14,-94.59"/> +</g> +</g> +</svg> diff --git a/challenge-113/arne-sommer/misc/tree2.dot b/challenge-113/arne-sommer/misc/tree2.dot new file mode 100644 index 0000000000..adcd85cdbf --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree2.dot @@ -0,0 +1,16 @@ +digraph foogrph { + node [shape = record,height=.1]; + node21[label = "<left> |<center> 21|<right> "]; + "node21":left -> "node20":center; + node20[label = "<left> |<center> 20|<right> "]; + "node20":left -> "node18":center; + node18[label = "<left> |<center> 18|<right> "]; + "node18":right -> "node21":center; + node21[label = "<left> |<center> 21|<right> "]; + "node21":right -> "node19":center; + node19[label = "<left> |<center> 19|<right> "]; + "node19":left -> "node17":center; + node17[label = "<left> |<center> 17|<right> "]; + "node19":right -> "node16":center; + node16[label = "<left> |<center> 16|<right> "]; +} diff --git a/challenge-113/arne-sommer/misc/tree2.svg b/challenge-113/arne-sommer/misc/tree2.svg new file mode 100644 index 0000000000..a52f38f373 --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree2.svg @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<!-- Generated by graphviz version 2.43.0 (0) + --> +<!-- Title: foogrph Pages: 1 --> +<svg width="273pt" height="152pt" + viewBox="0.00 0.00 273.00 152.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> +<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 148)"> +<title>foogrph</title> +<polygon fill="white" stroke="transparent" points="-4,4 -4,-148 269,-148 269,4 -4,4"/> +<!-- node21 --> +<g id="node1" class="node"> +<title>node21</title> +<polygon fill="none" stroke="black" points="78,-120.5 78,-143.5 148,-143.5 148,-120.5 78,-120.5"/> +<text text-anchor="middle" x="88" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="98,-120.5 98,-143.5 "/> +<text text-anchor="middle" x="113" y="-128.3" font-family="Times,serif" font-size="14.00">21</text> +<polyline fill="none" stroke="black" points="128,-120.5 128,-143.5 "/> +<text text-anchor="middle" x="138" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node20 --> +<g id="node2" class="node"> +<title>node20</title> +<polygon fill="none" stroke="black" points="15,-60.5 15,-83.5 85,-83.5 85,-60.5 15,-60.5"/> +<text text-anchor="middle" x="25" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="35,-60.5 35,-83.5 "/> +<text text-anchor="middle" x="50" y="-68.3" font-family="Times,serif" font-size="14.00">20</text> +<polyline fill="none" stroke="black" points="65,-60.5 65,-83.5 "/> +<text text-anchor="middle" x="75" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node21->node20 --> +<g id="edge1" class="edge"> +<title>node21:left->node20:center</title> +<path fill="none" stroke="black" d="M88,-120C88,-100.92 62.43,-104.57 53.24,-93.66"/> +<polygon fill="black" stroke="black" points="56.5,-92.37 50,-84 49.86,-94.59 56.5,-92.37"/> +</g> +<!-- node19 --> +<g id="node4" class="node"> +<title>node19</title> +<polygon fill="none" stroke="black" points="141,-60.5 141,-83.5 211,-83.5 211,-60.5 141,-60.5"/> +<text text-anchor="middle" x="151" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="161,-60.5 161,-83.5 "/> +<text text-anchor="middle" x="176" y="-68.3" font-family="Times,serif" font-size="14.00">19</text> +<polyline fill="none" stroke="black" points="191,-60.5 191,-83.5 "/> +<text text-anchor="middle" x="201" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node21->node19 --> +<g id="edge4" class="edge"> +<title>node21:right->node19:center</title> +<path fill="none" stroke="black" d="M138,-120C138,-100.92 163.57,-104.57 172.76,-93.66"/> +<polygon fill="black" stroke="black" points="176.14,-94.59 176,-84 169.5,-92.37 176.14,-94.59"/> +</g> +<!-- node18 --> +<g id="node3" class="node"> +<title>node18</title> +<polygon fill="none" stroke="black" points="0,-0.5 0,-23.5 70,-23.5 70,-0.5 0,-0.5"/> +<text text-anchor="middle" x="10" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="20,-0.5 20,-23.5 "/> +<text text-anchor="middle" x="35" y="-8.3" font-family="Times,serif" font-size="14.00">18</text> +<polyline fill="none" stroke="black" points="50,-0.5 50,-23.5 "/> +<text text-anchor="middle" x="60" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node20->node18 --> +<g id="edge2" class="edge"> +<title>node20:left->node18:center</title> +<path fill="none" stroke="black" d="M25,-60C25,-47.42 30.74,-42.77 33.52,-34.03"/> +<polygon fill="black" stroke="black" points="37.01,-34.4 35,-24 30.08,-33.38 37.01,-34.4"/> +</g> +<!-- node18->node21 --> +<g id="edge3" class="edge"> +<title>node18:right->node21:center</title> +<path fill="none" stroke="black" d="M60,-24C60,-46.01 82.84,-41.03 94,-60 106.3,-80.91 111.56,-89.64 112.73,-109.83"/> +<polygon fill="black" stroke="black" points="109.24,-110.09 113,-120 116.24,-109.91 109.24,-110.09"/> +</g> +<!-- node17 --> +<g id="node5" class="node"> +<title>node17</title> +<polygon fill="none" stroke="black" points="107,-0.5 107,-23.5 177,-23.5 177,-0.5 107,-0.5"/> +<text text-anchor="middle" x="117" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="127,-0.5 127,-23.5 "/> +<text text-anchor="middle" x="142" y="-8.3" font-family="Times,serif" font-size="14.00">17</text> +<polyline fill="none" stroke="black" points="157,-0.5 157,-23.5 "/> +<text text-anchor="middle" x="167" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node19->node17 --> +<g id="edge5" class="edge"> +<title>node19:left->node17:center</title> +<path fill="none" stroke="black" d="M151,-60C151,-47.5 145.83,-42.74 143.33,-33.99"/> +<polygon fill="black" stroke="black" points="146.79,-33.45 142,-24 139.85,-34.37 146.79,-33.45"/> +</g> +<!-- node16 --> +<g id="node6" class="node"> +<title>node16</title> +<polygon fill="none" stroke="black" points="195,-0.5 195,-23.5 265,-23.5 265,-0.5 195,-0.5"/> +<text text-anchor="middle" x="205" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="215,-0.5 215,-23.5 "/> +<text text-anchor="middle" x="230" y="-8.3" font-family="Times,serif" font-size="14.00">16</text> +<polyline fill="none" stroke="black" points="245,-0.5 245,-23.5 "/> +<text text-anchor="middle" x="255" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node19->node16 --> +<g id="edge6" class="edge"> +<title>node19:right->node16:center</title> +<path fill="none" stroke="black" d="M201,-60C201,-43.63 219.42,-43.54 226.9,-33.78"/> +<polygon fill="black" stroke="black" points="230.31,-34.59 230,-24 223.64,-32.47 230.31,-34.59"/> +</g> +</g> +</svg> diff --git a/challenge-113/arne-sommer/misc/tree3.dot b/challenge-113/arne-sommer/misc/tree3.dot new file mode 100644 index 0000000000..acd1c7376d --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree3.dot @@ -0,0 +1,16 @@ +digraph foogrph { + node [shape = record,height=.1]; + node94557370778344[label = "<left> |<center> 21|<right> "]; + "node94557370778344":left -> "node94557370778232":center; + node94557370778232[label = "<left> |<center> 20|<right> "]; + "node94557370778232":left -> "node94557370778064":center; + node94557370778064[label = "<left> |<center> 18|<right> "]; + "node94557370778064":right -> "node94557370778008":center; + node94557370778008[label = "<left> |<center> 21|<right> "]; + "node94557370778344":right -> "node94557370778288":center; + node94557370778288[label = "<left> |<center> 19|<right> "]; + "node94557370778288":left -> "node94557370778120":center; + node94557370778120[label = "<left> |<center> 17|<right> "]; + "node94557370778288":right -> "node94557370778176":center; + node94557370778176[label = "<left> |<center> 16|<right> "]; +} diff --git a/challenge-113/arne-sommer/misc/tree3.svg b/challenge-113/arne-sommer/misc/tree3.svg new file mode 100644 index 0000000000..008b0f8d4e --- /dev/null +++ b/challenge-113/arne-sommer/misc/tree3.svg @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<!-- Generated by graphviz version 2.43.0 (0) + --> +<!-- Title: foogrph Pages: 1 --> +<svg width="254pt" height="212pt" + viewBox="0.00 0.00 254.00 212.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> +<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 208)"> +<title>foogrph</title> +<polygon fill="white" stroke="transparent" points="-4,4 -4,-208 250,-208 250,4 -4,4"/> +<!-- node94557370778344 --> +<g id="node1" class="node"> +<title>node94557370778344</title> +<polygon fill="none" stroke="black" points="69,-180.5 69,-203.5 139,-203.5 139,-180.5 69,-180.5"/> +<text text-anchor="middle" x="79" y="-188.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="89,-180.5 89,-203.5 "/> +<text text-anchor="middle" x="104" y="-188.3" font-family="Times,serif" font-size="14.00">21</text> +<polyline fill="none" stroke="black" points="119,-180.5 119,-203.5 "/> +<text text-anchor="middle" x="129" y="-188.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778232 --> +<g id="node2" class="node"> +<title>node94557370778232</title> +<polygon fill="none" stroke="black" points="25,-120.5 25,-143.5 95,-143.5 95,-120.5 25,-120.5"/> +<text text-anchor="middle" x="35" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="45,-120.5 45,-143.5 "/> +<text text-anchor="middle" x="60" y="-128.3" font-family="Times,serif" font-size="14.00">20</text> +<polyline fill="none" stroke="black" points="75,-120.5 75,-143.5 "/> +<text text-anchor="middle" x="85" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778344->node94557370778232 --> +<g id="edge1" class="edge"> +<title>node94557370778344:left->node94557370778232:center</title> +<path fill="none" stroke="black" d="M79,-180C79,-166.01 67.63,-162.95 62.48,-153.91"/> +<polygon fill="black" stroke="black" points="65.83,-152.85 60,-144 59.04,-154.55 65.83,-152.85"/> +</g> +<!-- node94557370778288 --> +<g id="node5" class="node"> +<title>node94557370778288</title> +<polygon fill="none" stroke="black" points="113,-120.5 113,-143.5 183,-143.5 183,-120.5 113,-120.5"/> +<text text-anchor="middle" x="123" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="133,-120.5 133,-143.5 "/> +<text text-anchor="middle" x="148" y="-128.3" font-family="Times,serif" font-size="14.00">19</text> +<polyline fill="none" stroke="black" points="163,-120.5 163,-143.5 "/> +<text text-anchor="middle" x="173" y="-128.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778344->node94557370778288 --> +<g id="edge4" class="edge"> +<title>node94557370778344:right->node94557370778288:center</title> +<path fill="none" stroke="black" d="M129,-180C129,-166.01 140.37,-162.95 145.52,-153.91"/> +<polygon fill="black" stroke="black" points="148.96,-154.55 148,-144 142.17,-152.85 148.96,-154.55"/> +</g> +<!-- node94557370778064 --> +<g id="node3" class="node"> +<title>node94557370778064</title> +<polygon fill="none" stroke="black" points="0,-60.5 0,-83.5 70,-83.5 70,-60.5 0,-60.5"/> +<text text-anchor="middle" x="10" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="20,-60.5 20,-83.5 "/> +<text text-anchor="middle" x="35" y="-68.3" font-family="Times,serif" font-size="14.00">18</text> +<polyline fill="none" stroke="black" points="50,-60.5 50,-83.5 "/> +<text text-anchor="middle" x="60" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778232->node94557370778064 --> +<g id="edge2" class="edge"> +<title>node94557370778232:left->node94557370778064:center</title> +<path fill="none" stroke="black" d="M35,-120C35,-108 35,-102.75 35,-94.12"/> +<polygon fill="black" stroke="black" points="38.5,-94 35,-84 31.5,-94 38.5,-94"/> +</g> +<!-- node94557370778008 --> +<g id="node4" class="node"> +<title>node94557370778008</title> +<polygon fill="none" stroke="black" points="25,-0.5 25,-23.5 95,-23.5 95,-0.5 25,-0.5"/> +<text text-anchor="middle" x="35" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="45,-0.5 45,-23.5 "/> +<text text-anchor="middle" x="60" y="-8.3" font-family="Times,serif" font-size="14.00">21</text> +<polyline fill="none" stroke="black" points="75,-0.5 75,-23.5 "/> +<text text-anchor="middle" x="85" y="-8.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778064->node94557370778008 --> +<g id="edge3" class="edge"> +<title>node94557370778064:right->node94557370778008:center</title> +<path fill="none" stroke="black" d="M60,-60C60,-48 60,-42.75 60,-34.12"/> +<polygon fill="black" stroke="black" points="63.5,-34 60,-24 56.5,-34 63.5,-34"/> +</g> +<!-- node94557370778120 --> +<g id="node6" class="node"> +<title>node94557370778120</title> +<polygon fill="none" stroke="black" points="88,-60.5 88,-83.5 158,-83.5 158,-60.5 88,-60.5"/> +<text text-anchor="middle" x="98" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="108,-60.5 108,-83.5 "/> +<text text-anchor="middle" x="123" y="-68.3" font-family="Times,serif" font-size="14.00">17</text> +<polyline fill="none" stroke="black" points="138,-60.5 138,-83.5 "/> +<text text-anchor="middle" x="148" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778288->node94557370778120 --> +<g id="edge5" class="edge"> +<title>node94557370778288:left->node94557370778120:center</title> +<path fill="none" stroke="black" d="M123,-120C123,-108 123,-102.75 123,-94.12"/> +<polygon fill="black" stroke="black" points="126.5,-94 123,-84 119.5,-94 126.5,-94"/> +</g> +<!-- node94557370778176 --> +<g id="node7" class="node"> +<title>node94557370778176</title> +<polygon fill="none" stroke="black" points="176,-60.5 176,-83.5 246,-83.5 246,-60.5 176,-60.5"/> +<text text-anchor="middle" x="186" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +<polyline fill="none" stroke="black" points="196,-60.5 196,-83.5 "/> +<text text-anchor="middle" x="211" y="-68.3" font-family="Times,serif" font-size="14.00">16</text> +<polyline fill="none" stroke="black" points="226,-60.5 226,-83.5 "/> +<text text-anchor="middle" x="236" y="-68.3" font-family="Times,serif" font-size="14.00"> </text> +</g> +<!-- node94557370778288->node94557370778176 --> +<g id="edge6" class="edge"> +<title>node94557370778288:right->node94557370778176:center</title> +<path fill="none" stroke="black" d="M173,-120C173,-100.92 198.57,-104.57 207.76,-93.66"/> +<polygon fill="black" stroke="black" points="211.14,-94.59 211,-84 204.5,-92.37 211.14,-94.59"/> +</g> +</g> +</svg> diff --git a/challenge-113/arne-sommer/perl/ch-1.pl b/challenge-113/arne-sommer/perl/ch-1.pl new file mode 100755 index 0000000000..9d6a3af8dc --- /dev/null +++ b/challenge-113/arne-sommer/perl/ch-1.pl @@ -0,0 +1,37 @@ +#! /usr/bin/env perl + +use strict; +use feature 'say'; + +use Algorithm::Combinatorics 'combinations'; +use List::Util 'sum'; +use Getopt::Long; + +my $verbose = 0; +GetOptions("verbose" => \$verbose); + +my $N = shift(@ARGV) // die "Please specify an integer > 0"; +die "Please specify an integer > 0" unless $N =~ /^[1-9]\d*$/; + +my $D = shift(@ARGV) // die "Please specify a digit"; +die "Please specify a digit" unless $D =~ /^\d$/; + +my @candidates = grep { /$D/ } (1 .. $N); + +say ": Candidates " . join(', ', @candidates) if $verbose; + +for my $size (1 .. @candidates) +{ + for my $comb (combinations(\@candidates, $size)) + { + say ": Considering " . join(' + ', @$comb) if $verbose; + + if (sum(@$comb) == $N) + { + say 1; + exit; + } + } +} + +say 0; diff --git a/challenge-113/arne-sommer/perl/ch-2.pl b/challenge-113/arne-sommer/perl/ch-2.pl new file mode 100755 index 0000000000..6cdb10322f --- /dev/null +++ b/challenge-113/arne-sommer/perl/ch-2.pl @@ -0,0 +1,29 @@ +#! /usr/bin/env perl + +use strict; +use warnings; +use feature 'say'; + +use Getopt::Long; +use List::Util qw(sum); + +my $verbose = 0; + +GetOptions("verbose" => \$verbose); + +my $tree = shift(@$ARGV) // '1 | 2 3 | 4 * 5 6 | * 7'; + +my $sum = sum(grep(/\d/, split(/\s+/, $tree))); + +say ": Sum: $sum" if $verbose; + +my @elems; + +for my $elem (split(/\s+/, $tree)) +{ + $elem =~ /\d/ + ? push(@elems, $sum - $elem) + : push(@elems, $elem); +} + +say join(" ", @elems); diff --git a/challenge-113/arne-sommer/perl/recreate-binary-tree-perl b/challenge-113/arne-sommer/perl/recreate-binary-tree-perl new file mode 100755 index 0000000000..6cdb10322f --- /dev/null +++ b/challenge-113/arne-sommer/perl/recreate-binary-tree-perl @@ -0,0 +1,29 @@ +#! /usr/bin/env perl + +use strict; +use warnings; +use feature 'say'; + +use Getopt::Long; +use List::Util qw(sum); + +my $verbose = 0; + +GetOptions("verbose" => \$verbose); + +my $tree = shift(@$ARGV) // '1 | 2 3 | 4 * 5 6 | * 7'; + +my $sum = sum(grep(/\d/, split(/\s+/, $tree))); + +say ": Sum: $sum" if $verbose; + +my @elems; + +for my $elem (split(/\s+/, $tree)) +{ + $elem =~ /\d/ + ? push(@elems, $sum - $elem) + : push(@elems, $elem); +} + +say join(" ", @elems); diff --git a/challenge-113/arne-sommer/perl/represent-integer-perl b/challenge-113/arne-sommer/perl/represent-integer-perl new file mode 100755 index 0000000000..9d6a3af8dc --- /dev/null +++ b/challenge-113/arne-sommer/perl/represent-integer-perl @@ -0,0 +1,37 @@ +#! /usr/bin/env perl + +use strict; +use feature 'say'; + +use Algorithm::Combinatorics 'combinations'; +use List::Util 'sum'; +use Getopt::Long; + +my $verbose = 0; +GetOptions("verbose" => \$verbose); + +my $N = shift(@ARGV) // die "Please specify an integer > 0"; +die "Please specify an integer > 0" unless $N =~ /^[1-9]\d*$/; + +my $D = shift(@ARGV) // die "Please specify a digit"; +die "Please specify a digit" unless $D =~ /^\d$/; + +my @candidates = grep { /$D/ } (1 .. $N); + +say ": Candidates " . join(', ', @candidates) if $verbose; + +for my $size (1 .. @candidates) +{ + for my $comb (combinations(\@candidates, $size)) + { + say ": Considering " . join(' + ', @$comb) if $verbose; + + if (sum(@$comb) == $N) + { + say 1; + exit; + } + } +} + +say 0; diff --git a/challenge-113/arne-sommer/raku/ch-1.raku b/challenge-113/arne-sommer/raku/ch-1.raku new file mode 100755 index 0000000000..ef6e2f7c93 --- /dev/null +++ b/challenge-113/arne-sommer/raku/ch-1.raku @@ -0,0 +1,19 @@ +#! /usr/bin/env raku + +unit sub MAIN (Int $N where $N > 0, Int $D where $D.chars == 1, :v($verbose)); + +my @candidates = (1 .. $N).grep( * ~~ /$D/); + +say ": Candidates { @candidates.join(', ') }" if $verbose; + +for @candidates.combinations(1..*) -> @comb +{ + say ": Considering { @comb.join(' + ') }" if $verbose; + if @comb.sum == $N + { + say 1; + exit; + } +} + +say 0;
\ No newline at end of file diff --git a/challenge-113/arne-sommer/raku/ch-2.raku b/challenge-113/arne-sommer/raku/ch-2.raku new file mode 100755 index 0000000000..caf24b1596 --- /dev/null +++ b/challenge-113/arne-sommer/raku/ch-2.raku @@ -0,0 +1,98 @@ +#! /usr/bin/env raku + +unit sub MAIN (Str $tree = '1 | 2 3 | 4 * 5 6 | * 7', :v($verbose), :g(:$graph)); + +class BinaryNode +{ + has Numeric $.value is rw; + has BinaryNode $.left is rw; + has BinaryNode $.right is rw; + + method id + { + self.Str ~~ /(\d+)/; return $0.Str; + } + + method sum + { + my $sum = self.value; + $sum += self.left.sum if self.left.defined; + $sum += self.right.sum if self.right.defined; + return $sum; + } +} + +my @btree = $tree.split("|")>>.words; + +my @old-nodes; +my @new-nodes; + +for @btree.reverse -> $row +{ + my @current = @$row; + @old-nodes = @new-nodes; + @new-nodes = (); + + for @current -> $value + { + if $value eq "*" + { + @new-nodes.push("*"); + next; + } + + my $left = @old-nodes.shift // "*"; $left = Nil if $left eq "*"; + my $right = @old-nodes.shift // "*"; $right = Nil if $right eq "*"; + + @new-nodes.push(BinaryNode.new(value => $value.Int, + left => $left // Nil, + right => $right // Nil)); + } +} + +my $btree = @new-nodes[0]; + +say ": Sum: { $btree.sum }" if $verbose; + +say ": { $btree.raku }\n" if $verbose; + +traverse($btree); + +say ": { $btree.raku }\n" if $verbose; + +graph($btree) if $graph; + +sub traverse ($current) +{ + $current.value = $sum - $current.value; + + traverse($current.left) if $current.left.defined; + traverse($current.right) if $current.right.defined; +} + +sub graph ($graph) +{ + say 'digraph foogrph {'; + say ' node [shape = record,height=.1];'; + + do-it($graph); + + say '}'; + + sub do-it ($current) + { + say " node{ $current.id }[label = \"<left> |<center> { $current.value }|<right> \"];"; + + if $current.left.defined + { + say " \"node{ $current.id }\":left -> \"node{ $current.left.id }\":center;"; + do-it($current.left); + } + + if $current.right.defined + { + say " \"node{ $current.id }\":right -> \"node{ $current.right.id }\":center;"; + do-it($current.right); + } + } +} diff --git a/challenge-113/arne-sommer/raku/recreate-binary-tree b/challenge-113/arne-sommer/raku/recreate-binary-tree new file mode 100755 index 0000000000..44b8783893 --- /dev/null +++ b/challenge-113/arne-sommer/raku/recreate-binary-tree |
