aboutsummaryrefslogtreecommitdiff
path: root/challenge-178/duncan-c-white/README
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-178/duncan-c-white/README')
-rw-r--r--challenge-178/duncan-c-white/README67
1 files changed, 39 insertions, 28 deletions
diff --git a/challenge-178/duncan-c-white/README b/challenge-178/duncan-c-white/README
index 500870a343..00a9b78b5a 100644
--- a/challenge-178/duncan-c-white/README
+++ b/challenge-178/duncan-c-white/README
@@ -1,46 +1,57 @@
-Task 1: Permuted Multiples
+Task 1: Quater-imaginary Base
-Write a script to find the smallest positive integer x such that x, 2x,
-3x, 4x, 5x and 6x are permuted multiples of each other.
+Write a script to convert a given number (base 10) to quater-imaginary
+base number and vice-versa. For more informations, please checkout
+the wiki page: https://en.wikipedia.org/wiki/Quater-imaginary_base
-For example, the integers 125874 and 251748 are permutated multiples of
-each other as
-
-251784 = 2 x 125874
-
-and also both have the same digits but in different order.
-
-Output
+For example,
- 142857
+$number_base_10 = 4
+$number_quater_imaginary_base = 10300
-MY NOTES: ok, sounds pretty easy. Compare permutation either by forming
-bags of digits and comparing them, or simply by sorting the digits
-numerically (a signature) and comparing signatures.
+MY NOTES: seriously? base -2i, and for task 1? what was Knuth smoking
+in 1960? First, we have to define "number" more carefully. I'm going to
+choose "positive integer", because that reduces the problem from base -2i
+to base -4 with zeroes between every pair of digits, and that's already
+much too horrible for a "task 1".
GUEST LANGUAGE: As a bonus, I also had a go at translating ch-1.pl
into C (look in the C directory for that).
-Task 2: Reversible Numbers
+Task 2: Business Date
-Write a script to find out all Reversible Numbers below 100.
+You are given $timestamp (date with time) and $duration in hours.
-A number is said to be a reversible if sum of the number and its reverse
-had only odd digits.
+Write a script to find the time that occurs $duration business hours
+after $timestamp. For the sake of this task, let us assume the working
+hours is 9am to 6pm, Monday to Friday. Please ignore timezone too.
For example,
-36 is reversible number as 36 + 63 = 99 i.e. all digits are odd.
-17 is not reversible as 17 + 71 = 88, none of the digits are odd.
+Suppose the given timestamp is 2022-08-01 10:30 and the duration is 4 hours:
+then the next business date would be 2022-08-01 14:30.
-Output
+Similar if the given timestamp is 2022-08-01 17:00 and the duration
+is 3.5 hours, then the next business date would be 2022-08-02 11:30.
-10, 12, 14, 16, 18, 21, 23, 25, 27,
-30, 32, 34, 36, 41, 43, 45, 50, 52,
-54, 61, 63, 70, 72, 81, 90
+MY NOTES: ok, at least this is more straightforward. We sort of "wrap
+around" from date D, time 18:00 to date D+1 time 09:00 (when D is
+Mon..Thur), and similarly wrap around from Friday 18:00 to the following
+Monday 09:00..
-MY NOTES: Unusually, this seems even easier than task 1.
+My first version (ch-2.pl) shows how to cheat using Date::Manip, which
+already has a concept of business days which does of the work.
-GUEST LANGUAGE: As a bonus, I also had a go at translating ch-2.pl
-into C (look in the C directory for that).
+My second version (ch-2a.pl) shows an alternative where we do most of the
+work ourselves, needing only routines to:
+ - parse a calendar date and time, and
+ - move to the next calendar date, and
+ - determine which day of the week (Mon..Sun, 1..7) a date is
+ - break a date down into (year, month, day, hour, minutes)
+
+GUEST LANGUAGE: obviously ch-2.pl could only be translated into C
+by translating all the built-in business day logic of Date::Manip
+to C as well. But, having effectively done all that in the Perl
+universe in ch-2a.pl, I then had a go at translating ch-2a.pl into C
+(look in the C directory for that)