+ Reply to Thread
Results 1 to 7 of 7

Recognizing a pattern of 0's

  1. #1
    Registered User
    Join Date
    10-13-2016
    Location
    ND, USA
    MS-Off Ver
    Standard 2010
    Posts
    2

    Recognizing a pattern of 0's

    I am working on a simulation problem for a class. I am simulating a simple game where you flip a coin 10 times, Heads = 0, Tails = 1. To win the game, I need to flip 4 heads (0's) in a row. How can I get Excel to recognize four 0's in a row? I can generate the random numbers (=RANDBETWEEN(0,1)) but I can't figure out the right formula to generate a True (win) or False (lose) output. An example would be:
    0 1 0 1 0 1 0 1 0 1 = Loss
    1 1 0 1 0 1 0 0 0 0 = Win

    I think I could do it using IF/AND functions but I think it would get pretty complicated doing it that way.
    Last edited by gryanb; 10-14-2016 at 12:21 PM.

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Recognizing a pattern of 0's

    If your 1,s and 0's are in the same cell,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Frob first, tweak later

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,812

    Re: Recognizing a pattern of 0's

    I would probably try a =COUNTIF() function in a helper row. If random numbers are in A1:J1
    A2=COUNTIF(A1:D1,0) and copy across. Note the relative references.
    M2=(COUNTIF(A2:J2,4)>0) M2 returns TRUE for win and FALSE for loss.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Recognizing a pattern of 0's

    Have you tried FREQUENCY comparing 0s with non-0s?

    Starting with something like this:

    =FREQUENCY(IF(A1:J1=0,COLUMN(A:J)),IF(A1:J1<>0,COLUMN(A:J)))
    Dave

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Recognizing a pattern of 0's

    Try this ...

    =IF(SUMPRODUCT(--(A1:G1&B1:H1&C1:I1&D1:J1="0000")),"Win","Loss")
    Last edited by Phuocam; 10-13-2016 at 11:10 PM.

  6. #6
    Registered User
    Join Date
    10-13-2016
    Location
    ND, USA
    MS-Off Ver
    Standard 2010
    Posts
    2

    Re: Recognizing a pattern of 0's

    - Neil - I have to repeat the simulation 10,000 times and I am not aware of a way to produce multiple 0's and 1's in a single cell. If I was doing a few manually, it would work out great but not quite in this situation. I do appreciate your input though!

    - MrShorty - your way worked out pretty well for me. It made the spreadsheet pretty big, but it produces the output that I need it to so I'll consider it a success!

    I appreciate all the quick responses I got from everyone! Thanks!

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Recognizing a pattern of 0's

    A follow up afterthought.

    Try array entering this. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Continuing a pattern on autofil without pattern re-starting
    By jakeyoung111 in forum Excel General
    Replies: 4
    Last Post: 06-22-2016, 11:11 AM
  2. Excel autofill not recognizing increment pattern.
    By s.hill in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-23-2015, 12:42 PM
  3. [SOLVED] Lookup and return rows based on pattern start and pattern end
    By JDI in forum Excel General
    Replies: 18
    Last Post: 11-16-2014, 11:44 PM
  4. [SOLVED] Autofill Issues- recognizing pattern
    By ryanaskren in forum Excel General
    Replies: 3
    Last Post: 08-28-2014, 09:45 AM
  5. [SOLVED] Autofill not recognizing pattern
    By WILLPOU in forum Excel General
    Replies: 4
    Last Post: 11-05-2013, 11:24 PM
  6. pattern recognizing in excel for a large data set
    By maulik1k in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 10-09-2013, 10:27 PM
  7. Replies: 4
    Last Post: 06-09-2010, 11:54 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1