aboutsummaryrefslogtreecommitdiff
path: root/challenge-205
diff options
context:
space:
mode:
authorMatthiasMuth <99873492+MatthiasMuth@users.noreply.github.com>2023-02-26 08:55:07 +0100
committerGitHub <noreply@github.com>2023-02-26 08:55:07 +0100
commitc46b4601eebf7c48a352d7f75352ad984f0d99ab (patch)
tree74fa8ee0305f08f5618e93d5cc5c1427ed4a9fa4 /challenge-205
parent9ae3ffca43334638ce57214ba1b84f9d5dff881c (diff)
parentb284f024a9a0fb134828bfaba21aa1d5354ac2f7 (diff)
downloadperlweeklychallenge-club-c46b4601eebf7c48a352d7f75352ad984f0d99ab.tar.gz
perlweeklychallenge-club-c46b4601eebf7c48a352d7f75352ad984f0d99ab.tar.bz2
perlweeklychallenge-club-c46b4601eebf7c48a352d7f75352ad984f0d99ab.zip
Merge branch 'manwar:master' into muthm-205
Diffstat (limited to 'challenge-205')
-rw-r--r--challenge-205/kjetillll/perl/ch-1.pl3
-rw-r--r--challenge-205/kjetillll/perl/ch-2.pl15
-rw-r--r--challenge-205/polettix/blog.txt1
-rw-r--r--challenge-205/polettix/blog1.txt1
-rw-r--r--challenge-205/polettix/perl/ch-1.pl22
-rw-r--r--challenge-205/polettix/perl/ch-2.pl17
-rw-r--r--challenge-205/polettix/raku/ch-1.raku18
-rw-r--r--challenge-205/polettix/raku/ch-2.raku6
-rw-r--r--challenge-205/shawn-wagner/racket/ch-1.rkt46
-rw-r--r--challenge-205/shawn-wagner/racket/ch-2.rkt21
-rw-r--r--challenge-205/solathian/perl/ch-1.pl47
-rw-r--r--challenge-205/solathian/perl/ch-2.pl36
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/README.md10
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/bb.edn2
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/build.clj19
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/deps.edn4
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/src/c205/t1.clj17
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/src/c205/t2.clj20
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/test/c205/t1_test.clj9
-rw-r--r--challenge-205/tyler-wardhaugh/clojure/test/c205/t2_test.clj8
-rw-r--r--challenge-205/ulrich-rieke/cpp/ch-1.cpp19
-rw-r--r--challenge-205/ulrich-rieke/cpp/ch-2.cpp22
-rw-r--r--challenge-205/ulrich-rieke/haskell/ch-1.hs14
-rw-r--r--challenge-205/ulrich-rieke/haskell/ch-2.hs15
-rw-r--r--challenge-205/ulrich-rieke/perl/ch-1.pl15
-rw-r--r--challenge-205/ulrich-rieke/perl/ch-2.pl18
-rw-r--r--challenge-205/ulrich-rieke/raku/ch-1.raku13
-rw-r--r--challenge-205/ulrich-rieke/rust/ch-1.rs26
-rw-r--r--challenge-205/ulrich-rieke/rust/ch-2.rs22
29 files changed, 478 insertions, 8 deletions
diff --git a/challenge-205/kjetillll/perl/ch-1.pl b/challenge-205/kjetillll/perl/ch-1.pl
new file mode 100644
index 0000000000..9583b00105
--- /dev/null
+++ b/challenge-205/kjetillll/perl/ch-1.pl
@@ -0,0 +1,3 @@
+my( $a, $b, $c ) = sort {$b <=> $a} @ARGV;
+print $c // $a;
+print "\n";
diff --git a/challenge-205/kjetillll/perl/ch-2.pl b/challenge-205/kjetillll/perl/ch-2.pl
new file mode 100644
index 0000000000..9ab1f1aab9
--- /dev/null
+++ b/challenge-205/kjetillll/perl/ch-2.pl
@@ -0,0 +1,15 @@
+
+#----optimize for brevity:
+#print [ sort {$b <=> $a} map {//; map 0+$_ ^ 0+$', @ARGV } @ARGV ]->[0];
+#print "\n";
+
+
+#---- or optimize for clarity:
+my $highest;
+for my $a (@ARGV){
+for my $b (@ARGV){
+ my $xor = 0+$a ^ 0+$b;
+ $highest = $xor if not defined $highest
+ or $xor > $highest;
+}}
+print "$highest\n";
diff --git a/challenge-205/polettix/blog.txt b/challenge-205/polettix/blog.txt
new file mode 100644
index 0000000000..d59165c930
--- /dev/null
+++ b/challenge-205/polettix/blog.txt
@@ -0,0 +1 @@
+https://etoobusy.polettix.it/2023/02/23/pwc205-third-highest/
diff --git a/challenge-205/polettix/blog1.txt b/challenge-205/polettix/blog1.txt
new file mode 100644
index 0000000000..178dfa1adb
--- /dev/null
+++ b/challenge-205/polettix/blog1.txt
@@ -0,0 +1 @@
+https://etoobusy.polettix.it/2023/02/24/pwc205-maximum-xor/
diff --git a/challenge-205/polettix/perl/ch-1.pl b/challenge-205/polettix/perl/ch-1.pl
new file mode 100644
index 0000000000..b08ee71fc3
--- /dev/null
+++ b/challenge-205/polettix/perl/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+use v5.24;
+use warnings;
+use experimental 'signatures';
+
+say third_highest(@ARGV);
+
+sub third_highest (@array) {
+ my @highest;
+ ITEM:
+ for (@array) {
+ my $x = $_; # work with a copy
+ for my $i (0 .. $#highest) {
+ next ITEM if $x == $highest[$i];
+ ($x, $highest[$i]) = ($highest[$i], $x) if $x > $highest[$i];
+ }
+ push @highest, $x if @highest < 3;
+ }
+ return @highest == 3 ? $highest[2]
+ : @highest > 0 ? $highest[0]
+ : undef;
+}
diff --git a/challenge-205/polettix/perl/ch-2.pl b/challenge-205/polettix/perl/ch-2.pl
new file mode 100644
index 0000000000..2bbf4a3aa8
--- /dev/null
+++ b/challenge-205/polettix/perl/ch-2.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+use v5.24;
+use warnings;
+use experimental qw< bitwise signatures >;
+
+say maximum_xor(@ARGV);
+
+sub maximum_xor (@array) {
+ my $max = 0;
+ for my $i (0 .. $#array - 1) {
+ for my $j ($i + 1 .. $#array) {
+ my $xor = $array[$i] ^ $array[$j];
+ $max = $xor if $xor > $max;
+ }
+ }
+ return $max;
+}
diff --git a/challenge-205/polettix/raku/ch-1.raku b/challenge-205/polettix/raku/ch-1.raku
new file mode 100644
index 0000000000..642f572045
--- /dev/null
+++ b/challenge-205/polettix/raku/ch-1.raku
@@ -0,0 +1,18 @@
+#!/usr/bin/env raku
+use v6;
+sub MAIN (*@args) { put third-highest(@args) }
+
+sub third-highest (@array) {
+ my @highest;
+ ITEM:
+ for @array -> $x is copy {
+ for ^@highest -> $i {
+ next ITEM if $x == @highest[$i];
+ ($x, @highest[$i]) = @highest[$i], $x if $x > @highest[$i];
+ }
+ @highest.push: $x if @highest < 3;
+ }
+ return @highest == 3 ?? @highest[2]
+ !! @highest > 0 ?? @highest[0]
+ !! Nil;
+}
diff --git a/challenge-205/polettix/raku/ch-2.raku b/challenge-205/polettix/raku/ch-2.raku
new file mode 100644
index 0000000000..a0197e3ceb
--- /dev/null
+++ b/challenge-205/polettix/raku/ch-2.raku
@@ -0,0 +1,6 @@
+#!/usr/bin/env raku
+use v6;
+sub MAIN (*@args) { put maximum-xor2(@args) }
+
+sub maximum-xor (@array) { @array .combinations(2) .map({[+^] $_}) .max }
+sub maximum-xor2 (@a) { @a.combinations(2).map(->($x,$y){$x +^ $y}).max }
diff --git a/challenge-205/shawn-wagner/racket/ch-1.rkt b/challenge-205/shawn-wagner/racket/ch-1.rkt
new file mode 100644
index 0000000000..8cd2fcba41
--- /dev/null
+++ b/challenge-205/shawn-wagner/racket/ch-1.rkt
@@ -0,0 +1,46 @@
+#lang racket/base
+
+(require srfi/43) ; For vector-swap!
+
+(define (vector-partition! vec left right pivot-index <?)
+ (define pivot (vector-ref vec pivot-index))
+ (vector-swap! vec pivot-index right)
+ (let loop ([i left]
+ [store-index left])
+ (cond
+ ((< i right)
+ (cond
+ ((<? (vector-ref vec i) pivot)
+ (vector-swap! vec store-index i)
+ (loop (+ i 1) (+ store-index 1)))
+ (else
+ (loop (+ i 1) store-index))))
+ (else
+ (vector-swap! vec right store-index)
+ store-index))))
+
+;;; Basic quickselect
+(define (kth-element! vec k <? [left 0] [right (- (vector-length vec) 1)])
+ (if (= left right)
+ (vector-ref vec left)
+ (let* ([pivot-index (random left (+ right 1))]
+ [pivot-index (vector-partition! vec left right pivot-index <?)])
+ (cond
+ ((= k pivot-index)
+ (vector-ref vec k))
+ ((< k pivot-index)
+ (kth-element! vec k <? left (- pivot-index 1)))
+ (else
+ (kth-element! vec k <? (+ pivot-index 1) right))))))
+
+(define (solution vec)
+ (if (< (vector-length vec) 3)
+ (apply max (vector->list vec))
+ (kth-element! (vector-copy vec) 2 >)))
+
+(define (demo num vec)
+ (printf "Example ~A: Third highest element of ~S -> ~A~%" num vec (solution vec)))
+
+(demo 1 #(5 3 4))
+(demo 2 #(5 6))
+(demo 3 #(5 4 4 3))
diff --git a/challenge-205/shawn-wagner/racket/ch-2.rkt b/challenge-205/shawn-wagner/racket/ch-2.rkt
new file mode 100644
index 0000000000..2d8d88e5b8
--- /dev/null
+++ b/challenge-205/shawn-wagner/racket/ch-2.rkt
@@ -0,0 +1,21 @@
+#lang racket/base
+
+(require racket/list racket/match)
+(define (solution nums)
+ (for/fold ([num1 -1]
+ [num2 -1]
+ [max-xor 0])
+ ([pair (in-combinations nums 2)])
+ (match-let ([(list p1 p2) pair])
+ (let ([xor (bitwise-xor p1 p2)])
+ (if (> xor max-xor)
+ (values p1 p2 xor)
+ (values num1 num2 max-xor))))))
+
+(define (demo n nums)
+ (let-values ([(n1 n2 xor) (solution nums)])
+ (printf "Example ~A: The maximum result of ~A xor ~A = ~A~%" n n1 n2 xor)))
+
+(demo 1 '(1 2 3 4 5 6 7))
+(demo 2 '(2 4 1 3))
+(demo 3 '(10 5 7 12 8))
diff --git a/challenge-205/solathian/perl/ch-1.pl b/challenge-205/solathian/perl/ch-1.pl
new file mode 100644
index 0000000000..315ed16cbb
--- /dev/null
+++ b/challenge-205/solathian/perl/ch-1.pl
@@ -0,0 +1,47 @@
+#!usr/bin/perl
+use v5.36;
+
+# Challange 205 - 1 - Third Highest
+# You are given an array of integers.
+# Write a script to find out the Third Highest if found otherwise return the maximum.
+
+thirdHighest(5,4,4,3); # 3 # First highest is 5. Second highest is 4. Third highest is 3.
+thirdHighest(5,6); # 6 # First highest is 6. Second highest is 5. Third highest is missing, so maximum is returned.
+thirdHighest(5,3,4); # 3 # First highest is 5. Second highest is 4. Third highest is 3.
+thirdHighest(); # Array is empty
+thirdHighest(5,5,5);
+thirdHighest(5,5,4,4,3,3);
+
+sub trimArray($arrRef) # remove duplicated elements from the array
+{
+ my @trimmedArr;
+
+ if(@$arrRef > 0)
+ {
+ @$arrRef = sort @$arrRef;
+
+ my $last = $arrRef->[0];
+ push(@trimmedArr, $last);
+
+ for(my $i = 1; $i < @$arrRef; $i++)
+ {
+ if($last != $arrRef->[$i])
+ {
+ $last = $arrRef->[$i];
+ push(@trimmedArr, $last);
+
+ }
+ }
+ }
+
+ return @trimmedArr;
+}
+
+sub thirdHighest(@array)
+{
+ @array = trimArray(\@array);
+
+ if(@array == 0) {say "Array is empty."}
+ elsif(@array < 3) {say $array[-1]}
+ else {say $array[-3]}
+} \ No newline at end of file
diff --git a/challenge-205/solathian/perl/ch-2.pl b/challenge-205/solathian/perl/ch-2.pl
new file mode 100644
index 0000000000..2bfcb001c0
--- /dev/null
+++ b/challenge-205/solathian/perl/ch-2.pl
@@ -0,0 +1,36 @@
+#!usr/bin/perl
+use v5.36;
+
+# Challange 205 - 2 - Maximum XOR
+# You are given an array of integers.
+# Write a script to find the highest value obtained by XORing any two distinct members of the array.
+
+
+# Input: @array = (1,2,3,4,5,6,7)
+# Output: 7
+# The maximum result of 1 xor 6 = 7.
+
+# Input: @array = (2,4,1,3)
+# Output: 7
+# The maximum result of 4 xor 3 = 7.
+
+# Input: @array = (10,5,7,12,8)
+# Output: 15
+# The maximum result of 10 xor 5 = 15.
+
+maXor(1,2,3,4,5,6,7); # 7
+maXor(2,4,1,3); # 7
+maXor(10,5,7,12,8); # 15
+
+sub maXor(@array)
+{
+ my $max = 0;
+
+ foreach my $value (@array)
+ {
+ map{ $max = $_ ^ $value if(($_ ^ $value) > $max) } @array;
+
+ }
+
+ say $max;
+} \ No newline at end of file
diff --git a/challenge-205/tyler-wardhaugh/clojure/README.md b/challenge-205/tyler-wardhaugh/clojure/README.md
index 103893d9b9..b7d0abb1ee 100644
--- a/challenge-205/tyler-wardhaugh/clojure/README.md
+++ b/challenge-205/tyler-wardhaugh/clojure/README.md
@@ -1,6 +1,6 @@
-# c200
+# c205
-The Weekly Challenge — #200 — Tyler Wardhaugh
+The Weekly Challenge — #205 — Tyler Wardhaugh
## Usage
@@ -17,12 +17,12 @@ Run Task #1:
Run Task #2:
- $ clojure -M:t2 N
+ $ clojure -M:t2 COLL
# ... or ...
- $ bb run task-2 N
+ $ bb run task-2 COLL
# Alternatively, to run it via Babashka:
- $ bb run task-2-bb N
+ $ bb run task-2-bb COLL
Run the project's tests (which are samples from the task descriptions):
diff --git a/challenge-205/tyler-wardhaugh/clojure/bb.edn b/challenge-205/tyler-wardhaugh/clojure/bb.edn
index d7f9593e83..46c9cae858 100644
--- a/challenge-205/tyler-wardhaugh/clojure/bb.edn
+++ b/challenge-205/tyler-wardhaugh/clojure/bb.edn
@@ -1,6 +1,6 @@
{
:paths ["src" "resources"]
- :deps {c200/c200 {:local/root "."}}
+ :deps {c205/c205 {:local/root "."}}
:tasks
{
diff --git a/challenge-205/tyler-wardhaugh/clojure/build.clj b/challenge-205/tyler-wardhaugh/clojure/build.clj
new file mode 100644
index 0000000000..44d02594bf
--- /dev/null
+++ b/challenge-205/tyler-wardhaugh/clojure/build.clj
@@ -0,0 +1,19 @@
+(ns build
+ (:refer-clojure :exclude [test])
+ (:require [org.corfield.build :as bb]))
+
+(def lib 'net.clojars.c205/c205)
+(def version "0.1.0-SNAPSHOT")
+(def main 'c205.c205)
+
+(defn test "Run the tests." [opts]
+ (bb/run-tests opts))
+
+(def clean bb/clean)
+
+(defn ci "Run the CI pipeline of tests (and build the uberjar)." [opts]
+ (-> opts
+ (assoc :lib lib :version version :main main)
+ (bb/run-tests)
+ (bb/clean)
+ (bb/uber)))
diff --git a/challenge-205/tyler-wardhaugh/clojure/deps.edn b/challenge-205/tyler-wardhaugh/clojure/deps.edn
index bcf2a4462e..619d09fa32 100644
--- a/challenge-205/tyler-wardhaugh/clojure/deps.edn
+++ b/challenge-205/tyler-wardhaugh/clojure/deps.edn
@@ -1,8 +1,8 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}}
:aliases
- {:t1 {:main-opts ["-m" "c200.t1"]}
- :t2 {:main-opts ["-m" "c200.t2"]}
+ {:t1 {:main-opts ["-m" "c205.t1"]}
+ :t2 {:main-opts ["-m" "c205.t2"]}
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.8.3" :git/sha "7ac1f8d"
;; since we're building an app uberjar, we do not
diff --git a/challenge-205/tyler-wardhaugh/clojure/src/c205/t1.clj b/challenge-205/tyler-wardhaugh/clojure/src/c205/t1.clj
new file mode 100644
index 0000000000..b8d66b63f8
--- /dev/null
+++ b/challenge-205/tyler-wardhaugh/clojure/src/c205/t1.clj
@@ -0,0 +1,17 @@
+(ns c205.t1
+ (:require
+ [clojure.edn :as edn]))
+
+(def DEFAULT-INPUT [[5 4 3]])
+
+(defn third-highest
+ [coll]
+ (let [sorted (->> coll (into (sorted-set-by (comp - compare))) seq)]
+ (nth sorted 2 (first sorted))))
+
+(defn -main
+ "Run Task 1 with a given input COLL, defaulting to the first example from
+ the task description."
+ [& args]
+ (let [[coll] (or (some->> args (map edn/read-string)) DEFAULT-INPUT)]
+ (println (third-highest coll))))
diff --git a/challenge-205/tyler-wardhaugh/clojure/src/c205/t2.clj b/challenge-205/tyler-wardhaugh/clojure/src/c205/t2.clj
new file mode 100644
index 0000000000..6f245b6bab
--- /dev/null
+++ b/challenge-205/tyler-wardhaugh/clojure/src/c205/t2.clj
@@ -0,0 +1,20 @@
+(ns c205.t2
+ (:require
+ [clojure.edn :as edn]))
+
+(def DEFAULT-INPUT [[1 2 3 4 5 6 7]])
+
+(defn max-xor
+ [coll]
+ (let [uniq (set coll)
+ xors (for [x uniq
+ y (drop 1 uniq)]
+ (bit-xor x y))]
+ (apply max xors)))
+
+(defn -main
+ "Run Task 2 with a given input COLL, defaulting to the first
+ example from the task description."
+ [& args]
+ (let [[coll] (or (some->> args (map edn/read-string)) DEFAULT-INPUT)]
+ (println (max-xor coll))))
diff --git a/challenge-205/tyler-wardhaugh/clojure/test/c205/t1_test.clj b/challenge-205/tyler-wardhaugh/clojure/test/c205/t1_test.clj
new file mode 100644
index 0000000000..3ab163a73e
--- /dev/null
+++ b/challenge-205/tyler-wardhaugh/clojure/test/c205/t1_test.clj
@@ -0,0 +1,9 @@
+(ns c205.t1-test
+ (:require [clojure.test :refer [deftest is testing]]
+ [c205.t1 :refer [third-highest]]))
+
+(deftest task-1
+ (testing "Task 1 produces the correct results from examples in the description"
+ (is (= 3 (third-highest [5 3 4])))
+ (is (= 6 (third-highest [5 6])))
+ (is (= 3 (third-highest [5 4 4 3])))))
diff --git a/challenge-205/tyler-wardhaugh/clojure/test/c205/t2_test.clj b/challenge-205/tyler-wardhaugh/clojure/test/c205/t2_test.clj
new file mode 100644
index 0000000000..af2e00887b
--- /dev/null
+++ b/challenge-205/tyler-wardhaugh/clojure/test/c205/t2_test.clj
@@ -0,0 +1,8 @@
+(ns c205.t2-test
+ (:require [clojure.test :refer [deftest is testing]]
+ [c205.t2 :refer [max-xor]]))
+
+(deftest task-2
+ (testing "Task 2 produces the correct results from examples in the description"
+ (is (= 7 (max-xor [1 2 3 4 5 6 7])))
+ (is (= 15 (max-xor [10 5 7 12 8])))))
diff --git a/challenge-205/ulrich-rieke/cpp/ch-1.cpp b/challenge-205/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..6a05ec6425
--- /dev/null
+++ b/challenge-205/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+#include <vector>
+#include <cstdlib>
+#include <algorithm>
+
+int main( int argc, char* argv[] ) {
+ std::vector<int> numbers ;
+ for ( int i = 1 ; i < argc ; i++ )
+ numbers.push_back( std::atoi( argv[i] ) ) ;
+ auto last = std::unique( numbers.begin( ) , numbers.end( ) ) ;
+ numbers.erase( last, numbers.end( ) ) ;
+ std::sort( numbers.begin( ) , numbers.end( ) ) ;
+ if ( numbers.size( ) < 3 )
+ std::cout << numbers.back( ) ;
+ else
+ std::cout << numbers[ numbers.size( ) - 3 ] ;
+ std::cout << std::endl ;
+ return 0 ;
+}
diff --git a/challenge-205/ulrich-rieke/cpp/ch-2.cpp b/challenge-205/ulrich-rieke/cpp/ch-2.cpp
new file mode 100644
index 0000000000..636630de95
--- /dev/null
+++ b/challenge-205/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <cstdlib>
+#include <vector>
+
+int main( int argc , char * argv[] ) {
+ std::vector<int> numbers ;
+ for ( int i = 1 ; i < argc ; i++ ) {
+ numbers.push_back( std::atoi( argv[ i ] ) ) ;
+ }
+ int the_max = 0 ;
+ int sz = numbers.size( ) ;
+ for ( int i = 0 ; i < sz - 1 ; i++ ) {
+ for ( int j = i + 1 ; j < sz ; j++ ) {
+ if ( numbers[ i ] != numbers[ j ] ) {
+ int num = numbers[ i ] ^ numbers[ j ] ;
+ if ( num > the_max )
+ the_max = num ;
+ }
+ }
+ }
+ std::cout << the_max << std::endl ;
+}
diff --git a/challenge-205/ulrich-rieke/haskell/ch-1.hs b/challenge-205/ulrich-rieke/haskell/ch-1.hs
new file mode 100644
index 0000000000..b1514a975d
--- /dev/null
+++ b/challenge-205/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,14 @@
+module Challenge205
+ where
+import qualified Data.Set as S
+import Data.List ( sort )
+
+solution :: [Int] -> Int
+solution list
+ |length uniques < 3 = maximum uniques
+ |otherwise = head $ drop ( l - 3 ) $ sort uniques
+ where
+ uniques :: [Int]
+ uniques = S.toList $ S.fromList list
+ l :: Int
+ l = length uniques
diff --git a/challenge-205/ulrich-rieke/haskell/ch-2.hs b/challenge-205/ulrich-rieke/haskell/ch-2.hs
new file mode 100644
index 0000000000..f6fc96827e
--- /dev/null
+++ b/challenge-205/ulrich-rieke/haskell/ch-2.hs
@@ -0,0 +1,15 @@
+module Challenge205_2
+ where
+import Data.Bits ( xor )
+import qualified Data.Set as S
+import Data.List ( (!!) )
+
+solution :: [Int] -> Int
+solution list = maximum $ map (\p -> xor ( fst p ) ( snd p ) )
+[(noDoublets !! i, noDoublets !! j) | i <- [0..l - 2] ,
+j <- [i + 1 ..l - 1]]
+ where
+ noDoublets :: [Int]
+ noDoublets = S.toList $ S.fromList list
+ l :: Int
+ l = length noDoublets
diff --git a/challenge-205/ulrich-rieke/perl/ch-1.pl b/challenge-205/ulrich-rieke/perl/ch-1.pl
new file mode 100644
index 0000000000..668d73133b
--- /dev/null
+++ b/challenge-205/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+my %uniques ;
+map { $uniques{$_}++ } @ARGV ;
+my @unique = keys %uniques ;
+my @sorted = sort { $b <=> $a } @unique ;
+if ( scalar( @unique ) < 3 ) {
+ say $sorted[0] ;
+}
+else {
+ say $sorted[2] ;
+}
diff --git a/challenge-205/ulrich-rieke/perl/ch-2.pl b/challenge-205/ulrich-rieke/perl/ch-2.pl
new file mode 100644
index 0000000000..b139055ef7
--- /dev/null
+++ b/challenge-205/ulrich-rieke/perl/ch-2.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+my $size = scalar( @ARGV ) ;
+my $max = 0 ;
+for my $i ( 0 .. $size - 2 ) {
+ for my $j ( $i + 1 .. $size - 1 ) {
+ if ( $ARGV[ $i ] != $ARGV[ $j ] ) {
+ my $num = $ARGV[ $i ] ^ $ARGV[ $j ] ;
+ if ( $num > $max ) {
+ $max = $num ;
+ }
+ }
+ }
+}
+say $max ;
diff --git a/challenge-205/ulrich-rieke/raku/ch-1.raku b/challenge-205/ulrich-rieke/raku/ch-1.raku
new file mode 100644
index 0000000000..0040213648
--- /dev/null
+++ b/challenge-205/ulrich-rieke/raku/ch-1.raku
@@ -0,0 +1,13 @@
+use v6 ;
+
+say "Enter some numbers, separated by a blank!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+my @uniques = @numbers.unique ;
+if ( @uniques.elems < 3 ) {
+ say @uniques.max ;
+}
+else {
+ my @sorted = @uniques.sort( { $^b <=> $^a } ) ;
+ say @sorted[2] ;
+}
diff --git a/challenge-205/ulrich-rieke/rust/ch-1.rs b/challenge-205/ulrich-rieke/rust/ch-1.rs
new file mode 100644
index 0000000000..5705d65fe8
--- /dev/null
+++ b/challenge-205/ulrich-rieke/rust/ch-1.rs
@@ -0,0 +1,26 @@
+use std::io ;
+use std::collections::HashSet ;
+
+fn main() {
+ println!("Enter some integers separated by blanks");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ let numbers : Vec<i32> = entered_line.split_whitespace( ).
+ map( | s | s.trim( ).parse::<i32>( ).unwrap( )).collect( ) ;
+ let mut unique_numbers : HashSet<i32> = HashSet::new( ) ;
+ for n in numbers {
+ unique_numbers.insert( n ) ;
+ }
+ let mut uniques : Vec<i32> = Vec::new( ) ;
+ for n in unique_numbers {
+ uniques.push( n ) ;
+ }
+ uniques.sort_by( | a , b | b.cmp( a ) ) ;
+ if uniques.len( ) < 3 {
+ println!("{}" , uniques[0] ) ;
+ }
+ else {
+ println!("{}" , uniques[2] ) ;
+ }
+}
diff --git a/challenge-205/ulrich-rieke/rust/ch-2.rs b/challenge-205/ulrich-rieke/rust/ch-2.rs
new file mode 100644
index 0000000000..49d0d000d0
--- /dev/null
+++ b/challenge-205/ulrich-rieke/rust/ch-2.rs
@@ -0,0 +1,22 @@
+use std::io ;
+use itertools::Itertools ;
+
+fn main() {
+ println!("Print a number of integers, separated by blanks!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ let numbers : Vec<i32> = entered_line.split_whitespace( ).map(
+ | s | s.trim( ).parse::<i32>().unwrap( )).collect( ) ;
+ let mut the_max : i32 = 0 ;
+ let mut iter = numbers.into_iter( ).combinations( 2 ) ;
+ while let Some( v ) = iter.next( ) {
+ if v[0] != v[1] {
+ let val : i32 = v[0] ^ v[1] ;
+ if val > the_max {
+ the_max = val ;
+ }
+ }
+ }
+ println!("{}" , the_max) ;
+}