some function magic
Function Magic some
2023-06-13 09:12:08 时间
# encoding: utf-8
"""
Create on: 2018-08-24 上午1:32
author: sato
mail: ysudqfs@163.com
life is short, you need python
"""
# def insert_sort(array):
# # 从第二个开始循环
# for i in range(1, len(array)):
# # 认为他是最小的
# min = array[i]
# j = i - 1
# while j >= 0 and array[j] > min:
# array[j+1] = array[j]
# print(array)
#
# j -= 1
# array[j+1] = min
# print(array)
# return array
def bucketSort(nums):
# 选择一个最大的数
max_num = max(nums)
# 创建一个元素全是 0 的列表, 当做桶
bucket = [0] * (max_num + 1)
# print(bucket)
# 把所有元素放入桶中, 即把对应元素个数加一
for i in nums:
bucket[i] += 1
# print(nums)
# print(bucket)
# 存储排序好的元素
sort_nums = []
# 取出桶中的元素
for j in range(len(bucket)):
if bucket[j] != 0:
for y in range(bucket[j]):
print(bucket[j])
sort_nums.append(j)
return sort_nums
# bucketSort(nums)
# if __name__ == "__main__":
# import random
#
# # array = [i for i in range(1, 11)]
# # random.shuffle(array)
# array = [1,5,6,8,4]
# print("排序前:", array)
# # new_array = insert_sort(array)
# new_array = bucketSort(array)
# print("排序后:", new_array)
def toStr(n, base):
convertString = "0123456789" + "".join([chr(i) for i in range(65, 91)]) + "".join([chr(i) for i in range(97, 123)])
if n < base:
return convertString[n]
else:
return toStr(n // base, base) + convertString[n % base]
# print(toStr(600, 62))
def jumpFloor(number):
# write code here
tempArray = [1, 2]
if number >= 3:
for i in range(3, number + 1):
tempArray[(i + 1) % 2] = tempArray[0] + tempArray[1]
return tempArray[(number + 1) % 2]
print(jumpFloor(20))
# fibonacci
(((1 + 根号5 )/2)^n - ((1 - 根号5)/2)^n)/根号5
相关文章
- go的数据类型-其他数据类型-function(二)
- SAP SD 客户主数据里的Partner Function的一个奇怪现象
- ORA-26747: The one-to-many transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-30129: invalid function argument received ORACLE 报错 故障修复 远程处理
- ORA-30557: function based index could not be properly maintained ORACLE 报错 故障修复 远程处理
- ORA-31600: invalid input value string for parameter string in function string ORACLE 报错 故障修复 远程处理
- ORA-31610: cannot call this function from a non-master process ORACLE 报错 故障修复 远程处理
- MySQL Error number: 3758; Symbol: ER_FUNCTIONAL_INDEX_FUNCTION_IS_NOT_ALLOWED; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-64126: XMLIndex Table Function: failure at the start of the function ORACLE 报错 故障修复 远程处理
- ORA-64128: XMLIndex Table Function: failure during the function evaluation ORACLE 报错 故障修复 远程处理
- PostgreSQL 22016: invalid_argument_for_nth_value_function 报错 故障修复 远程处理
- Scalaz(7)- typeclass:Applicative-idomatic function application详解编程语言
- js提交表单错误:document.form.submit() is not a function详解编程语言
- Function eregi is deprecated (解决方法)详解编程语言
- functionMySQL ABS Function: the Solution to Mathematics Problems.(mysqlabs)
- Oracle 视图 V$IOSTAT_FUNCTION 官方解释,作用,如何使用详细说明
- PHP Fatal error: Uncaught Error: Call to undefined function pcntl_fork().. 开启php pcntl扩展实现多进程详解编程语言
- Exploring the Power of Oracle LEAST Function in Database Management(oracleleast)
- vbs(asp)下的Function语句
- greenbrower用到的function.js代码集合
- ASP去掉字符串头尾连续回车和空格的Function