+ Reply to Thread
Results 1 to 16 of 16

Lazy caterer's sequence

  1. #1
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Lazy caterer's sequence

    Hi all,

    I'm trying to reverse the lazy caterer's sequence to determine which level of a number is closest.
    1 1 1
    2 2 3
    3 4 7
    4 7 14
    5 11 25
    6 16 41
    7 22 63
    8 29 92
    9 37 129
    10 46 175
    56 231

    EG:
    175 is level 9 but what is the formula to return the number 9? (And yes the previous "cost" is required to get to that level (129 + 46 = 175))

    I'd love to be able to get this into a single formula without the need for numbers in other rows etc. But I'm not sure that's possible.

    The end goal is to have a number say 182 and return or tell us the MAXIMUM level you could get to. (9) And the remainder on a different cell. (not as important)

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Lazy caterer's sequence

    Assuming that your sequence is in columns A, B and C starting in row 1, and that you put the number 182 in cell E1, then you can use these formulae in the cells stated:

    F1: =MATCH(E1,C:C)-1

    to give you the level, and:

    G1: =E1-INDEX(C:C,F1+1)

    to give you the remainder.

    Incidentally, you have 11 missing from your final example line.

    Hope this helps.

    Pete

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Lazy caterer's sequence

    The "formula" you're looking for will need to solve a cubic equation and I don't think that's possible. With 0, 1, 2, 3, 4 ... in column A, put this in B1 and copy down:

    Please Login or Register  to view this content.
    That will give you your sequence. The first term is cubed so, to reverse it, you'll need to solve a cubic. You could use Solver or Goal Seek perhaps: https://www.exceldemy.com/solving-equations-in-excel/
    The other option is to use a lookup table or a VBA user-defined function.

    WBD
    Office 365 on Windows 11, looking for rep!

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Lazy caterer's sequence

    A simpler way of generating the sequence - put 1 in the cells A1:C1, then these formulae:

    A2: =A1+1

    B2: =A1+B1

    C2: =C1+B2

    then copy those 3 formulae down as far as you need.

    Hope this helps.

    Pete

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Lazy caterer's sequence

    Just spotted that you're on O365!!

    With the value (e.g. 182) in A1, put this in B1:

    Please Login or Register  to view this content.
    That will give you the highest value, the remainder, and the row number.

    WBD

  6. #6
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    Thanks everyone!

    =LET(s,SEQUENCE(41,,0,1),c,(s^3+3*s^2+8*s+6)/6,m,LOOKUP($A1,c),CHOOSE({1,2,3},m,$A1-m,MATCH(m,c,0)-1))

    Can you explain this so I can tweak it?

    I'd like to be able to control how quickly the sequence accelerates (instead of +1 it could be +2). And also how to display the results separately if so desired.
    Also how can I get excel to display the calculated sequence (after sequence + all the math).

    Thanks!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,218

    Re: Lazy caterer's sequence

    Do you need the thread I closed (now reopened), or can I close it again?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    Hi all,

    With the help of WideBoyDixon, PeteUK, and AI I've been able to figure most of it out.

    Simplified below is the version I'm currently working on, and will add the match function back later. For now this displays the list of terms from the lazy caterer's sequence (+1) then I am attempting to cumulatively add those together in a simplified way (avoiding complex math). However, currently this is displaying a #value result after calculating the indexes, and I cannot figure out what is going on there.

    =LET(a,SEQUENCE(10,1,0,1), b,((a^2+a+2)/2)+1, c,SEQUENCE(10,1,1,1), d,SUM(INDEX(b,1):INDEX(b,c,1)),d)

    Can someone please take a look and see where this is screwed up.

    The result should be (a spill):
    2 5 10 18 30 47 70 100 138 185

    Thanks!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,218

    Re: Lazy caterer's sequence

    I have now closed the other thread which was all to do with this one after all!

  10. #10
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    No AliGW, it has nothing to do with the lazy carterer's sequence. If you want to directly message me please do so instead of posting directly into the forums.

  11. #11
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    Hi all,

    With the help of WideBoyDixon, PeteUK, and AI I've been able to figure most of it out.

    Simplified below is the version I'm currently working on, and will add the match function back later. For now this displays the list of terms from the lazy caterer's sequence (+1) then I am attempting to cumulatively add those together in a simplified way (avoiding complex math). However, currently this is displaying a #value result after calculating the indexes, and I cannot figure out what is going on there.

    =LET(a,SEQUENCE(10,1,0,1), b,((a^2+a+2)/2)+1, c,SEQUENCE(10,1,1,1), d,SUM(INDEX(b,1):INDEX(b,c,1)),d)

    Can someone please take a look and see where this is screwed up?

    The result should be (a spill):
    2 5 10 18 30 47 70 100 138 185

    Thanks!

  12. #12
    Registered User
    Join Date
    06-02-2020
    Location
    Turkey
    MS-Off Ver
    365 TR - V.2309
    Posts
    97

    Re: Lazy caterer's sequence

    Hi,

    If I didn't misunderstand, please try..

    with SCAN - LAMBDA

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    or without LAMBDA (using MMULT)

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    Holy smokes dude! You nailed it on the first try!! WOW

    Can you explain how it works please? In case I need to adjust things.

  14. #14
    Registered User
    Join Date
    10-03-2022
    Location
    Oakville, Ontario
    MS-Off Ver
    365
    Posts
    38

    Re: Lazy caterer's sequence

    This is what an AI (Chat GPT) told me:

    "LET function: This function is used to define variables that will be used in subsequent calculations. It's a way to assign names to values or expressions.

    a: This variable is assigned the result of SEQUENCE(1, 10, 0, 1), which generates an array of 10 numbers starting from 0 and incrementing by 1. So, a will hold the values [0, 1, 2, ..., 9].
    b: This variable is assigned the result of the expression ((a^2 + a + 2) / 2) + 1, which calculates the corresponding values of the sequence described in your original post. This is essentially a mathematical expression to generate Sequence 1.

    SCAN function: This function is used to perform a cumulative operation on an array, applying a given function at each step. In this case, it's used for element-wise addition.
    SCAN(0, b, LAMBDA(x, y, x + y)): The SCAN function takes three arguments: an initial value (0 in this case), the array b, and a lambda function LAMBDA(x, y, x + y).

    LAMBDA(x, y, x + y): This is a lambda function that takes two arguments, x and y, and returns their sum (x + y). In this context, it's the element-wise addition operation.

    SCAN iterates over the array b, applying the lambda function to each element and accumulating the result. So, the result of SCAN will be an array where each element is the sum of all preceding elements in the array b.

    The result of the SCAN function is the final array of element-wise cumulative sums, which corresponds to the desired output.
    The formula uses these steps to generate the element-wise cumulative sum of Sequence 1 and outputs the correct result: 2, 5, 10, 18, 30, 47, 70, 100, 138, 185."


    Looking at the calculation steps in excel it literally shows #VALUE then suddenly calculates the correct result and works.

    In my own words, it seems like the scan is what is doing the iterative process of adding, and lambda is explaining what to do with the sequence array?

  15. #15
    Registered User
    Join Date
    06-02-2020
    Location
    Turkey
    MS-Off Ver
    365 TR - V.2309
    Posts
    97

    Re: Lazy caterer's sequence

    The comment is absolutely correct.
    Cumulative totals are obtained with the SCAN function.

  16. #16
    Registered User
    Join Date
    06-02-2020
    Location
    Turkey
    MS-Off Ver
    365 TR - V.2309
    Posts
    97

    Re: Lazy caterer's sequence

    If the series will repeat in columns the formula can be as in the picture

    Formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by 52779; 08-21-2023 at 03:12 PM.

+ 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. Find a short-sequence in a longer sequence (Clash Royale Chests Challenge)
    By GeneralDisarray in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-08-2016, 12:20 PM
  2. MsgBox is lazy or disobedient
    By Sidewinder72 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2015, 11:03 PM
  3. Replies: 7
    Last Post: 06-08-2015, 08:39 AM
  4. I'm lazy. There has to be a faster way to pull data & cross reference a worksheet, right?
    By colleendeborah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2013, 07:52 PM
  5. lazy gits
    By martindwilson in forum The Water Cooler
    Replies: 91
    Last Post: 02-11-2013, 05:35 AM
  6. Help With school problems Fixed cost, "the caterer", TSP
    By Dolphan36 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-11-2012, 03:05 PM
  7. [SOLVED] Simple question I'm too lazy to answer but still need some help on
    By Zerex71 in forum Excel General
    Replies: 3
    Last Post: 07-21-2006, 05:20 PM

Tags for this Thread

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