Aunt Bobbie, The Mighty Flyers

Hello on this Tuesday afternoon. I trust everyone is doing well. This past weekend we had a nice memorial service for my dear Aunt Bobbie. She passed away peacefully on Saturday the 6th. She meant so much to so many people. She was my favorite Aunt. Every time I saw here she always welcomed me and gave me a big hug and a kiss. Every time I saw my dad, he would say “Auntie Bobbie said to tell Greg hi!” She was always thinking about those around her and genuinely cared about others. As a Christian we have the assurance that we will see her again someday in heaven. Aunt Bobbie we thank you for all the great life memories we will always share.

If all goes well, I should be starting a new job on Monday the 22nd. I was hired by the home based worker department of Sykes. I am already familiar with this company, they had a call center in Greeley several years ago. I will be doing customer support for Fantasy Football customers on Yahoo.com. I have three weeks of paid training and then will work up to 39 hours a week based on need. I’ve been really studying all the rules and details, I signed up for play this year and named my team “The Mighty Flyers”. There will be 10 teams in my league, each team has 15 players, 9 of those players will be starters and 6 will be the bench. The team consists of 1 quarterback, 3 wide receivers, 2 running backs, 1 tight end, 1 kicker, 1 defense and special team. In the head-to-head play, I will be going against another team each week of the real NFL season. During that week, however well my players do in real life will determine how well I will do with my Fantasy Football team. If my quarterback gets 2 touchdowns, and my running backs get 3 touchdowns, I will receive points. For example if I draft Arian Foster – a running back from Houston Texans, and he gets 2 touchdowns this weekend in his real life game, then I will get 6 points for each of those touchdowns. So my Fantasy team will consist of the best players from different NFL teams. I am really looking forward to the coming season, both in real life and in the Fantasy Football leagues – Go Broncos!

Until next time – Have a great day.

Greg

Advertisements

Stack Exchange review

Hello on Thursday afternoon. I just got in from a bike ride and am feeling refreshed. There was not much going on outside, other than the milder temperatures. We have been having an August monsoon here in Colorado. Warm days with clouds and thunderstorms in the evenings, the rain showers have been nice.

I have recently discovered some very helpful new websites. Stack Exchange is one of the flagship sites. Here is their description: “Stack Exchange is a fast-growing network of 58 question and answer sites on diverse topics from software programming to cooking to photography and gaming.” One of my favorites is Stack Overflow – “Q&A for professional and enthusiast programmers.” I’ve found many helpful python programming hints on this site. You can ask a question about any programming topic and the professionals will answer it, or doing a Google search – many of the results will most likely include Stack Exchange pages that have a similar question/answers that have already been asked and answered. They just launched a bicycle question answer site yesterday. If you run into a problem when repairing or maintaining your bicycle, this would be a great place to go for help. I am really impressed with the design of these sites. They are easy to read, there is no information overload, they are ascetically pleasing and most of all they are helpful. Keep up the good work gentlemen. Right now I am listening to Podcast # 13 of your weekly Stack Exchange pod casts.

Project Euler – Problem # 74 – Solved with Python

Problem:

The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145:

1! + 4! + 5! = 1 + 24 + 120 = 145

Perhaps less well known is 169, in that it produces the longest chain of numbers that link back to 169; it turns out that there are only three such loops that exist:

  • 169 → 363601 → 1454 → 169
  • 871 → 45361 → 871
  • 872 → 45362 → 872

It is not difficult to prove that EVERY starting number will eventually get stuck in a loop. For example,

  • 69 → 363600 → 1454 → 169 → 363601 (→ 1454)
  • 78 → 45360 → 871 → 45361 (→ 871)
  • 540 → 145 (→ 145)

Starting with 69 produces a chain of five non-repeating terms, but the longest non-repeating chain with a starting number below one million is sixty terms.

How many chains, with a starting number below one million, contain exactly sixty non-repeating terms?

**********

This solution does not meet the one minute requirement, it does return the right answer. (Took about 5 minutes on my computer.)

This is just a brute force approach to solving this problem. Since we know that all the factorials will be 0 – 9, we create a dictionary of the first 10 factorials, put the chain into a list, and count the number of lists that are 60 elements in length. I am still looking for ways to speed up this program, maybe using a set for the chain???

# Python version = 2.7.2
# Platform = win32

import math
import time

def factorials_dict():
    """Create a dictionary of factorials 0 - 9"""
    d = {}
    for i in xrange(0, 10):
        d[i] = math.factorial(i)
    return d

def main():
    """Main Program"""
    start_time = time.clock()
    longest_chain = 0
    number_of_chains = 0
    factorials = factorials_dict()
    for number in xrange(66, 1000001):
        counter = 1
        switch = 1
        chain_element = number
        chainList = [number]
        while switch == 1:
            chain_element = str(chain_element)
            sum_factorials = 0
            for integer in chain_element:
                sum_factorials = factorials[int(integer)] + sum_factorials
            chain_element = sum_factorials
            if chain_element not in chainList:
                chainList.append(chain_element)
                counter += 1
            else:
                switch = 0
        if counter > longest_chain:
            number_of_chains = 1
            longest_chain = counter
        elif counter == longest_chain:
            number_of_chains += 1
        else:
            continue
    print "longest_chain = ", longest_chain
    print "number_of_chains = ", number_of_chains
    run_time = time.clock() - start_time
    print "Run time = ", run_time
            
if __name__ == '__main__':
    main()