aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-276/kai-burgdorf/javascript/ch-1.js17
-rw-r--r--challenge-276/kai-burgdorf/javascript/ch-2.js18
-rwxr-xr-xchallenge-276/kai-burgdorf/perl/ch-1.pl23
-rwxr-xr-xchallenge-276/kai-burgdorf/perl/ch-2.pl31
4 files changed, 89 insertions, 0 deletions
diff --git a/challenge-276/kai-burgdorf/javascript/ch-1.js b/challenge-276/kai-burgdorf/javascript/ch-1.js
new file mode 100644
index 0000000000..1c45ef6e55
--- /dev/null
+++ b/challenge-276/kai-burgdorf/javascript/ch-1.js
@@ -0,0 +1,17 @@
+//const hours = [12, 12, 30, 24, 24];
+//const hours = [72, 48, 24, 5];
+//const hours = [12, 18, 24];
+
+var pairs = [];
+
+hours.forEach((firstSummand, i) => {
+ hours.forEach((secondSummand, j) => {
+ if( j>i && ((firstSummand + secondSummand) % 24) == 0) {
+ pairs.push("Pair " + (pairs.length+1) + ": (" + firstSummand + ", " + secondSummand + ")");
+ }
+ })
+})
+
+console.log("Output: " + pairs.length + "\n" + JSON.stringify(pairs));
+
+
diff --git a/challenge-276/kai-burgdorf/javascript/ch-2.js b/challenge-276/kai-burgdorf/javascript/ch-2.js
new file mode 100644
index 0000000000..735773bf1e
--- /dev/null
+++ b/challenge-276/kai-burgdorf/javascript/ch-2.js
@@ -0,0 +1,18 @@
+const ints = [1, 2, 2, 4, 1, 5];
+//const ints = [1, 2, 3, 4, 5];
+
+
+var frequencies = {};
+var highest = 0;
+var total = 0;
+
+ints.forEach((curInt, i) => {
+ frequencies[curInt] = (frequencies[""+curInt] === undefined) ? 1 : frequencies[""+curInt]+1;
+ if(frequencies[""+curInt] > highest) highest=frequencies[""+curInt];
+});
+
+(new Set(ints)).forEach((curInt, i) => {
+ if(frequencies[""+curInt] === highest) total+=frequencies[""+curInt];
+});
+
+console.log("Output: " + total);
diff --git a/challenge-276/kai-burgdorf/perl/ch-1.pl b/challenge-276/kai-burgdorf/perl/ch-1.pl
new file mode 100755
index 0000000000..2385b6b6d3
--- /dev/null
+++ b/challenge-276/kai-burgdorf/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+#@hours = (12, 12, 30, 24, 24);
+@hours = (72, 48, 24, 5);
+
+my $paircounter = 0;;
+my $i = 0;
+
+foreach( @hours ) {
+ my $j = 0;
+ my $firstSummand = $_;
+ foreach( @hours ) {
+ if( $j>$i && (($firstSummand + $_) % 24) == 0) {
+ $paircounter++;
+ print "Pair $paircounter: ($firstSummand, $_)\n";
+ }
+ $j++;
+ };
+ $i++;
+}
+
+print "Output: $paircounter\n";
+
diff --git a/challenge-276/kai-burgdorf/perl/ch-2.pl b/challenge-276/kai-burgdorf/perl/ch-2.pl
new file mode 100755
index 0000000000..f314b182f7
--- /dev/null
+++ b/challenge-276/kai-burgdorf/perl/ch-2.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+@ints = (1, 2, 2, 4, 1, 5);
+#@ints = (1, 2, 3, 4, 5);
+
+my %frequencies;
+my $highest = 0;
+my $total = 0;
+
+
+foreach (@ints) {
+ if (exists $frequencies{$_}) {
+ $frequencies{$_}++;
+ }
+ else {
+ $frequencies{$_} = 1;
+ }
+ if($frequencies{$_} > $highest) {
+ $highest=$frequencies{$_};
+ }
+}
+
+for(keys %frequencies){
+ print("frequ for value $_ is $frequencies{$_}\n");
+ if($frequencies{$_} == $highest) {
+ $total += $frequencies{$_};
+ }
+}
+
+print "\nhighest Frequency: $highest";
+print "\nOutput: $total";