Coding Challenges - Dlang or Generic

H. S. Teoh hsteoh at qfbox.info
Tue Jan 10 01:22:33 UTC 2023


On Tue, Jan 10, 2023 at 12:17:18AM +0000, Paul via Digitalmars-d-learn wrote:
> Greetings Dlang-ers
> I was wondering if anyone knew of any coding challenges available
> where the input and output are specified and its left to the
> programmer to find a solution?

Here's a challenge.  Given an input year, for example, "2023", write a
program that outputs (for the corresponding year):

--------------------------------snip---------------------------------
                              2023
       January              February                March        
 Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
  1  2  3  4  5  6  7            1  2  3  4            1  2  3  4
  8  9 10 11 12 13 14   5  6  7  8  9 10 11   5  6  7  8  9 10 11
 15 16 17 18 19 20 21  12 13 14 15 16 17 18  12 13 14 15 16 17 18
 22 23 24 25 26 27 28  19 20 21 22 23 24 25  19 20 21 22 23 24 25
 29 30 31              26 27 28              26 27 28 29 30 31   

        April                  May                  June         
 Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                    1      1  2  3  4  5  6               1  2  3
  2  3  4  5  6  7  8   7  8  9 10 11 12 13   4  5  6  7  8  9 10
  9 10 11 12 13 14 15  14 15 16 17 18 19 20  11 12 13 14 15 16 17
 16 17 18 19 20 21 22  21 22 23 24 25 26 27  18 19 20 21 22 23 24
 23 24 25 26 27 28 29  28 29 30 31           25 26 27 28 29 30   
 30                                                              

        July                 August               September      
 Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                    1         1  2  3  4  5                  1  2
  2  3  4  5  6  7  8   6  7  8  9 10 11 12   3  4  5  6  7  8  9
  9 10 11 12 13 14 15  13 14 15 16 17 18 19  10 11 12 13 14 15 16
 16 17 18 19 20 21 22  20 21 22 23 24 25 26  17 18 19 20 21 22 23
 23 24 25 26 27 28 29  27 28 29 30 31        24 25 26 27 28 29 30
 30 31                                                           

       October              November              December       
 Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
  1  2  3  4  5  6  7            1  2  3  4                  1  2
  8  9 10 11 12 13 14   5  6  7  8  9 10 11   3  4  5  6  7  8  9
 15 16 17 18 19 20 21  12 13 14 15 16 17 18  10 11 12 13 14 15 16
 22 23 24 25 26 27 28  19 20 21 22 23 24 25  17 18 19 20 21 22 23
 29 30 31              26 27 28 29 30        24 25 26 27 28 29 30
                                             31                  
--------------------------------snip---------------------------------

Code will be graded on readability, unittest coverage, and reusability
(how many functions have wide applicability outside of this challenge).

;-)


T

-- 
A mathematician learns more and more about less and less, until he knows everything about nothing; whereas a philospher learns less and less about more and more, until he knows nothing about everything.


More information about the Digitalmars-d-learn mailing list