All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Bella's Fruitful Week (Posted on 2024-05-31) Difficulty: 3 of 5
In a week, Bella either eat a mango, a guava, or an apple each day. If she will not eat the same fruit for two consecutive days, and the fruit eaten on the 1st and the last day will not repeat, how many different ways are there for her to eat fruits?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Programmatic confirmation | Comment 2 of 4 |
I ran a program which brute force counted, confirming Brian Smith's answer of 126.

I checked integers from 0 to 3^7, converted to base 3 in text format, then applied the imposed conditions.

--------
count = 0
successes = []
for n in range((3**7):
    pattern = base2base(n,10,3).zfill(7)
    if pattern[0] == pattern[-1]:
        continue
    fail = False
    for index,char in enumerate(pattern):
        if index == 0:
            continue
        if char == pattern[index-1]:
            fail = True
            break
    if not fail:
        count += 1
        successes.append(pattern)

print(count)

  Posted by Larry on 2024-05-31 17:28:43
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information