Jump to content
BrainDen.com - Brain Teasers

superprismatic

Moderator
  • Posts

    1267
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by superprismatic

  1. Find three witty English sentences

    which can be interleaved without

    overlap to produce the sequence


    NIIDNELOTEOINTYPHVINERGIISNCENTVEAVOFACURYEABSVERYETNHCUINGIEMSSCRAUPCKS
    [/code] Here is example solved problem of this type: Suppose the given string were
    [code]
    VIFAIDOOOREELILLIKSEENWHAACETFISUGITATDOGIHIELVAEFSROMTHPSTEELRAWPORFEETUAAVFUGELOLFTHYEONRTAHEIGESENWCRONGSIOMDPETEOFENT
    Then, then three such sentences producing this are

    VIOLENCEISTHELASTREFUGEOFTHEINCOMPETENT
    IFEELLIKEAFUGITIVEFROMTHELAWOFAVERAGES
    ADOORISWHATADOGISPERPETUALLYONTHEWRONGSIDEOF
    [/code] The interleaving is:
    [code]
    V I O L E N CE IS T H EL A ST R E FUGE O FTH EI N C OM PET ENT
    IF EE LLIK E A F UGIT I V EF ROMTH EL AW O F A V E R A GES
    A DO OR I S WH A T A DOGI S P E R P ETU A L L Y ON T H E W RONGSI D EOF
    VIFAIDOOOREELILLIKSEENWHAACETFISUGITATDOGIHIELVAEFSROMTHPSTEELRAWPORFEETUAAVFUGELOLFTHYEONRTAHEIGESENWCRONGSIOMDPETEOFENT

  2. Interleave the three strings


    FOGIEMYONSNSASIASOGEHNONNSEFSWINKHKSN
    FORGVEMMNASLOFGIETHNOSESEFTHEWHHNTEYTLSENS
    RGIEMENNENSESFORGVEHENOEOHOEHOTHIEYAKSEE
    [/code] so that they may overlap only at letters they have in common and together they form a witty English sentence. This sentence also has the shortest possible length of any string made by overlapped interleaving of this kind. Here is example solved problem of this type: Suppose that the three strings were
    [code]
    SSNOAITAYINUITISLSRAVOHEKINDOPEMEUZZLEI
    SIOTWTTSBUTITSILUATIVEFEHEKIPBLMTHUZLES
    THIIAWITTYSYGUTTISLLSTTFETHEKIOFPROEMHPUZLE
    Each of these can be stretched out over 70 positions so that each of the 70 positions is covered by a letter from at least one of the three. Furthermore, letters at positions of overlap must agree:

    S SNO A I T AYIN U ITIS L S RA V O HEKINDO P EM E UZZLEI
    SI OT W TT S BUTIT SI LU ATIVE FE HEKI P BL MTH U ZLE S
    THI I AWITTYS Y G UT TIS LL ST T FETHEKI OFPRO EM H PUZ LE
    THISISNOTAWITTYSAYINGBUTITISILLUSTRATIVEOFETHEKINDOFPROBLEMTHEPUZZLEIS
    [/code]

    This 70-long string, although not unique, is as

    short as possible while fulfilling the requirements

    of the problem (with the exception of wit).

  3. M O T M MN E E I T E A E O E N A N U

    H WOC O MNT S N W O L R YD G SI

    TE TSO L E H R D H R DT P I D T Y

    HMTEWOCTSOMLMNTESEHINTWERODAHELOREYDTGPSINDATNYU

    IT MESSESD IT UP A BIT BUT IF YOU COPPY AND PASTE IT IN A TXT. DOC. IT'LL EVEN OUT A BIT. :(

    You found a 48-long string. That's pretty good, but you can do better!

  4. I don't know any of the C's :blush:

    I tried Java compilation, I got the error:

    ----------

    1. ERROR in jan1.java (at line 1)

    public class Leapyear

    ^^^^^^^^

    The public type Leapyear must be defined in its own file

    ----------

    1 problem (1 error)

  5. Interleave the three 19-long strings


    MOTMMNEEITEAEOENANU
    HWOCOMNTSNWOLRYDGSI
    TETSOLEHRDHRDTPIDTY
    [/code] so that they may overlap only at letters they have in common and together they form the shortest possible string (not necessarily an English sentence). Here is example solved problem of this type: Suppose that the three strings were
    [code]
    HEGOOMOASUTYPOATHII
    EISPLLIHTOPRLMTHTSS
    RADEXAEFOTONTOEEFBE
    Each of these can be stretched out over 45 positions so that each of the 45 positions is covered by a letter from at least one of the three. Furthermore, letters at positions of overlap must agree:

    HE GO O MOASUTYPO A T HII
    EISPLL IH TO PRLM T HTSS
    RADE XA EF OTON T OEEFB E

    RADEISPLLXAIHEFGOTONPRLMOASUTYPOEEFBAHTSSHIIE
    [/code]

    This 45-long string, although not unique, is as

    short as possible while fulfilling the requirements

    of the problem.

  6. Interleave the three 19-long strings


    MOTMMNEEITEAEOENANU
    HWOCOMNTSNWOLRYDGSI
    TETSOLEHRDHRDTPIDTY
    [/code] so that they don't overlap and together they form a 57-long string which is a good English sentence with the spaces collapsed out. Here is example solved problem of this type: Suppose that the three strings were
    [code]
    HEGOOMOASUTYPOATHII
    EISPLLIHTOPRLMTHTSS
    RADEXAEFOTONTOEEFBE
    Each of these can be stretched out over 57 positions so that they do not overlap and each of the 57 positions is used by at least one of them this way:

    HE GOO M O AS U T YP O A THI I
    EIS PL L I H T O PR L MTH T S S
    R A DEXA E F O T ONTO E E F B E

    HEREISAGOODEXAMPLEOFASOLUTIONTOTHETYPEOFPROBLEMTHATTHISIS
    [/code]

  7. yes, it was meant for those who thought that the number of Saturdays and Sundays were the same

    By the way, I couldn't compile your program. I got the following error:

    jan1.c:1: error: expected unqualified-id before ‘public’

    With a different C compiler, I got this error:

    jan1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘class’

    I don't program in C or C++, so I don't know what the problem is.

    Can you help?

  8. It's a simple code (Gregorian calendar starts 15 October 1581, so the first January 1 is in 1582, and it's a Friday.)

    Saturdays: 60

    Sundays: 62

    Run it for yourself


    {
    // 0 = saturday, 1 = sunday, 2 = monday, 3 = tuesday, 4 = wednesday, 5 = thursday, 6 = friday
    public static void main()
    {
    int sat = 0, sun = 0;
    for (int year = 1582, day = 6; year <= 2009; year++) {
    if (day == 0) {sat++;}
    if (day == 1) {sun++;}
    if (isLeapYear(year)) {day += 2;}
    else {day++;}
    day %= 7;
    }
    System.out.println("Saturdays: " + sat + "\nSundays: " + sun);
    }

    public static boolean isLeapYear(int year)
    {
    boolean leap = false;
    if (year % 4 == 0) {leap = true;}
    if (year % 100 == 0 && year % 400 != 0) {leap = false;}
    return leap;
    }

    }

    // Outputs:
    // Saturdays: 60
    // Sundays: 62
    public class Leapyear

    When your program is run on ANY 400 year period, say from 1582 to 1981, it always gets 58 Sundays and 56 Saturdays.

  9. Let's start with the year 2000 when New Years was on a Saturday.

    Let 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday,

    and 6=Saturday. I have written the New Years day numbers on a width

    of 28. The year 2000 is a leap year but 2100, 2200, and 2300 are not.

    Other years divisible by 4 are leap years. Here's the table:


    New Year day numbers Years Comments
    6123460124560234501235601345 2000-2027 2000 is a leap year
    6123460124560234501235601345 2028-2055
    6123460124560234501235601345 2056-2083
    6123460124560234560124560234 2084-2111 in 2100 it's a 5 (Friday) and not a leap year
    5012356013456123460124560234 2112-2139
    5012356013456123460124560234 2140-2167
    5012356013456123460124560234 2168-2195
    5012345602345012356013456123 2196-2223 in 2200 it's a 3 (Wednesday) and not a leap year
    4601245602345012356013456123 2224-2251
    4601245602345012356013456123 2252-2279
    4601245602345012356012345012 2280-2307 in 2300 it's a 1 (Monday) and not a leap year
    3560134561234601245602345012 2308-2335
    3560134561234601245602345012 2336-2363
    3560134561234601245602345012 2364-2391
    35601345 2392-2399
    612346..... 2400-etc. in 2400 it's a 6 (Saturday) and a leap year
    and things are as they were in 2000, so another
    400-year cycle begins.

    If you count the occurance of each digit you find

    0 (Sunday) occurs 58 times

    1 (Monday) occurs 56 times

    2 (Tuesday) occurs 58 times

    3 (Wednesday) occurs 57 times

    4 (Thursday) occurs 57 times

    5 (Friday) occurs 58 times

    6 (Saturday) occurs 56 times

  10. New years day moves forward one day every year in a normal year.

    Every 4th year one day misses its chance to be new years day.

    Starting with Saturday as new years day in year 0 the first year to miss will be Wednesday in year 4, then Monday in year 8 and Saturday in year 12, Thursday in year 16, Tuesday in year 20, Sunday in year 24, Friday in year 28 and then we are back to Wednesday in year 32.

    Thus the pattern repeats over 28 years (32 – 4)

    Now let’s consider what happens in year 400 (when we miss a leap year);

    L 393 394 395 L 397 398 399 400 401 402 403 L 405 406 407 L 409 410 411 L

    Sat Su M Tu * Th F Sa Su M Tu W Th * Sa Su M Tu * Th F Sa Su * Tu

    413 414 415 L 417 418 419 L

    W Th F * Su M Tu W * F

    (sorry folks, try as I might I cant get these to line up properly in the text window)

    Clearly in the 28 year cycle containing the 400th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 392 and then multiples of 28 after that will be Fridays from years 420 to 784 etc as shown below;

    1 – 392 = Sat 400 reset a day earlier

    420 – 784 = Fri 800 reset a day earlier

    812 – 1176 = Th 1200 reset a day earlier

    1204 - 1596 = Wed 1600 reset a day earlier

    1624 to 1988 = Tues 2000 reset a day earlier

    2016 to 2380 = Mon 2400 reset a day earlier

    2408 to 2772 – Sun 2800 Reset a day earlier

    2800 to 2828 - Sat

    So that pattern repeats every 2800 years

    In essence, the answer is that without a time frame the question cannot be answered

    Steve

    But 400 is a leap year. (sorry, I forgot to put this in my previous post)

  11. New years day moves forward one day every year in a normal year.

    Every 4th year one day misses its chance to be new years day.

    Starting with Saturday as new years day in year 0 the first year to miss will be Wednesday in year 4, then Monday in year 8 and Saturday in year 12, Thursday in year 16, Tuesday in year 20, Sunday in year 24, Friday in year 28 and then we are back to Wednesday in year 32.

    Thus the pattern repeats over 28 years (32 – 4)

    Now let’s consider what happens in year 400 (when we miss a leap year);

    L 393 394 395 L 397 398 399 400 401 402 403 L 405 406 407 L 409 410 411 L

    Sat Su M Tu * Th F Sa Su M Tu W Th * Sa Su M Tu * Th F Sa Su * Tu

    413 414 415 L 417 418 419 L

    W Th F * Su M Tu W * F

    (sorry folks, try as I might I cant get these to line up properly in the text window)

    Clearly in the 28 year cycle containing the 400th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 392 and then multiples of 28 after that will be Fridays from years 420 to 784 etc as shown below;

    1 – 392 = Sat 400 reset a day earlier

    420 – 784 = Fri 800 reset a day earlier

    812 – 1176 = Th 1200 reset a day earlier

    1204 - 1596 = Wed 1600 reset a day earlier

    1624 to 1988 = Tues 2000 reset a day earlier

    2016 to 2380 = Mon 2400 reset a day earlier

    2408 to 2772 – Sun 2800 Reset a day earlier

    2800 to 2828 - Sat

    So that pattern repeats every 2800 years

    In essence, the answer is that without a time frame the question cannot be answered

    Steve

    You forgot to take into account that years 100, 200, and 300 are not leap years.

  12. I completely disagree with you and believe that the chances are equal? Your formula is flawed by only looking at 400 years. You should instead look at a multiple of 28 since the pattern will repeat every 28 years due to leap years (7 days a week * 4 years to a leap year). So the breakdown would be New Year's falling on:

    SU

    M

    T

    W

    F

    SA

    SU

    M

    W

    TH

    F

    SA

    M

    T

    W

    TH

    SA

    SU

    M

    T

    TH

    F

    SA

    SU

    T

    W

    TH

    F

    Year 29 would repeat the pattern of year 1. If you count the days New Year will fall out on in a 28 year period, it is completely even between every day of the week. So if you were to look at 420 years instead of 400 the results should be completely even.

    The rule for leap year is: Y is a leap year if and only if Y is a multiple of 4 AND if it's a multiple of 100, then it must also be a multiple of 400. So, the year 2000 was a leap year, but the year 1900 was not. That 400 in the rule means that the leap year cycle is 400 years long.

  13. The Gregorian calendar cycles through all possible

    yearly calendars in 400 years. You can see this

    because the number of days in 400 years is

    (3*365+366)*100-3 which is 146,097, a multiple

    of 7. In 400 years, New Years Day is on a

    Sunday 58 times and on a Saturday 56 times.

    So, the answer to the OP is Sunday.

  14. Tuckleton is correct.

    The 26th digit from the left is 7.

    All those ones are just successive powers of 12 which can be taken mod 19 as you compute them. They all add up to 12 mod 19. The digit in the 26th place from the left is in the 1224 place. Well 1224=1 mod 19, so the digit we are looking for is 7 because 12(representing all the ones)+7*1(value of the 26th place from left)=0 mod 19.

  15. JMust realized an error in my previous post and too late to change it.

    Corrections in RED:

    As for the below

    The numbers of IDs should be 12^4/12*4 = 432

    Are you sure you're not counting similar IDs more than once? More than 3 times even?

    Yes, I am sure. I checked all pairs of the 1344 and they all differ by at least 2. I tried to attach the file but it just sat there spinning a wheel -- nothing was uploaded. I tried the basic uploader, but I couldn't figure out how to use it -- there was no mention of uploading when I tried to use it.

×
×
  • Create New...