2018年5月21日
2017年4月25日
2017年4月5日
首个网站发布完毕!
第一个项目算是完成了,阴阳师悬赏任务查询,可以查4个任务怪的出现关卡,以及哪些关包括了两个以上的任务怪。
用的是Flask加亚马逊EC2,域名在Godaddy买的。
目前用的临时ip地址http://13.113.70.177 ,过两天yysdata.com就能解析成功了。
获益良多,哇哈哈哈。
下一步是继续做功能了。目前想到的功能如下:
式神定位(控速、控火、肉、控制、后手、输出)
式神常用御魂及出处
特效触发计算
用的是Flask加亚马逊EC2,域名在Godaddy买的。
目前用的临时ip地址http://13.113.70.177 ,过两天yysdata.com就能解析成功了。
获益良多,哇哈哈哈。
下一步是继续做功能了。目前想到的功能如下:
式神定位(控速、控火、肉、控制、后手、输出)
式神常用御魂及出处
特效触发计算
2017年1月4日
2016年12月27日
390. Elimination Game - I really didn't expect it working so perfect
最开始的时候,我写的代码是这样的:
nums = range(n, 0, -1)
while len(nums) > 1:
nums = nums[-2::-2]
毫无疑问,虽然答案对了,但是内存爆了。
于是搜了下其他人的答案,知道了思路是找左右点。然后有了下面的代码:
left, length ,step = 1, n, 1
right = left + (n - 1) * step
while length > 1:
left += step # Drop the first
step <<= 1
length >>= 1
right = left + (length - 1) * step # Get the right point.
left, right = right, left
step = ~step + 1
扔到PyCharm里调试,并和上面那个结果做Assert,居然完美通过,然后我就木凳狗带了——妈蛋我自己都只有个大概思路就撸了啊,没想到居然没什么错,这和我一贯以来20%的通过率不符啊……
nums = range(n, 0, -1)
while len(nums) > 1:
nums = nums[-2::-2]
毫无疑问,虽然答案对了,但是内存爆了。
于是搜了下其他人的答案,知道了思路是找左右点。然后有了下面的代码:
left, length ,step = 1, n, 1
right = left + (n - 1) * step
while length > 1:
left += step # Drop the first
step <<= 1
length >>= 1
right = left + (length - 1) * step # Get the right point.
left, right = right, left
step = ~step + 1
扔到PyCharm里调试,并和上面那个结果做Assert,居然完美通过,然后我就木凳狗带了——妈蛋我自己都只有个大概思路就撸了啊,没想到居然没什么错,这和我一贯以来20%的通过率不符啊……
2016年12月1日
312. Burst Balloons 继续趟pytho的坑……
这次被坑的是初始化二维数组……
[[0] * size] * size != [[0] * size for i in range(size)] == [[0 for i in range(size)] for i in range(size)]
然后读了读 http://ars.me/programming/2014/06/14/py-listmul/ 妥了……
[[0] * size] * size != [[0] * size for i in range(size)] == [[0 for i in range(size)] for i in range(size)]
然后读了读 http://ars.me/programming/2014/06/14/py-listmul/ 妥了……
2016年11月30日
花了差不多一下午补DP相关的东西,终于勉强做完了377. Combination Sum IV
在思路上绕了好久,最后还是没解决,忍不住去搜索了。然后发现是自己不擅长的DP,花了差不多整个下午,终于能勉强答题了。
class Solution(object):
def combinationSum4(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
dp = [1] + [0] * target
for i in range(target + 1):
for num in nums:
if i + num <= target:
dp[i + num] += dp[i]
return dp[target]
答完题回来看看,似乎确实不难啊……
class Solution(object):
def combinationSum4(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
dp = [1] + [0] * target
for i in range(target + 1):
for num in nums:
if i + num <= target:
dp[i + num] += dp[i]
return dp[target]
答完题回来看看,似乎确实不难啊……
2016年11月17日
378. Kth Smallest Element in a Sorted Matrix的附带收获
神之多重list展开:
matrix_expanded = [element for line in matrix for element in line]
这很Python,写了两个for循环的我给跪了……
matrix_expanded = [element for line in matrix for element in line]
这很Python,写了两个for循环的我给跪了……
2016年11月9日
406. Queue Reconstruction by Height 的Python解法
研究了好久算法,最后参考了别人的思路,才发现代码可以这么简单……
思路总结:
1. 预排序,h从大到小,k从小到大
2. 依次把每个元素插到新list的k位置
class Solution(object):
def reconstructQueue(self, people):
"""
:type people: List[List[int]]
:rtype: List[List[int]]
"""
result = []
people.sort(key = operator.itemgetter(1))
people.sort(key = operator.itemgetter(0), reverse = True)
for p in people:
result.insert(p[1], p)
return result
这样的思路实现起来,真的很简单啊!
思路总结:
1. 预排序,h从大到小,k从小到大
2. 依次把每个元素插到新list的k位置
class Solution(object):
def reconstructQueue(self, people):
"""
:type people: List[List[int]]
:rtype: List[List[int]]
"""
result = []
people.sort(key = operator.itemgetter(1))
people.sort(key = operator.itemgetter(0), reverse = True)
for p in people:
result.insert(p[1], p)
return result
这样的思路实现起来,真的很简单啊!
2016年5月18日
2016年4月28日
2016年4月23日
订阅:
博文 (Atom)