Pēteris Caune
 
[Most Recent Entries] [Calendar View] [Friends View]

Friday, April 21st, 2006

    Time Event
    4:22a
    Riekstiņš

    Lūk, jums, jauks cietais rieksts! Kādu uzdevumu risina šī python programmiņa?

    
        from operator import mul
    
        def modder(x):
            i = 0
            while x:
                i += 1
                (x, remainder) = divmod(x, 2)
                if remainder: yield i
    
        for i in xrange(1, 2 ** 9):
            set1 = set(modder(i))
            set2 = set(range(1,10)) - set1
    
            if sum(set1) == reduce(mul, list(set2), 1): 
                print str(set1)
                print str(set2)
                break
    
    
    

    << Previous Day 2006/04/21
    [Calendar]
    Next Day >>

Paviānu štelles   About Sviesta Ciba