Results 1 to 2 of 2

Thread: Ordering Integers, Small -> Big + knowing length of streak

  1. #1

    Thread Starter
    New Member MuscleShark88's Avatar
    Join Date
    Feb 2010
    Posts
    12

    Ordering Integers, Small -> Big + knowing length of streak

    Hi everyone, first time posting here.

    I was wondering if someone could help me out w/ this little problem I'm having.

    card1
    card2
    card3
    card4
    card5
    card6
    card7

    are my integers and they range from 2 to 14 (yes, we're dealing w/ cards 2 -> Ace)

    what I would like to do is order them from smallest to largest and find out what the longest streak is.

    for example:

    With the 7 cards being: 2, 2, 3, 4, 7, 9, 13

    2, 3, 4 would be the longest streak, so the answer would be 3. I also need to know where the streak starts and where it ends. In this example, 2 is the start, 4 is the end.

    Thanks alot for your help!
    Last edited by MuscleShark88; Feb 9th, 2010 at 01:15 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Ordering Integers, Small -> Big + knowing length of streak

    Welcome to the forums.

    You will want a sorting algorithm. Here are several submitted by Ellis Dee.

    Regarding your streak, maybe a simple loop. Start at 2nd sorted card, and see if it is +1 from the previous. If so, keep checking and keep count. If another streak is found and is longer, keep that count and where it started. All this is done within a single For:Next loop.

    Edited: You don't need to keep track of the end of the streak. The end = streakStart + streakLen - 1
    Last edited by LaVolpe; Feb 9th, 2010 at 09:16 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width