Skip to content

Commit

Permalink
change something about practice project
Browse files Browse the repository at this point in the history
  • Loading branch information
qixiangyang committed Jul 5, 2019
1 parent e8a4f50 commit bc644e8
Show file tree
Hide file tree
Showing 110 changed files with 111 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .idea/learning_project.iml → .idea/Practice.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions Excellent_Cases/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Description:
Author:qxy
Date: 2019-07-05 17:43
File: __init__.py
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions Excellent_Cases/sogou_spider/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Description:
Author:qxy
Date: 2019-07-05 17:43
File: __init__.py
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test.py → Excellent_Cases/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sogou_spider.sgwc import search_officials
from Excellent_Cases.sogou_spider.sgwc import search_officials

officials = search_officials(keyword='阿尔法工场')

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@


def climbStairs(n: int) -> int:
pass
a, b = 1, 1
for _ in range(1, n-1):
a, b = a+b, a
return a


print(climbStairs(7))
File renamed without changes.
File renamed without changes.
File renamed without changes.
84 changes: 84 additions & 0 deletions Leetcode/_00746_min_cost_climbing_stairs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
Description:
Author:qxy
Date: 2019-07-04 14:07
File: 00746_min_cost_climbing_stairs
"""

"""
数组的每个索引做为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。
每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。
您需要找到达到楼层顶部的最低花费。在开始时,你可以选择从索引为 0 或 1 的元素作为初始阶梯。
示例 1:
输入: cost = [10, 15, 20]
输出: 15
解释: 最低花费是从cost[1]开始,然后走两步即可到阶梯顶,一共花费15。
 示例 2:
输入: cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
输出: 6
解释: 最低花费方式是从cost[0]开始,逐个经过那些1,跳过cost[3],一共花费6。
注意:
cost 的长度将会在 [2, 1000]。
每一个 cost[i] 将会是一个Integer类型,范围为 [0, 999]。
"""
from typing import List


def minCostClimbingStairs(cost: List[int]) -> int:

# val_list = []
# for start1 in range(2):
# start1_score = 0
# start1_score += cost[start1]
# while start1 < len(cost)-1:
# tmp = cost[start1+1: start1+3]
# print(tmp)
# print(start1_score)
# if len(tmp) > 1:
# if tmp[0] == tmp[1]:
# start1 += 2
# start1_score += tmp[1]
# else:
# min_cost = min(tmp)
# start1 += tmp.index(min_cost)+1
# start1_score += min_cost
# if len(tmp) == 1:
# start1 += 1
# # start1_score += tmp[0]
# if len(tmp) == 0:
# break
# val_list.append(start1_score)
# return min(val_list)

dp0, dp1 = cost[0], cost[1]

for i in range(2, len(cost)):
dpi = min(dp0 + cost[i], dp1 + cost[i])
dp0, dp1 = dp1, dpi

return min(dp0, dp1)

# start2 = 1
# start2_score = 0
# start2_score += cost[start2]
# while start2 < len(cost):
# tmp = cost[start2+1: start2+3]
# if len(tmp) == 0:
# break
# min_cost = min(tmp)
# start2 += tmp.index(min_cost)+1
# start2_score += min_cost
# # print(start2_score)
# return start1_score


# data = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
data = [0, 1, 2, 2]
n = minCostClimbingStairs(data)
print(n)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added Python/Fluent_Python/chapter2/floats.bin
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions leetcode/00131_palindrome_partitioning.py

This file was deleted.

8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### 值得反复学习的优秀项目或者代码

#### sougou_spider 搜狗微信爬虫,新的requests的使用方式、3.7的语法、高级的代码表达方式, lxml 新的解析函数
#### Algorithm 算法: 目前已完成常见排序算法
#### Data Structure 数据结构: 目前已完成链表,队列,接下来学习树
#### Excellent Cases: 优秀的项目学习 目前有一个sougou爬虫的例子
#### LeetCode: 刷题记录
#### Python: Python基础练习

#### LeetCode刷题,每天一个
Date:2019-07-05

0 comments on commit bc644e8

Please sign in to comment.