Viral Math Puzzles


#1

If one’s brain is wired for this sort of thing, it jumps right out at you. With the learning and practice fresh in one’s mind, the code pattern emerges almost immediately.

>>> a = list(range(1,9))
>>> b = list(range(min(a) + 3, max(a) + 4))
>>> print (sum(a + b))
96
>>> 

Stuff like this is the coolest thing to design code around.


#2
>>> def one_four_series(b):
	a = list(range(1, b + 1))
	b = list(range(min(a) + 3, max(a) + 4))
	return sum(a + b)

>>> one_four_series(8)
96
>>> one_four_series(80)
6720
>>> one_four_series(800)
643200
>>> 
>>> def one_four_term(n):
    for a in range(1, n + 1):
        if one_four_series(a) == n:
            return a

        
>>> one_four_term(96)
8
>>> one_four_term(6720)
80
>>> 

#3

Sent from my BlackBerry 10 smartphone.