Click here to Skip to main content
15,889,116 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
GeneralRe: Microsoft makes Notepad a separate Store app starting with new Windows 10 20H1 test build Pin
David O'Neil19-Aug-19 11:32
professionalDavid O'Neil19-Aug-19 11:32 
News14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
abmv18-Aug-19 5:43
professionalabmv18-Aug-19 5:43 
GeneralRe: 14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
Sander Rossel18-Aug-19 9:03
professionalSander Rossel18-Aug-19 9:03 
GeneralRe: 14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
raddevus18-Aug-19 9:44
mvaraddevus18-Aug-19 9:44 
GeneralRe: 14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
Sander Rossel18-Aug-19 10:06
professionalSander Rossel18-Aug-19 10:06 
GeneralRe: 14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
Eddy Vluggen19-Aug-19 12:57
professionalEddy Vluggen19-Aug-19 12:57 
GeneralRe: 14-Year-Old Makes $2.2 Million Running Her Own Candy Empire Pin
Mark_Wallace18-Aug-19 18:19
Mark_Wallace18-Aug-19 18:19 
NewsInteresting Coding Problem Pin
#realJSOP18-Aug-19 3:51
mve#realJSOP18-Aug-19 3:51 
How Should Schools Grade Unexpected-But-Correct Answers On Coding Tests? - Slashdot[^]

I solved this back in the early 80's using Turbo Pascal. Back then, the solution wasn't "unexpected", because we didn't have convenient framework methods available to us that actually did the math. Here's my approach, converted to C# from that ancient Pascal code (yes, I still have source code from the 80's on my box).

C#
static int CountLeapYears2(int minYear, int maxYear)
{
    // do the basic math up here so we don't clutter the final expression
    int years   = (maxYear - minYear);

    // A leap year is evenly divisible by 4, and those that are divisible by 100 AND 400. 
    // This is why I use 0.03 to find the number of periods to subtract from the number 
    // of years being evaluated.
    int periods = (int)(years * 0.03);

    int count   = (int)((years - (years * 0.03)) * 0.25);
    return count;
}


It should be noted that iterating from the minimum DateTime value to the maximum DateTime value with the C# DateTime.IsLeapYear() takes a measurable amount of time (for me, it was 0.0068359 seconds), while my almost 40-year old method did not produce a measurable duration at all. In the ineterst of completeness, here's my iterative method:

C#
static int CountLeapYears1(int minYear, int maxYear)
{
    int count = 0;
    for (int i = minYear; i <= maxYear; i++)
    {
        if (DateTime.IsLeapYear(i))
        {
            count++;
        }
    }
    return count;
}

".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

GeneralRe: Interesting Coding Problem Pin
Nelek18-Aug-19 5:26
protectorNelek18-Aug-19 5:26 
GeneralRe: Interesting Coding Problem Pin
#realJSOP18-Aug-19 5:36
mve#realJSOP18-Aug-19 5:36 
GeneralRe: Interesting Coding Problem Pin
Nelek18-Aug-19 5:48
protectorNelek18-Aug-19 5:48 
GeneralRe: Interesting Coding Problem Pin
Richard Deeming19-Aug-19 9:23
mveRichard Deeming19-Aug-19 9:23 
Newsthe rise and fall of Tumblr Pin
BillWoodruff18-Aug-19 0:00
professionalBillWoodruff18-Aug-19 0:00 
GeneralRe: the rise and fall oof Tumblr Pin
RickZeeland18-Aug-19 0:25
mveRickZeeland18-Aug-19 0:25 
GeneralRe: the rise and fall of Tumblr Pin
Mike Hankey18-Aug-19 4:09
mveMike Hankey18-Aug-19 4:09 
GeneralRe: the rise and fall of Tumblr Pin
Nelek18-Aug-19 4:42
protectorNelek18-Aug-19 4:42 
GeneralGreat Big Story - Cracking the Code of Cicada 3301 - Webseries Pin
abmv16-Aug-19 0:58
professionalabmv16-Aug-19 0:58 
NewsWhen Jupiter was young, a massive planet likely slammed into it Pin
Kent Sharkey15-Aug-19 15:16
staffKent Sharkey15-Aug-19 15:16 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
#realJSOP16-Aug-19 0:48
mve#realJSOP16-Aug-19 0:48 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
Daniel Pfeffer16-Aug-19 1:38
professionalDaniel Pfeffer16-Aug-19 1:38 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
#realJSOP16-Aug-19 2:28
mve#realJSOP16-Aug-19 2:28 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
Sander Rossel18-Aug-19 2:29
professionalSander Rossel18-Aug-19 2:29 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
Daniel Pfeffer18-Aug-19 2:39
professionalDaniel Pfeffer18-Aug-19 2:39 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
Sander Rossel18-Aug-19 2:59
professionalSander Rossel18-Aug-19 2:59 
GeneralRe: When Jupiter was young, a massive planet likely slammed into it Pin
Nelek18-Aug-19 5:22
protectorNelek18-Aug-19 5:22 

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.