aboutsummaryrefslogtreecommitdiff
path: root/challenge-113/abigail/README.md
blob: a026cb8bf70d95a83c6d5bfca0f7d4c40b81a401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Solutions by Abigail
## [Represent Integer](https://perlweeklychallenge.org/blog/perl-weekly-challenge-113/#TASK1)

> You are given a positive integer `$N` and a digit `$D`.
>
> Write a script to check if `$N` can be represented as a sum
> of positive integers having `$D` at least once. If check passes
> print `1` otherwise `0`.

### Example
~~~~
Input: $N = 25, $D = 7
Output: 0 as there are 2 numbers between 1 and 25 having the digit 7
        i.e. 7 and 17. If we add up both we don't get 25.

Input: $N = 24, $D = 7
Output: 1
~~~~

### Solutions
* [AWK](awk/ch-1.awk)
* [Bash](bash/ch-1.sh)
* [C](c/ch-1.c)
* [Lua](lua/ch-1.lua)
* [Node.js](node/ch-1.js)
* [Perl](perl/ch-1.pl)
* [Python](python/ch-1.py)
* [Ruby](ruby/ch-1.rb)

### Blog
[Perl Weekly Challenge 113: Represent
Integer](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-113-1.html)

## [Recreate Binary Tree](https://perlweeklychallenge.org/blog/perl-weekly-challenge-113/#TASK2)

> You are given a Binary Tree.
> 
> Write a script to replace each node of the tree with the sum of
> all the remaining nodes

### Example
#### Input
~~~~
        1
       / \
      2   3
     /   / \
    4   5   6
     \
      7
~~~~
#### Output
~~~~
        27
       /  \
      26  25
     /   /  \
    24  23  22
     \
     21
~~~~


### Solutions
* [AWK](awk/ch-2.awk)
* [Bash](bash/ch-2.sh)
* [C](c/ch-2.c)
* [Lua](lua/ch-2.lua)
* [Node.js](node/ch-2.js)
* [Perl](perl/ch-2.pl)
* [Python](python/ch-2.py)
* [Ruby](ruby/ch-2.rb)

### Blog
[Perl Weekly Challenge 113: Recreate Binary
Tree](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-113-2.html)