diff --git a/.gitignore b/.gitignore index 894a44c..bde1962 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,5 @@ venv.bak/ # mypy .mypy_cache/ + +pictures/ diff --git a/Basic/algorithm/bubble_sort.py b/Basic/algorithm/bubble_sort.py new file mode 100644 index 0000000..01db74c --- /dev/null +++ b/Basic/algorithm/bubble_sort.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +class Solution: + + def bubble_sort(self, nums): + for i in range(1, len(nums)): + for j in range(0, len(nums) - i): + if nums[j] > nums[j + 1]: + nums[j], nums[j + 1] = nums[j + 1], nums[j] + + return nums + + +s = Solution() +lst = s.bubble_sort([2, 3, 1, 4, 5, 9, 8]) +print(lst) diff --git a/BeautifulSoup4/getstart.py b/BeautifulSoup4/getstart.py new file mode 100644 index 0000000..a03e328 --- /dev/null +++ b/BeautifulSoup4/getstart.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# BeautifulSoup 4.6.3 起步 + +html_doc = """ + + + The Dormouse's story + + +

The Dormouse's story

+

Once upon a time there were three little sisters;and their names were

+ Elsie, +Lacie and +Tillie; +and they lived at the bottom of a well.

+ + +""" + +from bs4 import BeautifulSoup + +soup = BeautifulSoup(html_doc, 'html.parser') + +print(soup.title) # The Dormouse's story +print(soup.title.name) # u'title' +print(soup.title.string) # The Dormouse's story +print(soup.title.parent.name) # u'head' +print(soup.p) #

The Dormouse's story

+print(soup.p['class']) # ['title'] +print(soup.a) # Elsie +# [Elsie, Lacie, Tillie] +print(soup.find_all('a')) +print(soup.find(id="link1")) # Elsie +print(soup.prettify()) + + +# 从文档中找到所有标签的链接 +for link in soup.find_all('a'): + print(link.get('href')) + +# 从文档中获取所有文字内容 +print(soup.get_text()) \ No newline at end of file diff --git a/BeautifulSoup4/grabImg.py b/BeautifulSoup4/grabImg.py new file mode 100644 index 0000000..315db94 --- /dev/null +++ b/BeautifulSoup4/grabImg.py @@ -0,0 +1,42 @@ +import requests +from bs4 import BeautifulSoup +import os + +baseurl = "https://tieba.baidu.com/p/5461479002" +index = 1 + + +def getpics(url): + global index + r = requests.get(url) + soup = BeautifulSoup(r.text, "lxml") + pagenum = soup.find("li", class_="l_reply_num").find_all("span", class_="red")[1].text + pics = soup.find_all("img", class_="BDE_Image") + for pic in pics: + # print(pic['src']) + savepics(pic['src'], index) + print("picture " + str(index) + " saved") + index = index + 1 + + +def savepics(url, name): + if os.path.exists('pictures/picture' + str(name) + '.jpg'): + return + if not os.path.exists('pictures'): + os.mkdir("pictures") + else: + piccontent = requests.get(url).content + with open('pictures/picture' + str(name) + '.jpg', 'wb') as f: + f.write(piccontent) + + +if __name__ == '__main__': + r = requests.get(baseurl) + soup = BeautifulSoup(r.text, "lxml") + pagenum = soup.find("li", class_="l_reply_num").find_all("span", class_="red")[1].text + for i in range(1, int(pagenum) + 1): + if (i == 1): + url = baseurl + else: + url = baseurl + "?pn=" + str(i) + getpics(url) diff --git a/BeautifulSoup4/howToUseTag.py b/BeautifulSoup4/howToUseTag.py new file mode 100644 index 0000000..219deed --- /dev/null +++ b/BeautifulSoup4/howToUseTag.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +from bs4 import BeautifulSoup + +html_doc = """ + + + Extremely bold + + +""" +soup = BeautifulSoup(html_doc, "lxml") + +# 对象的种类归纳为:Tag,NavigableString,BeautifulSoup,Comment +tag = soup.b +print(type(tag)) +print(tag) +# 每个tag都有自己的名字,通过.name来获取 +print(tag.name) +tag.name = "blockquote" +print(tag) + +# Attributes +print(type(tag['class'])) # +print(tag['class']) # ['boldest] +print(tag.attrs) # {'class':['boldest']} + +# tag的属性可以被添加,删除或修改 +tag['class'] = 'verybold' +tag['id'] = 'verybold' + +del tag['class'] +del tag['id'] +print(tag) +print(tag.get('class')) + +css_soup = BeautifulSoup('

', "lxml") +print(css_soup.p['class']) # ['body', 'strikeout'] +css_soup1 = BeautifulSoup('

', 'lxml') +print(css_soup1.p['class']) # ['body'] + +# 如果某个属性看起来好像有多个值,但在任何版本的HTML定义中都没有被定义为多值属性,那么Beautiful Soup会将这个属性作为字符串返回 +id_soup = BeautifulSoup('

', 'lxml') +print(id_soup.p['id']) # my id + +# 将tag转换成字符串时,多值属性将会合并成一个值 +rel_soup = BeautifulSoup('

Back to the homepage

', 'lxml') +print(rel_soup.a['rel']) +rel_soup.a['rel'] = ['index', 'contents'] +print(rel_soup.p) + +# 如果转换的文档是XML格式,那么tag中不包含多值属性 +xml_soup = BeautifulSoup('

', 'xml') +print(xml_soup.p['class']) \ No newline at end of file diff --git a/Numpy/numpy_dtype.py b/Numpy/numpy_dtype.py new file mode 100644 index 0000000..5ef4641 --- /dev/null +++ b/Numpy/numpy_dtype.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +import numpy as np + +# 使用标量类型 +dt = np.dtype(np.int32) +# print(dt) + +# int8, int16, int32, int64四种数据类型可以使用字符串'i1','i2','i4','i8'代替 +dt = np.dtype('i4') +# print(dt) + +# 字节顺序标注 +dt = np.dtype('>i4') +# print(dt) + +# 首先创建结构化数据类型 +dt = np.dtype([('age', np.int8)]) +# print(dt) [('age', 'i1')] + +dt = np.dtype([('age', np.int8)]) +a = np.array([(10,), (20,), (30,)], dtype=dt) +# print(a) + +# 类型字段名可以用于存取实际的age列 +dt = np.dtype([('age', np.int8)]) +a = np.array([(10,), (20,), (30,)], dtype=dt) +# print(a['age']) + +student = np.dtype([('name', 'S20'), ('age', 'i1'), ('marks', 'f4')]) +# print(student) + +student = np.dtype([('name', 'S20'), ('age', 'i1'), ('marks', 'f4')]) +a = np.array([('abc', 21, 50), ('xyz', 18, 75)], dtype=student) +print(a) diff --git a/Numpy/numpy_ndarray_object.py b/Numpy/numpy_ndarray_object.py new file mode 100644 index 0000000..e4408d7 --- /dev/null +++ b/Numpy/numpy_ndarray_object.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +import numpy as np + +a = np.array([1, 2, 3]) +# print(a) + +# 多于一个维度 +a = np.array([[1, 2], [3, 4]]) +# print(a) + +# 最小维度 +a = np.array([1, 2, 3, 4, 5], ndmin=2) +# print(a) + +# dtype参数 +a = np.array([1, 2, 3], dtype=complex) +print(a) diff --git a/Numpy/testInstallSuccess.py b/Numpy/testInstallSuccess.py new file mode 100644 index 0000000..5913533 --- /dev/null +++ b/Numpy/testInstallSuccess.py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +# 测试是否安装成功 +from numpy import * + +print(eye(4)) diff --git a/Requests/filmlist.txt b/Requests/filmlist.txt index e44e55d..de3b288 100644 --- a/Requests/filmlist.txt +++ b/Requests/filmlist.txt @@ -1,251 +1,251 @@ - Ӱ - 1 Ф˵ľꡡ 9.6 - 2 𼧡 9.6 - 3 ɱֲ̫䡡 9.4 - 4 9.4 - 5 9.5 - 6 ̩̹˺š 9.3 - 7 ǧǧѰ 9.3 - 8 յ 9.4 - 9 οռ䡡 9.3 - 10 ܶԱ 9.3 - 11 Ȯ˹Ĺ¡ 9.3 - 12 ɵֱ롡 9.2 - 13 ϸʦ 9.2 - 14 ţĴ졡 9.2 - 15 ֮ʥȢס 9.2 - 16 ŵ硡 9.2 - 17 ̸ 9.2 - 18 è 9.1 - 19 ǼʴԽ 9.2 - 20 ¯ 9.2 - 21 ޼ 9.1 - 22 ɼ 9.2 - 23 Ҹš 9.0 - 24 ˡ 9.2 - 25 ȻĶ 9.0 - 26 ǡ 9.1 - 27 õӰԺ 9.1 - 28 ڰʿ 9.1 - 29 š 9.1 - 30 ʮŭ 9.4 - 31 ˡ 9.2 - 32 ɵƯ 9.0 - 33 ָ3޵С 9.1 - 34 ֲ 9.0 - 35 ֮ǡ 9.0 - 36 ط֤ˡ 9.6 - 37 ݻμǡ 8.9 - 38 ֮¹ⱦС 8.9 - 39 ա 9.0 - 40 籩 9.1 - 41 ˴ǹ 9.1 - 42 ˤӰɣְ֡ 9.1 - 43 ԽԺ 9.0 - 44 ʶŮˡ 9.0 - 45 ƶDZ 8.9 - 46 绤ˡ 9.2 - 47 ʫ硡 9.0 - 48 Vֳɱӡ 8.8 - 49 塡 9.3 - 50 ̸2 9.1 - 51 ָ2˫ 9.0 - 52 ָ1ħ֡ 8.9 - 53 顡 8.9 - 54 ʳŮ 9.1 - 55 顡 8.8 - 56 ¡ 9.1 - 57 ʨ 8.9 - 58 ¡ 9.1 - 59 ټҡ 9.1 - 60 СЬӡ 9.2 - 61  8.8 - 62 ӵһ 8.9 - 63 ħ 8.8 - 64 ʹ 8.7 - 65 Ͷ¡ 8.8 - 66 ˵ 8.8 - 67 ڿ͵۹ 8.9 - 68 ֮ 8.9 - 69 ӵɡ 8.7 - 70 ȴ 8.9 - 71 Ŀˡ 8.7 - 72 С˵ 8.8 - 73 ¸ҵġ 8.8 - 74 ְ» 8.7 - 75 ĩʵۡ 9.0 - 76 Ĭĸ򡡡 8.8 - 77 칬 9.3 - 78 ЧӦ 8.7 - 79 էй 8.8 - 80 ʦ 8.8 - 81 鲶֡ 8.8 - 82 ħʯ 8.8 - 83 ˼ 8.9 - 84 õӡ 8.8 - 85 ˹󷹵ꡡ 8.8 - 86 յ 8.7 - 87 èϷ 8.8 - 88 鹫 8.8 - 89 С 8.8 - 90 ɭ֡ 8.7 - 91 ԡ 9.1 - 92 ID 8.7 - 93 ϱɽ 8.7 - 94 ˯µк 8.9 - 95 㡡 8.7 - 96 ձȺ 8.6 - 97 ס 8.7 - 98 һһ 8.9 - 99 ۡ 8.8 - 100  8.6 - 101 Ӣ۴֮ 8.7 - 102 Ħʱ 9.2 - 103 ԡ 8.8 - 104 ϵ֮ǡ 8.9 - 105 ǰ 8.7 - 106 ʧİˡ 8.7 - 107 8.8 - 108 ֮ȡ 8.8 - 109 ƻʱ 8.8 - 110 ѡ 8.8 - 111 ٻŮĻꡡ 8.6 - 112 ֱֲ 8.7 - 113 Сɭ ƪ 8.9 - 114 ϲ֮ 8.6 - 115 8.9 - 116 մɵ졡 8.7 - 117 ѱ֡ 8.7 - 118 Ҹյվ 8.7 - 119 ͵̰֡ 8.5 - 120 趫С˰򰣵 8.7 - 121 ͵ 8.6 - 122 ө֮Ĺ 8.7 - 123 ɱ˻䡡 8.7 - 124 ʿ 9.2 - 125 ޵˾ 8.6 - 126 Ӱ3 8.7 - 127 ϲ硡 8.8 - 128 ⾪ꡡ 8.7 - 129 ƶߵİ̡ 8.5 - 130 а 8.6 - 131 氮ϡ 8.5 - 132 Ƭ 8.6 - 133 졡 8.5 - 134 ԭʼˡ 8.7 - 135 Сɭ ƪ 9.0 - 136 ֺҡ 8.8 - 137 ʥ() 8.7 - 138 ˡ 8.6 - 139 ө֮ɭ 8.8 - 140 󡡡 9.0 - 141 Ӣ۱ɫ 8.6 - 142 7ŷ 8.7 - 143 ¬ﷹꡡ 8.9 - 144 Թ 8.7 - 145 ¡ 8.8 - 146 ƫ 8.5 - 147 ½սӡ 8.6 - 148 ա 8.9 - 149 Ʋ㡡 8.4 - 150 ߵ˹ء 8.6 - 151 ڰʿ 8.6 - 152 ȼ¡ 8.7 - 153 ̸3 8.8 - 154 ݺĺ 8.7 - 155 ʱˡ 8.6 - 156 ܶԱ3 8.8 - 157 ʼDZ 8.5 - 158 硡 9.0 - 159 껪 8.5 - 160 ֪ 9.1 - 161 ˹Ҿֲ 8.7 - 162 ʮ 8.7 - 163 9.0 - 164 »𳵡 8.5 - 165 š 8.8 - 166 ԽʱյŮ 8.6 - 167 Ѫս־롡 8.7 - 168 ɽķ 8.8 - 169 ʱ 8.5 - 170 ˹ܡ 8.6 - 171 ѹ֡ 8.6 - 172 ˳ 8.7 - 173 ʶߡ 8.5 - 174 š 8.7 - 175 δIJݡ 8.8 - 176 ˮ 8.4 - 177 ȵĽꡡ 8.6 - 178 ͷعӡ 8.7 - 179 8.5 - 180 ɿ 8.7 - 181 ֲ֡ 8.4 - 182 ֡ 8.4 - 183 һα롡 8.7 - 184 䡡 8.8 - 185 ׷桡 8.9 - 186 ײ 8.6 - 187 ս֮ 8.6 - 188 ģϷ 8.6 - 189 ϵǡ 8.8 - 190 һŷά˾ȥ 8.8 - 191 ħŮլ㡡 8.5 - 192 Ȯ˹ 9.0 - 193 Ӱء 8.5 - 194 ɱ¼ 8.8 - 195 İˡ 8.6 - 196 Ӱ2 8.6 - 197 ֮ 8.7 - 198 ߸ֺ 8.9 - 199 ߡ 8.5 - 200 ǡ 8.9 - 201 ٴγ֮ŦԼ 8.5 - 202 Сĺ塡 8.5 - 203 ڿ͵۹3 8.6 - 204  9.2 - 205 ſջ 8.5 - 206 Դ롡 8.4 - 207 IJͣ 8.8 - 208 ս2ա 8.6 - 209 ռǡ 8.7 - 210 漣 8.7 - 211 ĩ·񻨡 8.7 - 212 5ס 8.3 - 213 С¡ 8.3 - 214 ֮⡡ 9.2 - 215 ̺졡 8.7 - 216 ޵ƻ 8.7 - 217 ޳ܻ쵰 8.5 - 218 ҹǰ 8.8 - 219 Ե򡡡 8.5 - 220 ´ 8.6 - 221 ʯͷ 8.3 - 222 E.T. ˡ 8.5 - 223 8.6 - 224 8.4 - 225 ̨ 8.6 - 226 ȡ 8.5 - 227 ƽڿ͡ 9.1 - 228 ˡ 8.5 - 229 һҹ 8.4 - 230 Ұ桡 8.6 - 231 Ѫꡡ 8.5 - 232 ۽ 8.8 - 233 ݽ 8.3 - 234 Ӣˡ 8.5 - 235 dzɷ 8.6 - 236 Ǩ񡡡 9.1 - 237 ӥ׹䡡 8.6 - 238 ʿ 8.9 - 239 β 8.6 - 240 Ը嵥 8.5 - 241 Ұ㡡 9.0 - 242 º 8.3 - 243 ҵһ 8.6 - 244 ǹ𡡡 8.6 - 245 ĵ 8.5 - 246 2001̫Ρ 8.7 - 247 ϵҲ񡡡 8.7 - 248 ǧһ 8.7 - 249 һ 8.6 - 250 ɫš 8.3 + 排名     电影     评分 + 1 肖申克的救赎     9.6 + 2 霸王别姬       9.6 + 3 这个杀手不太冷    9.4 + 4 阿甘正传       9.4 + 5 美丽人生       9.5 + 6 泰坦尼克号      9.3 + 7 千与千寻       9.3 + 8 辛德勒的名单     9.4 + 9 盗梦空间       9.3 + 10 机器人总动员     9.3 + 11 忠犬八公的故事    9.3 + 12 三傻大闹宝莱坞    9.2 + 13 海上钢琴师      9.2 + 14 放牛班的春天     9.2 + 15 大话西游之大圣娶亲  9.2 + 16 楚门的世界      9.2 + 17 教父         9.2 + 18 龙猫         9.1 + 19 星际穿越       9.2 + 20 熔炉         9.2 + 21 无间道        9.1 + 22 触不可及       9.2 + 23 当幸福来敲门     9.0 + 24 乱世佳人       9.2 + 25 怦然心动       9.0 + 26 疯狂动物城      9.1 + 27 天堂电影院      9.1 + 28 蝙蝠侠:黑暗骑士   9.1 + 29 活着         9.1 + 30 十二怒汉       9.4 + 31 鬼子来了       9.2 + 32 少年派的奇幻漂流   9.0 + 33 指环王3:王者无敌  9.1 + 34 搏击俱乐部      9.0 + 35 天空之城       9.0 + 36 控方证人       9.6 + 37 飞屋环游记      8.9 + 38 大话西游之月光宝盒  8.9 + 39 罗马假日       9.0 + 40 窃听风暴       9.1 + 41 两杆大烟枪      9.1 + 42 摔跤吧!爸爸     9.1 + 43 飞越疯人院      9.0 + 44 闻香识女人      9.0 + 45 哈尔的移动城堡    8.9 + 46 辩护人        9.2 + 47 死亡诗社       9.0 + 48 V字仇杀队      8.8 + 49 海豚湾        9.3 + 50 教父2        9.1 + 51 指环王2:双塔奇兵  9.0 + 52 指环王1:魔戒再现  8.9 + 53 美丽心灵       8.9 + 54 饮食男女       9.1 + 55 情书         8.8 + 56 素媛         9.1 + 57 狮子王        8.9 + 58 美国往事       9.1 + 59 钢琴家        9.1 + 60 小鞋子        9.2 + 61 七宗罪        8.8 + 62 被嫌弃的松子的一生  8.9 + 63 致命魔术       8.8 + 64 天使爱美丽      8.7 + 65 本杰明·巴顿奇事   8.8 + 66 西西里的美丽传说   8.8 + 67 黑客帝国       8.9 + 68 音乐之声       8.9 + 69 让子弹飞       8.7 + 70 拯救大兵瑞恩     8.9 + 71 看不见的客人     8.7 + 72 低俗小说       8.8 + 73 勇敢的心       8.8 + 74 剪刀手爱德华     8.7 + 75 末代皇帝       9.0 + 76 沉默的羔羊      8.8 + 77 大闹天宫       9.3 + 78 蝴蝶效应       8.7 + 79 春光乍泄       8.8 + 80 入殓师        8.8 + 81 心灵捕手       8.8 + 82 哈利·波特与魔法石  8.8 + 83 玛丽和马克思     8.9 + 84 阳光灿烂的日子    8.8 + 85 布达佩斯大饭店    8.8 + 86 禁闭岛        8.7 + 87 猫鼠游戏       8.8 + 88 幽灵公主       8.8 + 89 第六感        8.8 + 90 重庆森林       8.7 + 91 狩猎         9.1 + 92 致命ID       8.7 + 93 断背山        8.7 + 94 穿条纹睡衣的男孩   8.9 + 95 大鱼         8.7 + 96 加勒比海盗      8.6 + 97 告白         8.7 + 98 一一         8.9 + 99 甜蜜蜜        8.8 + 100 阿凡达        8.6 + 101 射雕英雄传之东成西就 8.7 + 102 摩登时代       9.2 + 103 阳光姐妹淘      8.8 + 104 上帝之城       8.9 + 105 爱在黎明破晓前    8.7 + 106 消失的爱人      8.7 + 107 侧耳倾听       8.8 + 108 风之谷        8.8 + 109 爱在日落黄昏时    8.8 + 110 超脱         8.8 + 111 倩女幽魂       8.6 + 112 恐怖直播       8.7 + 113 小森林 夏秋篇    8.9 + 114 喜剧之王       8.6 + 115 红辣椒        8.9 + 116 菊次郎的夏天     8.7 + 117 驯龙高手       8.7 + 118 幸福终点站      8.7 + 119 神偷奶爸       8.5 + 120 借东西的小人阿莉埃蒂 8.7 + 121 岁月神偷       8.6 + 122 萤火虫之墓      8.7 + 123 杀人回忆       8.7 + 124 七武士        9.2 + 125 怪兽电力公司     8.6 + 126 谍影重重3      8.7 + 127 喜宴         8.8 + 128 电锯惊魂       8.7 + 129 贫民窟的百万富翁   8.5 + 130 东邪西毒       8.6 + 131 真爱至上       8.5 + 132 记忆碎片       8.6 + 133 黑天鹅        8.5 + 134 疯狂原始人      8.7 + 135 小森林 冬春篇    9.0 + 136 请以你的名字呼唤我  8.8 + 137 哈利·波特与死亡圣器(下) 8.7 + 138 雨人         8.6 + 139 萤火之森       8.8 + 140 海洋         9.0 + 141 英雄本色       8.6 + 142 7号房的礼物     8.7 + 143 卢旺达饭店      8.9 + 144 心迷宫        8.7 + 145 荒蛮故事       8.8 + 146 傲慢与偏见      8.5 + 147 超能陆战队      8.6 + 148 虎口脱险       8.9 + 149 唐伯虎点秋香     8.4 + 150 海边的曼彻斯特    8.6 + 151 蝙蝠侠:黑暗骑士崛起 8.6 + 152 燃情岁月       8.7 + 153 教父3        8.8 + 154 纵横四海       8.7 + 155 时空恋旅人      8.6 + 156 玩具总动员3     8.8 + 157 恋恋笔记本      8.5 + 158 完美的世界      9.0 + 159 花样年华       8.5 + 160 无人知晓       9.1 + 161 达拉斯买家俱乐部   8.7 + 162 二十二        8.7 + 163 雨中曲        9.0 + 164 猜火车        8.5 + 165 魂断蓝桥       8.8 + 166 穿越时空的少女    8.6 + 167 血战钢锯岭      8.7 + 168 我是山姆       8.8 + 169 冰川时代       8.5 + 170 人工智能       8.6 + 171 爆裂鼓手       8.6 + 172 浪潮         8.7 + 173 朗读者        8.5 + 174 罗生门        8.7 + 175 未麻的部屋      8.8 + 176 香水         8.4 + 177 被解救的姜戈     8.6 + 178 头脑特工队      8.7 + 179 阿飞正传       8.5 + 180 可可西里       8.7 + 181 恐怖游轮       8.4 + 182 你的名字。      8.4 + 183 一次别离       8.7 + 184 房间         8.8 + 185 追随         8.9 + 186 撞车         8.6 + 187 战争之王       8.6 + 188 模仿游戏       8.6 + 189 地球上的星星     8.8 + 190 一个叫欧维的男人决定去死 8.8 + 191 魔女宅急便      8.5 + 192 忠犬八公物语     9.0 + 193 谍影重重       8.5 + 194 牯岭街少年杀人事件  8.8 + 195 完美陌生人      8.6 + 196 谍影重重2      8.6 + 197 梦之安魂曲      8.7 + 198 哪吒闹海       8.9 + 199 青蛇         8.5 + 200 惊魂记        8.9 + 201 再次出发之纽约遇见你 8.5 + 202 小萝莉的猴神大叔   8.5 + 203 黑客帝国3:矩阵革命 8.6 + 204 东京物语       9.2 + 205 新龙门客栈      8.5 + 206 源代码        8.4 + 207 步履不停       8.8 + 208 终结者2:审判日   8.6 + 209 海街日记       8.7 + 210 绿里奇迹       8.7 + 211 末路狂花       8.7 + 212 秒速5厘米      8.3 + 213 初恋这件小事     8.3 + 214 城市之光       9.2 + 215 碧海蓝天       8.7 + 216 无敌破坏王      8.7 + 217 无耻混蛋       8.5 + 218 爱在午夜降临前    8.8 + 219 这个男人来自地球   8.5 + 220 勇闯夺命岛      8.6 + 221 疯狂的石头      8.3 + 222 E.T. 外星人   8.5 + 223 卡萨布兰卡      8.6 + 224 变脸         8.4 + 225 海盗电台       8.6 + 226 发条橙        8.5 + 227 黄金三镖客      9.1 + 228 美国丽人       8.5 + 229 彗星来的那一夜    8.4 + 230 荒野生存       8.6 + 231 血钻         8.5 + 232 聚焦         8.8 + 233 国王的演讲      8.3 + 234 英国病人       8.5 + 235 非常嫌疑犯      8.6 + 236 迁徙的鸟       9.1 + 237 黑鹰坠落       8.6 + 238 勇士         8.9 + 239 燕尾蝶        8.6 + 240 遗愿清单       8.5 + 241 我爱你        9.0 + 242 穆赫兰道       8.3 + 243 叫我第一名      8.6 + 244 枪火         8.6 + 245 荒岛余生       8.5 + 246 2001太空漫游   8.7 + 247 上帝也疯狂      8.7 + 248 千钧一发       8.7 + 249 大卫·戈尔的一生   8.6 + 250 蓝色大门       8.3 diff --git a/Requests/movies.txt b/Requests/movies.txt index 31d7ffc..bf17f83 100644 --- a/Requests/movies.txt +++ b/Requests/movies.txt @@ -1,250 +1,250 @@ -0 Ф˵ľ -1 -2 ɱֲ̫ -3 -4 -5 ̩̹˺ -6 ǧǧѰ -7 յ -8 οռ -9 ܶԱ -10 Ȯ˹Ĺ -11 ɵֱ -12 ϸʦ -13 ţĴ -14 ֮ʥȢ -15 ŵ -16 ̸ -17 è -18 ǼʴԽ -19 ¯ -20 ޼ -21 ɼ -22 Ҹ -23 -24 ȻĶ -25 -26 õӰԺ -27 ڰʿ -28 -29 ʮŭ -30 -31 ɵƯ -32 ָ3޵ -33 ֲ -34 ֮ -35 ط֤ -36 ݻμ -37 ֮¹ⱦ -38 -39 籩 -40 ˴ǹ -41 ˤӰɣְ -42 ԽԺ -43 ʶŮ -44 ƶDZ -45 绤 -46 ʫ -47 Vֳɱ -48 -49 ̸2 -50 ָ2˫ -51 ָ1ħ -52 -53 ʳŮ -54 -55 -56 ʨ -57 -58 ټ -59 СЬ -60 -61 ӵһ -62 ħ -63 ʹ -64 Ͷ -65 ˵ -66 ڿ͵۹ -67 ֮ -68 ӵ -69 ȴ -70 Ŀ -71 С˵ -72 ¸ҵ -73 ְ» -74 ĩʵ -75 Ĭĸ -76 칬 -77 ЧӦ -78 էй -79 ʦ -80 鲶 -81 ħʯ -82 ˼ -83 õ -84 ˹󷹵 -85 յ -86 èϷ -87 鹫 -88 -89 ɭ -90 -91 ID -92 ϱɽ -93 ˯µк -94 -95 ձȺ -96 -97 һһ -98 -99 -100 Ӣ۴֮ -101 Ħʱ -102 -103 ϵ֮ -104 ǰ -105 ʧİ -106 -107 ֮ -108 ƻʱ -109 -110 ٻŮĻ -111 ֱֲ -112 Сɭ ƪ -113 ϲ֮ -114 -115 մɵ -116 ѱ -117 Ҹյվ -118 ͵̰ -119 趫С˰򰣵 -120 ͵ -121 ө֮Ĺ -122 ɱ˻ -123 ʿ -124 ޵˾ -125 Ӱ3 -126 ϲ -127 ⾪ -128 ƶߵİ -129 а -130 氮 -131 Ƭ -132 -133 ԭʼ -134 Сɭ ƪ -135 ֺ -136 ʥ() -137 -138 ө֮ɭ -139 -140 Ӣ۱ɫ -141 7ŷ -142 ¬ﷹ -143 Թ -144 -145 ƫ -146 ½ս -147 -148 Ʋ -149 ߵ˹ -150 ڰʿ -151 ȼ -152 ̸3 -153 ݺĺ -154 ʱ -155 ܶԱ3 -156 ʼDZ -157 -158 껪 -159 ֪ -160 ˹Ҿֲ -161 ʮ -162 -163 » -164 -165 ԽʱյŮ -166 Ѫս־ -167 ɽķ -168 ʱ -169 ˹ -170 ѹ -171 ˳ -172 ʶ -173 -174 δIJ -175 ˮ -176 ȵĽ -177 ͷع -178 -179 ɿ -180 ֲ -181 ֡ -182 һα -183 -184 ׷ -185 ײ -186 ս֮ -187 ģϷ -188 ϵ -189 һŷά˾ȥ -190 ħŮլ -191 Ȯ˹ -192 Ӱ -193 ɱ¼ -194 İ -195 Ӱ2 -196 ֮ -197 ߸ֺ -198 -199 -200 ٴγ֮ŦԼ -201 Сĺ -202 ڿ͵۹3 -203 -204 ſջ -205 Դ -206 IJͣ -207 ս2 -208 ռ -209 漣 -210 ĩ· -211 5 -212 С -213 ֮ -214 ̺ -215 ޵ƻ -216 ޳ܻ쵰 -217 ҹǰ -218 Ե -219 ´ -220 ʯͷ -221 E.T. -222 -223 -224 ̨ -225 -226 ƽڿ -227 -228 һҹ -229 Ұ -230 Ѫ -231 ۽ -232 ݽ -233 Ӣ -234 dzɷ -235 Ǩ -236 ӥ׹ -237 ʿ -238 β -239 Ը嵥 -240 Ұ -241 º -242 ҵһ -243 ǹ -244 ĵ -245 2001̫ -246 ϵҲ -247 ǧһ -248 һ -249 ɫ +0 肖申克的救赎 +1 霸王别姬 +2 这个杀手不太冷 +3 阿甘正传 +4 美丽人生 +5 泰坦尼克号 +6 千与千寻 +7 辛德勒的名单 +8 盗梦空间 +9 机器人总动员 +10 忠犬八公的故事 +11 三傻大闹宝莱坞 +12 海上钢琴师 +13 放牛班的春天 +14 大话西游之大圣娶亲 +15 楚门的世界 +16 教父 +17 龙猫 +18 星际穿越 +19 熔炉 +20 无间道 +21 触不可及 +22 当幸福来敲门 +23 乱世佳人 +24 怦然心动 +25 疯狂动物城 +26 天堂电影院 +27 蝙蝠侠:黑暗骑士 +28 活着 +29 十二怒汉 +30 鬼子来了 +31 少年派的奇幻漂流 +32 指环王3:王者无敌 +33 搏击俱乐部 +34 天空之城 +35 控方证人 +36 飞屋环游记 +37 大话西游之月光宝盒 +38 罗马假日 +39 窃听风暴 +40 两杆大烟枪 +41 摔跤吧!爸爸 +42 飞越疯人院 +43 闻香识女人 +44 哈尔的移动城堡 +45 辩护人 +46 死亡诗社 +47 V字仇杀队 +48 海豚湾 +49 教父2 +50 指环王2:双塔奇兵 +51 指环王1:魔戒再现 +52 美丽心灵 +53 饮食男女 +54 情书 +55 素媛 +56 狮子王 +57 美国往事 +58 钢琴家 +59 小鞋子 +60 七宗罪 +61 被嫌弃的松子的一生 +62 致命魔术 +63 天使爱美丽 +64 本杰明·巴顿奇事 +65 西西里的美丽传说 +66 黑客帝国 +67 音乐之声 +68 让子弹飞 +69 拯救大兵瑞恩 +70 看不见的客人 +71 低俗小说 +72 勇敢的心 +73 剪刀手爱德华 +74 末代皇帝 +75 沉默的羔羊 +76 大闹天宫 +77 蝴蝶效应 +78 春光乍泄 +79 入殓师 +80 心灵捕手 +81 哈利·波特与魔法石 +82 玛丽和马克思 +83 阳光灿烂的日子 +84 布达佩斯大饭店 +85 禁闭岛 +86 猫鼠游戏 +87 幽灵公主 +88 第六感 +89 重庆森林 +90 狩猎 +91 致命ID +92 断背山 +93 穿条纹睡衣的男孩 +94 大鱼 +95 加勒比海盗 +96 告白 +97 一一 +98 甜蜜蜜 +99 阿凡达 +100 射雕英雄传之东成西就 +101 摩登时代 +102 阳光姐妹淘 +103 上帝之城 +104 爱在黎明破晓前 +105 消失的爱人 +106 侧耳倾听 +107 风之谷 +108 爱在日落黄昏时 +109 超脱 +110 倩女幽魂 +111 恐怖直播 +112 小森林 夏秋篇 +113 喜剧之王 +114 红辣椒 +115 菊次郎的夏天 +116 驯龙高手 +117 幸福终点站 +118 神偷奶爸 +119 借东西的小人阿莉埃蒂 +120 岁月神偷 +121 萤火虫之墓 +122 杀人回忆 +123 七武士 +124 怪兽电力公司 +125 谍影重重3 +126 喜宴 +127 电锯惊魂 +128 贫民窟的百万富翁 +129 东邪西毒 +130 真爱至上 +131 记忆碎片 +132 黑天鹅 +133 疯狂原始人 +134 小森林 冬春篇 +135 请以你的名字呼唤我 +136 哈利·波特与死亡圣器(下) +137 雨人 +138 萤火之森 +139 海洋 +140 英雄本色 +141 7号房的礼物 +142 卢旺达饭店 +143 心迷宫 +144 荒蛮故事 +145 傲慢与偏见 +146 超能陆战队 +147 虎口脱险 +148 唐伯虎点秋香 +149 海边的曼彻斯特 +150 蝙蝠侠:黑暗骑士崛起 +151 燃情岁月 +152 教父3 +153 纵横四海 +154 时空恋旅人 +155 玩具总动员3 +156 恋恋笔记本 +157 完美的世界 +158 花样年华 +159 无人知晓 +160 达拉斯买家俱乐部 +161 二十二 +162 雨中曲 +163 猜火车 +164 魂断蓝桥 +165 穿越时空的少女 +166 血战钢锯岭 +167 我是山姆 +168 冰川时代 +169 人工智能 +170 爆裂鼓手 +171 浪潮 +172 朗读者 +173 罗生门 +174 未麻的部屋 +175 香水 +176 被解救的姜戈 +177 头脑特工队 +178 阿飞正传 +179 可可西里 +180 恐怖游轮 +181 你的名字。 +182 一次别离 +183 房间 +184 追随 +185 撞车 +186 战争之王 +187 模仿游戏 +188 地球上的星星 +189 一个叫欧维的男人决定去死 +190 魔女宅急便 +191 忠犬八公物语 +192 谍影重重 +193 牯岭街少年杀人事件 +194 完美陌生人 +195 谍影重重2 +196 梦之安魂曲 +197 哪吒闹海 +198 青蛇 +199 惊魂记 +200 再次出发之纽约遇见你 +201 小萝莉的猴神大叔 +202 黑客帝国3:矩阵革命 +203 东京物语 +204 新龙门客栈 +205 源代码 +206 步履不停 +207 终结者2:审判日 +208 海街日记 +209 绿里奇迹 +210 末路狂花 +211 秒速5厘米 +212 初恋这件小事 +213 城市之光 +214 碧海蓝天 +215 无敌破坏王 +216 无耻混蛋 +217 爱在午夜降临前 +218 这个男人来自地球 +219 勇闯夺命岛 +220 疯狂的石头 +221 E.T. 外星人 +222 卡萨布兰卡 +223 变脸 +224 海盗电台 +225 发条橙 +226 黄金三镖客 +227 美国丽人 +228 彗星来的那一夜 +229 荒野生存 +230 血钻 +231 聚焦 +232 国王的演讲 +233 英国病人 +234 非常嫌疑犯 +235 迁徙的鸟 +236 黑鹰坠落 +237 勇士 +238 燕尾蝶 +239 遗愿清单 +240 我爱你 +241 穆赫兰道 +242 叫我第一名 +243 枪火 +244 荒岛余生 +245 2001太空漫游 +246 上帝也疯狂 +247 千钧一发 +248 大卫·戈尔的一生 +249 蓝色大门 diff --git a/leetcode/code/complexNumberMultiply.py b/leetcode/code/complexNumberMultiply.py new file mode 100644 index 0000000..dda92cd --- /dev/null +++ b/leetcode/code/complexNumberMultiply.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +class Solution: + # 复数乘法 + def complexNumberMultiply(self, a, b): + # 获得字符串a的实数部分 + a_real = a.replace('i', '').split('+')[0] + a_imag = a.replace('i', '').split('+')[1] + int_a_real = int(a_real) + int_a_imag = int(a_imag) + + b_real = b.replace('i', '').split('+')[0] + b_imag = b.replace('i', '').split('+')[1] + int_b_real = int(b_real) + int_b_imag = int(b_imag) + + s1 = str(int_a_real * int_b_real) + s2 = str(int_a_real * int_b_imag + int_b_real * int_a_imag) + 'i' + s3 = str(int_b_imag * int_a_imag) + less = int(s1) - int(s3) + s = str(less) + '+' + s2 + print(s) + + def complexNumberMultiply1(self, a, b): + A, B = [], [] + for x in a.replace('i', '').split('+'): + A.append(int(x)) + for x in b.replace('i', '').split('+'): + B.append(int(x)) + + s = str(A[0] * B[0] - A[1] * B[1]) + '+' + str(A[0] * B[1] + A[1] * B[0]) + 'i' + print(s) + + +s = Solution() +s.complexNumberMultiply1("1+-1i", "1+-1i") diff --git a/leetcode/code/countPrimes.py b/leetcode/code/countPrimes.py new file mode 100644 index 0000000..5ce21f6 --- /dev/null +++ b/leetcode/code/countPrimes.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +""" +204.计数质数 +统计所以小于非负整数n的质数的数量 +输入:10 +输出: 4 +解释:小于10的质数一共有4个,它们是2,3,5,7 +""" + + +class Solution: + + def countPrimes(self, n): + if n < 3: + return 0 + prime = [1] * n + prime[0] = prime[1] = 0 + for i in range(2, int(n ** 0.5) + 1): + if prime[i] == 1: + prime[i * i:n:i] = [0] * len(prime[i * i:n:i]) + return sum(prime) + + + def countPrimes1(self, n): + flag, sum = False, 0 + for i in range(2, n): + for j in range(2, int(i**0.5)+1): + if i % j == 0: + flag = True + break + if flag == 0: + print(i) + sum += 1 + else: + flag = False + print(sum) + +s = Solution() +s1 = s.countPrimes1(10) +print(s1) diff --git a/leetcode/code/findNthDigit.py b/leetcode/code/findNthDigit.py new file mode 100644 index 0000000..0f217f6 --- /dev/null +++ b/leetcode/code/findNthDigit.py @@ -0,0 +1,25 @@ +class Solution(object): + def findNthDigit(self, n): + """ + :type n: int + :rtype: int + """ + """ + 个位数:1-9,一共9个,共计9个数字 + 2位数:10-99,一共90个,共计180个数字 + 3位数:100-999,一共900个,共计270个数字 + 4位数,1000-9999,一共9000个,共计36000个数字 36000=4*9*10**(4-1) + ...... + """ + # 第一步确定n是在几位数里,第二步是确定在几位数的第几位数字的第几位 + # 第一步 + digit = 1 # 位数 + while n > digit * 9 * 10 ** (digit - 1): + n -= digit * 9 * 10 ** (digit - 1) + digit += 1 + # 第二步 + a = int((n - 1) / digit) # 得到几位数的第几位数字 + b = int((n - 1) % digit) # 得到几位数的第几位数字的第几位 + num = 10 ** (digit - 1) + a # 得到第几位数字是多少 + res = list(str(num))[b:b + 1] # 数字转字符再转列表把第几位数的第几位切出来 + return int(''.join(res)) # 列表转字符再转数字 diff --git a/leetcode/code/hammingDistance.py b/leetcode/code/hammingDistance.py new file mode 100644 index 0000000..16f01a2 --- /dev/null +++ b/leetcode/code/hammingDistance.py @@ -0,0 +1,12 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +# 461.汉明距离 +class Solution: + def hammingDistance(self, x, y): + s = bin(x ^ y)[2:] + print(s.count('1')) + +s = Solution() +s.hammingDistance(1, 4) \ No newline at end of file diff --git a/leetcode/code/intersection.py b/leetcode/code/intersection.py new file mode 100644 index 0000000..ea31864 --- /dev/null +++ b/leetcode/code/intersection.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +class Solution: + """ + 349.两个数组的交集 + """ + + def intersection(self, nums1, nums2): + lst = list(set(nums1) & set(nums2)) + print(lst) + +s = Solution() +s.intersection([1, 2, 2, 1], [2, 2]) diff --git a/leetcode/code/isPowerOfTwo.py b/leetcode/code/isPowerOfTwo.py new file mode 100644 index 0000000..924b911 --- /dev/null +++ b/leetcode/code/isPowerOfTwo.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# 2的幂 +class Solution: + def isPowerOfTwo(self, n): + if n <= 0: + return False + if n == 1: + return True + + while n > 1: + if (n % 2 != 0): + return False + n /= 2 + return True + +s = Solution() +b = s.isPowerOfTwo(1) +print(b) \ No newline at end of file diff --git a/leetcode/code/isUgly.py b/leetcode/code/isUgly.py new file mode 100644 index 0000000..56f8889 --- /dev/null +++ b/leetcode/code/isUgly.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + + +# 263.丑数(只包含2,3,5的正整数) +class Solution: + def isUgly(self, num): + if num < 1: + return False + while num % 2 == 0: + num /= 2 + while num % 3 == 0: + num /= 3 + while num % 5 == 0: + num /= 5 + return (num == 1) or (num == 2) or (num == 3) or (num == 5) + + # 因式分解 + def getFactory(self, num): + return [x for x in range(1, num+1) if num % x == 0] + + +s = Solution() +b = s.getFactory(28) +print(b) diff --git a/leetcode/code/plusOne.py b/leetcode/code/plusOne.py new file mode 100644 index 0000000..42f57c6 --- /dev/null +++ b/leetcode/code/plusOne.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +class Solution: + def plusOne(self, digits): + s , output = '', [] + + for i in digits: + s += str(i) + num = int(s) + 1 + for i in str(num): + output.append(int(i)) + print(output) + +s = Solution() +s.plusOne([9, 9]) \ No newline at end of file diff --git a/leetcode/code/productExceptSelf.py b/leetcode/code/productExceptSelf.py new file mode 100644 index 0000000..8a5549a --- /dev/null +++ b/leetcode/code/productExceptSelf.py @@ -0,0 +1,22 @@ +#!/bin/usr/python +# -*- coding:utf-8 -*- +class Solution(object): + def productExceptSelf(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + dp1 = [1] + dp2 = [1] + for i in range(len(nums) - 1): + dp1.append(dp1[i] * nums[i]) + dp2.append(dp2[i] * nums[-i - 1]) + + output = [] + for i in range(len(dp1)): + output.append(dp1[i] * dp2[-i - 1]) + return output + +s = Solution() +lst = s.productExceptSelf([1, 2, 3, 4]) +print(lst) diff --git a/leetcode/code/reverse.py b/leetcode/code/reverse.py new file mode 100644 index 0000000..577816b --- /dev/null +++ b/leetcode/code/reverse.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# 整数反转 +class Solution: + def reverse(self, x): + if x >= 0: + num = int(str(x)[::-1]) + else: + num = int('-' + str(-x)[::-1]) + + if num >= (-2 ** 31) and num <= 2 ** 31 - 1: + return num + else: + return 0 + + +s = Solution() +n = s.reverse(123) +print(n) + +n = s.reverse(-123) +print(n) + +n = s.reverse(120) +print(n) + +n = s.reverse(1563847412) +print(n) diff --git a/leetcode/code/shuffle_an_array.py b/leetcode/code/shuffle_an_array.py new file mode 100644 index 0000000..f249fbe --- /dev/null +++ b/leetcode/code/shuffle_an_array.py @@ -0,0 +1,36 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + + +# 383.打乱数组 +class Solution: + + def __init__(self, nums): + self.origin = nums[:] + self.output = nums + + def reset(self): + """ + Resets the array to its original configuration and return it. + :rtype: List[int] + """ + return self.origin + + def shuffle(self): + """ + Returns a random shuffling of the array. + :rtype: List[int] + """ + import random + n = len(self.output) + for i in range(n): + j = random.randint(i, n - 1) + self.output[i], self.output[j] = self.output[j], self.output[i] + return self.output + + +nums = [1, 2, 3] +s = Solution(nums) +print(s.shuffle()) +print(s.reset()) diff --git a/leetcode/code/singleNumber.py b/leetcode/code/singleNumber.py new file mode 100644 index 0000000..bf0b68d --- /dev/null +++ b/leetcode/code/singleNumber.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +__author__ = 'exchris' + +# 137.只出现一次的数字II +class Solution: + + def singleNumber(self, nums): + a, b = 0, 0 + for num in nums: + b = ~a & (b ^ num) + a = ~b & (a ^ num) + return b + +s = Solution() +s1 = s.singleNumber([2, 2, 3, 2]) +print(s1) \ No newline at end of file diff --git a/leetcode/code/triangle.py b/leetcode/code/triangle.py new file mode 100644 index 0000000..81068aa --- /dev/null +++ b/leetcode/code/triangle.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +class Solution: + + def generate(self, row_nums): + triangle = [] + + for row_num in range(row_nums): + # The first and last row elements area always 1 + row = [None for _ in range(row_num + 1)] + row[0], row[-1] = 1, 1 + + for j in range(1, len(row) - 1): + row[j] = triangle[row_num - 1][j - 1] + triangle[row_num - 1][j] + + triangle.append(row) + + return triangle + + +s = Solution() +s.getRow(5) diff --git a/leetcode/code/triangle_index.py b/leetcode/code/triangle_index.py new file mode 100644 index 0000000..251431b --- /dev/null +++ b/leetcode/code/triangle_index.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +class Solution: + + def getRow(self, rowIndex): + lst = self.generate(rowIndex + 1)[-1] + print(lst) + + def generate(self, row_nums): + triangle = [] + + for row_num in range(row_nums): + # The first and last row elements area always 1 + row = [None for _ in range(row_num + 1)] + row[0], row[-1] = 1, 1 + + for j in range(1, len(row) - 1): + row[j] = triangle[row_num - 1][j - 1] + triangle[row_num - 1][j] + + triangle.append(row) + + return triangle + + def getRow1(self, rowIndex): + if rowIndex == 0: + return [1] + lst = [] + i, j = 1, 1 + h = rowIndex + while i < rowIndex: + lst.append(h // j) + h *= rowIndex - i + j *= i + 1 + i += 1 + lst.append(1) + lst.insert(0, 1) + print(lst) + + +s = Solution() +s.getRow(5)