Skip to content

Instantly share code, notes, and snippets.

View duoduo3369's full-sized avatar

杨洋 duoduo3369

  • 山东科技大学
  • china
View GitHub Profile
@duoduo3369
duoduo3369 / gist:3257215
Created August 4, 2012 12:30
lambda python
"""
Factorial
Topic 11: Question 1
A function that calls itself is said to be recursive. The creation of recursive functions is a powerful technique to solve problem that can be broken down into smaller or simpler form. One common use is to find the factorial of a number. The factorial of a number N is simply the number multiplied by the factorial of (N-1). Complete the code given below to calculate and returns the factorial of a numeber.
Examples
>>> factorial(5)
120
>>> factorial(1)
1
>>> factorial(0)
@duoduo3369
duoduo3369 / insert_sort.py
Created August 4, 2012 12:25
insert sort
# -*- coding: utf8 -*-
def insert_sort(input_array):
""" asc ord
每次处理就是将无序数列的第一个元素与有序数列的元素从后往前逐个进行比较,找出插入位置,将该元素插入到有序数列的合适位置中。
"""
if isinstance(input_array,list) == False:
print 'Error: When you use insert_sort function, please make sure your argument is a list'
return None
for j in xrange(1,len(input_array)):