Click here to Skip to main content
14,490,767 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: L33t CSS skills Pin
RickZeeland5-Nov-19 9:49
mveRickZeeland5-Nov-19 9:49 
GeneralRe: L33t CSS skills Pin
Sander Rossel5-Nov-19 20:37
professionalSander Rossel5-Nov-19 20:37 
GeneralRe: L33t CSS skills Pin
Richard Deeming5-Nov-19 10:28
mveRichard Deeming5-Nov-19 10:28 
GeneralRe: L33t CSS skills Pin
Sander Rossel5-Nov-19 20:28
professionalSander Rossel5-Nov-19 20:28 
GeneralRe: L33t CSS skills Pin
Richard Deeming6-Nov-19 7:26
mveRichard Deeming6-Nov-19 7:26 
GeneralRe: L33t CSS skills Pin
Sander Rossel6-Nov-19 10:09
professionalSander Rossel6-Nov-19 10:09 
GeneralRe: L33t CSS skills Pin
XTAL2565-Nov-19 18:12
MemberXTAL2565-Nov-19 18:12 
GeneralProgramming Quiz PinPopular
Marc Clifton5-Nov-19 6:48
mvaMarc Clifton5-Nov-19 6:48 
OK, reformatted to protect the guilty.

Write a function in your favorite language to create a "day view" in an array for a month, like 11/2019. So for that month/year, the array should look like this, where the day numbers not in the month are null or undefined:
                          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
My solution in C#, which uses an extension method:
int?[] days = new int?[6 * 7];
var dow = (int)new DateTime(2019, 11, 1).DayOfWeek;
Enumerable.Range(1, DateTime.DaysInMonth(2019, 11)).ForEachWithIndex((idx, n) => days[dow + idx] = n);
And the output function:
days.ForEachWithIndex((idx, n) => Console.Write(((idx % 7 == 0) ? "\r\n" : "") + (n?.ToString()?.PadLeft(5) ?? "     ")));
Which of course generates a leading CRLF, but oh well, that wasn't specifically indicated not to do so in the spec. Laugh | :laugh:

For the curious, this came up in a conversation with a coworker.


modified 5-Nov-19 14:41pm.

JokeRe: Programming Quiz Pin
RossMW5-Nov-19 7:30
professionalRossMW5-Nov-19 7:30 
GeneralRe: Programming Quiz Pin
Marc Clifton5-Nov-19 8:41
mvaMarc Clifton5-Nov-19 8:41 
GeneralRe: Programming Quiz Pin
0x01AA5-Nov-19 7:36
professional0x01AA5-Nov-19 7:36 
GeneralRe: Programming Quiz Pin
Marc Clifton5-Nov-19 8:39
mvaMarc Clifton5-Nov-19 8:39 
GeneralRe: Programming Quiz Pin
Richard Deeming5-Nov-19 8:10
mveRichard Deeming5-Nov-19 8:10 
GeneralRe: Programming Quiz Pin
W Balboos, GHB5-Nov-19 8:37
mveW Balboos, GHB5-Nov-19 8:37 
GeneralRe: Programming Quiz Pin
F Margueirat7-Nov-19 5:07
MemberF Margueirat7-Nov-19 5:07 
GeneralRe: Programming Quiz Pin
W Balboos, GHB8-Nov-19 3:08
mveW Balboos, GHB8-Nov-19 3:08 
GeneralRe: Programming Quiz Pin
Marc Clifton5-Nov-19 8:40
mvaMarc Clifton5-Nov-19 8:40 
GeneralRe: Programming Quiz Pin
Richard Deeming5-Nov-19 8:50
mveRichard Deeming5-Nov-19 8:50 
GeneralRe: Programming Quiz Pin
Member 128503227-Nov-19 3:00
MemberMember 128503227-Nov-19 3:00 
GeneralRe: Programming Quiz Pin
AFell25-Nov-19 12:41
MemberAFell25-Nov-19 12:41 
GeneralRe: Programming Quiz Pin
BillWoodruff5-Nov-19 21:22
mveBillWoodruff5-Nov-19 21:22 
GeneralRe: Programming Quiz Pin
Richard Deeming6-Nov-19 7:20
mveRichard Deeming6-Nov-19 7:20 
GeneralRe: Programming Quiz Pin
Member 110054785-Nov-19 21:20
MemberMember 110054785-Nov-19 21:20 
GeneralRe: Programming Quiz Pin
ZurdoDev6-Nov-19 1:02
mveZurdoDev6-Nov-19 1:02 
GeneralRe: Programming Quiz Pin
Jörgen Andersson6-Nov-19 2:04
professionalJörgen Andersson6-Nov-19 2:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.