Thread: Puzzle!!!

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    38

    Puzzle!!!

    Hi all got a puzzle for you!

    Find the next two lines of the following sequence:

    11
    21
    12-11
    11-12-21
    31-22-11
    13-11-22-21
    11-13-21-32-11
    ...
    ...

  2. #2
    I like code Rouss's Avatar
    Join Date
    Apr 2004
    Posts
    131
    They had something like this on the Google test and the python challenge...

    11
    21
    12-11
    11-12-21
    31-22-11
    13-11-22-21
    11-13-21-32-11


    31-13-12-11-13-12-21

    13-21-13-11-13-31-13-11-22-11

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    38
    Nice one :P

  4. #4
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291
    I don't get it
    Staying away from General.

  5. #5
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Say the code out loud and notice how what you say relates to the code before it.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    i still don't get it

  7. #7
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    I finally get it!
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  8. #8
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    TELL ME

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    If you're having trouble with this, I'll white out a hint for you all.

    Read out the numbers one digit at a time:

    11
    21
    12-11
    11-12-21
    31-22-11
    13-11-22-21
    11-13-21-32-11

    One One
    Two One
    One Two One One
    One One One Two Two One
    Three One Two Two One One
    One Three One One Two Two Two One
    One One One Three Two One Three Two One One

    Now compare each string to the previous line and look for a connection.


    ...and also if you're looking at Rouss' solution and not seeing a connection, note that he was slightly off. It should be:

    11
    21
    12-11
    11-12-21
    31-22-11
    13-11-22-21
    11-13-21-32-11

    31-13-12-11-13-12-21

    13-21-13-11-12-31-13-11-22-11
    Last edited by SlyMaelstrom; 12-24-2005 at 02:10 AM.
    Sent from my iPadŽ

  10. #10
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    I Still Don't Get It. Ive Been Reading It Over For Half An Hour

  11. #11
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Want more math? If you think that the sequence is "non-mathematical", I derived this mathematical expression that gives the sequence... have fun! (D is a recursive function and t is the term number.) It's a lot easier if you think verbally, isn't it?

    By the way, % here is a certain non-integer remainder function. 2.1%0.1 would be 0, 2.1%0.2 would be 0.1, 2.1%0.3 would be 0 since 0.3 fits evenly into 2.1, etc.) If you really want conventional operators, you could define % with limits and modular arithmetic...

    D(t+1) = (sigma(K=1,LOG(D(t)*10)-LOG(D(t)*10)%1,((D(t)-D(t)%10^(LOG(D(t))-
    LOG(D(t))%1)+sigma(S=1,LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,LOG(D(t)*10)
    -LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*
    10%10^R)%10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*
    10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)
    %10^(S-1))%10^S+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)
    *10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(
    sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10
    ^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^S+.5)*2*(D(t)
    -D(t)%10^(S-1))%10^S))-(D(t)-D(t)%10^(LOG(D(t))-LOG(D(t))%1)+sigma(S=1,
    LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)
    *10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)
    -(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%
    10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^S+1)%(((
    sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%
    10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*
    10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*
    10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^S+.5)*2*(D(t)-D(t)%10^(S
    -1))%10^S))%10^(K-1))%10^K/10^(K-1)*100^(2*sigma(N=1,K,(((D(t)-D(t)%
    10^(LOG(D(t))-LOG(D(t))%1)+sigma(S=1,LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,
    LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-
    (D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*
    10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%
    10^(R+1)))/10)%10^(S-1))%10^S+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%
    1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%
    10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)
    *10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))
    %10^S+.5)*2*(D(t)-D(t)%10^(S-1))%10^S))-(D(t)-D(t)%10^(LOG(D(t))-LOG(D(t))
    %1)+sigma(S=1,LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)
    %1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^
    (R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%
    10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^
    S+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^
    (R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(sigma(R=1,
    LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/
    10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^S+.5)*2*(D(t)-D(t)%
    10^(S-1))%10^S))%10^(N-1))%10^N+1)%(((D(t)-D(t)%10^(LOG(D(t))-LOG(D(t))%
    1)+sigma(S=1,LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*
    10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^
    R)%10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-
    D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^
    (S-1))%10^S+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-
    D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-
    (sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%
    10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(S-1))%10^S+.5)*2*
    (D(t)-D(t)%10^(S-1))%10^S))-(D(t)-D(t)%10^(LOG(D(t))-LOG(D(t))%1)+
    sigma(S=1,LOG(D(t))-LOG(D(t))%1,(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10
    )%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^
    R)%10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*
    10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/
    10)%10^(S-1))%10^S+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,
    ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%
    10^(R+1)))/10)-(sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*
    10-D(t)*10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))
    /10)%10^(S-1))%10^S+.5)*2*(D(t)-D(t)%10^(S-1))%10^S))%10^(N-1))%10^
    N+.5))))/100)+(sigma(K=1,LOG(D(t)*10)-LOG(D(t)*10)%1,100^(1+sigma(N=
    1,K-1,2*((((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*
    10%10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(
    sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%
    10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(N-1))%10^N/10^(N-
    1)+1)%(((sigma(R=1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%
    10^(R+1))%10^(R+2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)-(sigma(R=
    1,LOG(D(t)*10)-LOG(D(t)*10)%1-1,ABS((D(t)*10-D(t)*10%10^(R+1))%10^(R+
    2)/10-(D(t)*10-D(t)*10%10^R)%10^(R+1)))/10)%10^(N-1))%10^N/10^(N-1)+
    .5)))))/10)
    Erm, they say this gives you the pattern
    Last edited by SirCrono6; 12-24-2005 at 04:41 PM.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, thanks for the crystal clear code.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267

  14. #14
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Quote Originally Posted by h_howee
    11

    There are 2 1's here so we then write:

    21

    There is 1 2 followed by 1 1 so we write:

    12-11

    There is 1 1 followed by 1 2 followed by 2 1's so we write:

    11-12-21

    And so on and so on...
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  15. #15
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Nearly identical (well, same idea) to an ACM problem for this year's competition.

    http://acm.fit.edu/icpc/ser2005/problems/K_number.pdf
    {RTFM, KISS}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The puzzle again...Swapping elements of 2D array
    By crazygopedder in forum C Programming
    Replies: 44
    Last Post: 11-05-2008, 01:53 PM
  2. Replies: 12
    Last Post: 06-06-2008, 05:26 PM
  3. Crossword Puzzle Program
    By Loctan in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2006, 11:08 PM
  4. Solution to Google Puzzle 3,3,8,8=24
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-01-2006, 09:12 AM