Click here to Skip to main content
15,892,005 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: Coding puzzle Pin
PIEBALDconsult25-May-16 13:56
mvePIEBALDconsult25-May-16 13:56 
AnswerRe: Coding puzzle Pin
ImHere2Learn25-May-16 18:49
professionalImHere2Learn25-May-16 18:49 
AnswerRe: Coding puzzle Pin
Staffan Bruun25-May-16 19:48
professionalStaffan Bruun25-May-16 19:48 
AnswerRe: Coding puzzle Pin
Staffan Bruun25-May-16 20:31
professionalStaffan Bruun25-May-16 20:31 
GeneralRe: Coding puzzle Pin
Mycroft Holmes25-May-16 22:11
professionalMycroft Holmes25-May-16 22:11 
GeneralRe: Coding puzzle Pin
Staffan Bruun25-May-16 22:33
professionalStaffan Bruun25-May-16 22:33 
AnswerRe: Coding puzzle Pin
Kenneth Haugland25-May-16 21:45
mvaKenneth Haugland25-May-16 21:45 
AnswerRe: Coding puzzle Pin
Anthony Mushrow25-May-16 23:14
professionalAnthony Mushrow25-May-16 23:14 
You could also use the GetRange function on the list to do the actual work of making the sub lists, and then you don't need to keep track of so many things.

C#
List<List<int>> GetSubLists(List<int> lstInput)
{
    List<List<int>> lstSubLists = new List<List<int>>();

    if (lstInput.Count == 0)
        return lstSubLists;

    int subListStartIndex = 0;
    for (int i = 1; i < lstInput.Count; ++i)
    {
        if (lstInput[i] - lstInput[i-1] != 1)
        {
            lstSubLists.Add(lstInput.GetRange(subListStartIndex, i - subListStartIndex));
            subListStartIndex = i;
        }
    }

    lstSubLists.Add(lstInput.GetRange(subListStartIndex, lstInput.Count - subListStartIndex));

    return lstSubLists;
}

GeneralRe: Coding puzzle Pin
virang_2126-May-16 13:01
virang_2126-May-16 13:01 
AnswerRe: Coding puzzle Pin
BillWoodruff25-May-16 23:48
professionalBillWoodruff25-May-16 23:48 
GeneralRe: Coding puzzle Pin
virang_2126-May-16 12:59
virang_2126-May-16 12:59 
AnswerRe: Coding puzzle Pin
Eytukan26-May-16 0:23
Eytukan26-May-16 0:23 
JokeRe: Coding puzzle Pin
Staffan Bruun26-May-16 3:10
professionalStaffan Bruun26-May-16 3:10 
AnswerRe: Coding puzzle Pin
PIEBALDconsult26-May-16 17:29
mvePIEBALDconsult26-May-16 17:29 
GeneralSalesForce Pin
Marc Clifton25-May-16 12:56
mvaMarc Clifton25-May-16 12:56 
GeneralRe: SalesForce Pin
Mark_Wallace25-May-16 13:16
Mark_Wallace25-May-16 13:16 
GeneralRe: SalesForce Pin
Marc Clifton25-May-16 13:23
mvaMarc Clifton25-May-16 13:23 
GeneralRe: SalesForce Pin
Mycroft Holmes25-May-16 14:25
professionalMycroft Holmes25-May-16 14:25 
GeneralRe: SalesForce Pin
Slacker00726-May-16 2:08
professionalSlacker00726-May-16 2:08 
GeneralAny ideas which app is free and best for running youtube and list in the background continuously Pin
indian14325-May-16 11:39
indian14325-May-16 11:39 
GeneralRe: Any ideas which app is free and best for running youtube and list in the background continuously Pin
Mark_Wallace25-May-16 12:06
Mark_Wallace25-May-16 12:06 
AnswerRe: Any ideas which app is free and best for running youtube and list in the background continuously Pin
Sumuj John25-May-16 12:39
professionalSumuj John25-May-16 12:39 
GeneralRe: Any ideas which app is free and best for running youtube and list in the background continuously Pin
ZurdoDev26-May-16 1:05
professionalZurdoDev26-May-16 1:05 
GeneralUSA official visit Pin
Suvabrata Roy25-May-16 11:14
professionalSuvabrata Roy25-May-16 11:14 
GeneralRe: USA official visit Pin
Slacker00725-May-16 11:54
professionalSlacker00725-May-16 11:54 

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.