自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Zetrue_Li Blog

One of juniors in Sun Yat-sen University

  • 博客(31)
  • 资源 (4)
  • 收藏
  • 关注

原创 《升级》扑克牌游戏——Python实现

玩家模块的规范:用一个长度为2的字符串表示一张牌:(D,C,H,S) + (A,2,3,4,5,6,7,8,9,0,J,Q,K) 用"jk"、"JK"分别表示小王、大王游戏顺序是逆时针方向角色用一个字符串表示,("banker","banker_opposite","banker_left","banker_right")分别表示庄家、庄家的对家、庄家的左边、庄家的右边不考虑甩牌...

2018-12-10 10:54:00 8002 5

原创 解决寻找第K小元素问题——三种不同的算法实现

个人原创,禁止转载——Zetrue_Li  问题描述:在一个序列里找出第K小元素以下程序基于函数 int select_kth_smallest(list q, int k) 实现 :返回向量q中第k最小元的函数算法一:基于冒泡排序思想,暴力求解:基本思路:要求找出第k个最小元素,可以通过在序列中遍历k次,每次找出最小的,并放在序列头。类似泡泡一样,找出第k个大的泡泡(bu...

2018-09-12 19:23:25 30564 4

原创 Python plotTree.py —— 决策树绘图模块函数

Python plotTree.py —— 决策树绘图模块函数保存以下代码为plotTree.py,在所需调用的py文件,加入代码:import plotTreeplotTree.createPlot(Tree)plotTree.py:import matplotlib.pyplot as pltfrom pylab import *# 定义文本框和箭头格式d...

2019-03-26 15:41:45 7890

原创 Solve TSP with dynamic programming——动态规划解决旅行商(邮递员)问题

无向简单图的TSP算法小规模精确解:算法思想:小规模精确解的算法中心思想是动态规划思想。假设给定顶点集合V为{0,1,2,3,4,... .n}。由于图为无向完全图,我们可以很自然地将0视为输出的起点和终点。对于每个其他顶点i(除0之外),我们找到以0为起点,i为终点,且所有顶点恰好出现一次的最小成本路径。假设定义这条最小成本路径的成本为Cost(i),则相应TSP回路的Cost将...

2018-12-10 11:13:21 921

原创 Futoshiki solving wih GAC using Python

代码实现:import timeimport queuesize = 0 def read(string): global size board = [] small, large = {}, {} with open(string) as f: line = f.readline() size = int(line) for _ in range(size...

2018-10-28 21:52:39 677

原创 IDA* 迭代加深A star算法解决15数码问题——python实现

 1 IDA* Algorithm1.1 DescriptionIterative deepening A* (IDA*) was first described by Richard Korf in 1985, which is a graph traversaland path search algorithm that can find the shortest path bet...

2018-09-14 14:42:21 4585

原创 LeetCode 561. Array Partition I——python一行代码解决

问题来源:561. Array Partition I问题描述:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) fo...

2018-08-24 23:28:28 204

原创 LeetCode 867. Transpose Matrix——python一行代码解决

问题来源:867. Transpose Matrix问题描述:Given a matrix A, return the transpose of A.The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the ma...

2018-08-24 23:17:11 265

原创 LeetCode 832. Flipping an Image——python一行代码解决

问题来源:832. Flipping an Image问题描述:Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row ...

2018-08-24 14:33:15 215

原创 LeetCode 728. Self Dividing Numbers——python一行代码解决

问题来源 728. Self Dividing Numbers问题描述:A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0,...

2018-08-24 14:29:55 187

原创 Exercise: Sklearn

Steps1 Create a classification dataset (n samples 1000, n features 10)2 Split the dataset using 10-fold cross validation3 Train the algorithmsI GaussianNBI SVC (possible C values [1e-02, 1e-01, 1e00...

2018-06-18 21:37:52 196

原创 Exercise: Jupyter

 Exercise: JupyterPart 1For each of the four datasets...Compute the mean and variance of both x and yCompute the correlation coefficient between x and yCompute the linear regression line: y=β0+β1x+ϵy=...

2018-06-12 16:33:30 214

原创 Exercise: Scipy

Exercise 10.1: Least squaresGenerate matrix A ∈ Rm × n with m > n. Also generate some vector b ∈ Rm.Now find x = argminx k Ax − bk 2.Print the norm of the residual.残差定义:scipy.optimize.lsq_linearsci...

2018-06-05 14:22:59 818

原创 Exercise: Matpotlib

Exercise 11.1: Plotting a function    Plot the function           over the interval [0, 2]. Add proper axis labels, a title, etc.numpy.expnumpy.exp(x, /, out=None, *, where=True, casting='same_kind', ...

2018-05-29 09:06:50 501

原创 Exercise: Numpy

Exercise: NumpyGenerate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn × m and B ∈Rm × m, for n = 200, m = 500.构造A:利用内置函数numpy.random. normal(loc=0.0, scale=1.0, size=None...

2018-05-19 16:24:28 324

原创 LeetCode 71. Simplify Path

一、       问题描述:Given an absolute path for a file(Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:·        Did you consider the case w...

2018-05-16 19:15:08 109

原创 LeetCode 6. ZigZag Conversion

一、     问题描述:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows likethis: (you may want to display this pattern in a fixed font for betterlegibility)P   A   H   NA P L...

2018-05-05 22:10:54 110

原创 LeetCode 5. Longest Palindromic Substring

一、       问题描述:Given a string s, find the longestpalindromic substring in s. You may assumethat the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.E...

2018-04-28 17:35:04 115 1

原创 LeetCode 49. Group Anagrams

一、     问题描述:Given an array of strings, groupanagrams together.Example:Input:["eat", "tea", "tan","ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat",&

2018-04-27 22:27:53 95

原创 LeetCode 11. Container With Most Water

一、问题描述:    Given n non-negativeintegers a1, a2, ..., an, where each represents a point atcoordinate (i, ai). n verticallines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). F...

2018-04-25 20:09:30 101

原创 《Python编程》第十一章部分课后练习题

#11-1 城市和国家:代码:#11-1 城市和国家def city_country(city, country): return city.title() + ', ' + country.title() import unittestclass TestCites(unittest.TestCase): def test_city_country(self): pair ...

2018-04-11 19:10:28 920

原创 《Python编程》第十章部分课后练习题

#10-3 访客:代码:#10-3 访客def save(name): """save user's name in file""" file_name = 'guest.txt' with open(file_name, 'a') as fobj: fobj.write(name+'\n') while True: message = "Hello, please input...

2018-04-05 00:53:25 750 1

原创 《Python编程》第九章部分课后练习题

#9-4 就餐人数:代码:# 9-4 就餐人数class Restaurant(): """define one restaurant class""" def __init__(self, name, cuisine_type): self.restaurant_name = name self.cuisine_type = cuisine_type self.numb...

2018-04-03 21:04:22 803

原创 《Python编程》第八章部分课后练习题

#8-4 大号T恤:代码:#8-4 大号T恤def make_shirt(size='L', style='I love Python'): """pass two argurments to make the specific T-shirt""" message = "This T-shirt's size is " + size + '\n' message += "This T...

2018-03-29 17:36:38 1198

原创 《Python编程》第七章部分课后练习题

#7-4 披萨配料:代码:#7-4 披萨配料"""mushroomspepperoniextra cheese"""while True: message = 'Which Pizza ingredient would you add?' message += "\n(Enter 'quit' to end): " ingredient = input(message) if...

2018-03-26 21:50:06 5462

原创 《Python编程》第六章部分课后练习题

#6-3 词汇表:代码:#6-3 词汇表dic = {'<vector>': 'Vectors are sequence containers representing arrays that can change in size.','<stack>': 'Stacks are a type of container adaptor, specifically ...

2018-03-22 17:15:56 2604

原创 《Python编程》第五章部分课后练习题

#5-5 外星人颜色:代码:#5-5 外星人颜色def get_points(alien_color): point = 0 if alien_color == 'green': point = 5 elif alien_color == 'yellow': point = 10 else: point = 25 message = 'You get ' + str(po...

2018-03-19 20:59:47 1943

原创 《Python编程》第四章部分课后练习题

#4-3 数到20:代码:#4-3 数到20for num in range(1, 21): print(num)输出:pass#4-5 计算1~1 000 000的总和:代码:#4-5 计算1~1 000 000的总和import timenums = list(range(1, 1000001))print(min(nums))print(max(nums))time1 = t...

2018-03-15 16:50:50 5103 1

原创 《Python编程》第三章部分课后练习题

3-4 嘉宾名单:代码:#3-4 嘉宾名单members = ['Kobe Bryant', 'Anthony Davis', 'Michael Jordan']members.append('LeBron James')for member in members: message = member + ', are you willing to have dinner with me ?...

2018-03-13 15:53:24 1847

原创 《Python编程》第二章部分课后练习题

2-2 多条简单消息:代码:# 2-2: 多条简单消息 string = "Today is saturday!"print(string)string = "I am doing homework in library!"print(string)输出:Today is saturday!I am doing homework in library!2-4 调整名字的大小写:代码:#...

2018-03-10 15:21:57 1032

原创 浏览Python主页心得 && Python开发目标

Python主页网址:https://www.python.org    首先,进入主页第一眼看见的是介绍python代码风格及其优点滚动窗:    从注释上可以看出这是斐波那契数列的实现代码。笔者试着阅读下代码,发现代码语法和c++很相似,例如都有while循环语句,但是和c++不同的是while语句少了花括号“{}”而多了冒号“:”。除此之外,定义变量少了int、 double数据类型的声明,...

2018-03-06 15:13:46 217

《升级》扑克牌游戏——Python实现

《升级》扑克牌游戏——Python实现,包括UI界面,AI玩家,裁判监督三大模块。

2018-12-10

C语言考点汇总

C语言重要考点汇总 C语言基本知识 专门为学习C语言的入门新手整合的C语言基本知识

2018-04-27

Computer Networking 6th Edition Kurose Solution Manual

Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems 计算机网络 自顶向下 英文版答案 比中文版答案更加准确

2018-04-27

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除