自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 资源 (1)
  • 收藏
  • 关注

原创 leedcode解析—Python3—Sudoku Solver—hard

题目:Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:1.Each of the digits 1-9 must occur exactly once in each row.2.Each of the digits 1-9 must occur exactly once in each colum

2021-05-15 02:52:42 152

原创 python 如何复制 list

第一种方法,直接用等号复制;但是复制的其实是list1的地址,后面如果对list1进行了编辑,list2也会发生同样的改变list1 = [1,2,3]list2 = list1print(list2)list1.append(4)print(list2)# output[1, 2, 3][1, 2, 3, 4]2.第二种方法,切片法;当list只有一层时,复制的是list1中的每个元素,所以编辑list1不会影响list2;但是当list1不止一层时,即list1中还包含list.

2021-05-15 01:13:56 733

原创 leedcode解析—Python3—Search in Rotated Sorted Array—Medium

题目:There is an integer array nums sorted in ascending order (with distinct values).Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], …, n

2021-05-10 20:15:38 110

原创 leedcode解析—Python3—Divide Two Integers—Medium

题目Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.Return the quotient after dividing dividend by divisor.The integer division should truncate toward zero, which means losing its fract

2021-05-06 23:52:28 93

原创 leedcode解析—Python3—Regular Expression Matching—hard

题目:Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘✳’ where:‘.’ Matches any single character.​​​​‘✳’ Matches zero or more of the preceding element.The matching should cover the entire input str

2021-04-27 01:04:14 76

原创 leedcode解析—Python3—ZigZag Conversion—medium

题目:The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this:我的思路:把s拆成给定的行数,依次把s的每个元素加至正确的行中Runtime: 68 ms(36.82%),Memory Usage: 14.6 MB(24.24%),复杂度:O(len(s))我的解答:class Solution: def convert(self, s: str, num

2021-04-24 18:14:40 81

原创 leedcode解析—Python3—Longest Common Prefix—easy

题目:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: strs = [“flower”,“flow”,“flight”]Output: “fl”Example 2:Input: strs = [“dog”,“racecar”,“

2021-04-24 02:08:45 100

原创 leedcode解析—Python3—Add Two Numbers—medium

题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.You may assume the two nu

2021-04-23 16:25:07 252

原创 leedcode解析—Python3—Multiply Strings—medium

题目:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.我的思路:题目非常简单,计算两个

2021-04-23 15:34:07 52

原创 leedcode解析—Python3—Longest Substring Without Repeating Characters—medium

题目:Given a string s, find the length of the longest substring without repeating characters.Example :Input: s = “pwwkew”Output: 3Explanation: The answer is “wke”, with the length of 3.Notice that the answer must be a substring, “pwke” is a subsequence

2021-04-23 15:22:20 72

原创 leedcode解析—Python3—Median of Two Sorted Arrays—hard

import numpy as npclass Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: a = np.asarray(nums1) b = np.asarray(nums2) c = np.concatenate((a, b)) d = np.sort(c) if len(d)

2021-04-23 10:26:05 158

原创 leedcode解析—Python3—Longest Palindromic Substring—medium

题目:Given a string s, return the longest palindromic substring in s.Example 1:Input: s = “babad”Output: “bab”Note: “aba” is also a valid answer.Example 2:Input: s = “cbbd”Output: “bb”Example 3:Input: s = “a”Output: “a”Example 4:Input: s = “ac”

2021-04-22 16:56:19 128 1

原创 Python 快速生成有规律的 list 或 dic 的方法

#generate list that all members are samelist1 = 12*[1]#generate list that all members have same intervallist2 = [i for i in range(10)]#generate dictionary that all keys have same intervaldic1 = {str(i): 666 for i in range(10)}dic2 = {str(i): i for i

2021-04-21 20:30:29 698

原创 Standard ML Homework1

要求Programming Languages (Coursera / University of Washington) Assignment 1You will write 11 SML functions (and tests for them) related to calendar dates. In all problems, a “date” is an SML value of type intintint, where the first part is the year, the s

2021-04-14 22:08:24 411

原创 Emacs中SML的基本操作

快捷键Windows键盘中,这里C指的是Ctrl,M指的是Alt键C-x C-c: Quit EmacsC-g: Cancel the current actionC-x C-f: Open a file (whether or not it already exists)C-x C-s: Save a fileC-x C-w: Write a file (probably more familiar to you as Save as…)C-c C-s: 分割窗口并创建SML提示C-w:

2021-04-13 21:34:46 542

原创 Python—如何自定义数据类型和方法

这里用一个简单的实例来说明:class Character: def __init__(self, name, initial_health): self.name = name self.health = initial_health self.inventory = [] def __str__(self): s = "Name: " + self.name s += " Health:

2021-04-09 15:06:24 3226

原创 coursera—Mini-project #5—Memory

这是一个来自 The Rice的课程 An Introduction to Interactive Programming in Python (Part 2)的记忆力翻纸牌游戏,废话不多说,直接上代码。源代码# implementation of card game - Memoryimport simpleguiimport random# helper function to initialize globalsdef new_game(): global new_lis, st

2021-04-09 00:23:46 141

原创 RHIM domain 的预测—一个超级简单的python在分子生物学中的应用实例

为什么会写这篇文章/无奈脸作为一个曾经的生物狗(现在好像依然是),混迹于分子生物学实验室,偶尔会接到来自实验室导师的小杂活总是不能避免(大部分时候是偶尔看到一篇文章的灵光一现/捂脸);某一天老板想知道我们目前在研究的某个病毒是否存在RHIM区,好搞个大新闻,一顿 Ctrl + F 之后速度给完反馈后反而激起了对方更强烈的好奇心,干脆把我们有的都找找看吧。。。为了获得更准确的结果,防止人工出错(避免被累死),当时为了肝毕业半年没写过代码的我怒写如下小程序并且采用了一个自己编的并不百分百严谨的评分机制,最近为

2021-03-31 22:05:23 2079 2

原创 coursera—Mini-project #4—Pong

这是来自 The Rice的课程 An Introduction to Interactive Programming in Python (Part 1)最后一周的项目,一个乒乓球小游戏,可以分别用上下方向键和 “w” “S”键控制两方对手打乒乓球,最后一个项目相对之前的来说稍微复杂一些,主要完成的思路是先做好拍子,再让拍子按照规则上下移动不超过球台;再做好可以直线运动的球,接触到球桌边缘会直角反弹;最后再根据球是否触拍计分或者重新开始,具体步骤的解析,写在代码的注释里啦源代码# Implementa

2021-03-31 16:06:38 170

原创 coursera—Mini-project #3—Stopwatch: The Game

依然是整理的来自 The Rice的课程 An Introduction to Interactive Programming in Python (Part 1)第四周的小项目,一个简单的秒表游戏,点击停止时,秒表的秒钟是整数的话胜利加一分,这里用到了SimpleGUI的 timer小工具。源代码# template for "Stopwatch: The Game"# define global variablesimport simpleguisum_times = 0message

2021-03-31 14:50:30 261

原创 coursera—Mini-project #2—“Guess the number”

依然是整理的来自 The Rice的课程 An Introduction to Interactive Programming in Python (Part 1)第三周的小项目,一个简单的猜数字的游戏,这一课程大量用到了一个python的工具包SimpleGUI用于创建图形用户界面(GUI graphical user interface)源代码import simpleguiimport randomdef new_game(): range100() def range1

2021-03-30 22:51:39 240 1

原创 coursera—Mini-project #1 - Rock-paper-scissor-lizard-Spock

这个小项目来自 The Rice的课程 An Introduction to Interactive Programming in Python (Part 1)第二周的小项目,是一个进阶版的石头剪刀布小游戏,这里就借用一下网上随便搜到的翻译—石头剪刀布蜥蜴史波克吧!游戏规则分别用数字0-4代表你可以出的手势:0 — rock1 — Spock2 — paper3 — lizard4 — scissors其中每个手势可以杀死不同的另外两种手势:0 kill—> 3, 41 kill

2021-03-29 23:51:46 167

原创 Coursera-programming languages (Part A)-Week0 Emacs中SML环境的配置

本教程在Windows环境下操作Emacs的下载安装直接进入官网(https://www.gnu.org/software/emacs/)下载需要的版本的zip文件,无需安装,直接解压至想要安装的位置即可。由于直接打开emacs.exe会同时打开一个命令窗口,可以使用bin目录下的runemacs.exe作为快捷方式。SML的下载安装官网链接(http://www.smlnj.org/dist/working/110.80/)选择需要的版本,直接下载安装。在cmd终端运行sml出现版本信息代表安装成

2021-03-28 00:22:33 282 2

Khan Academy_ Statistics[229].pdf

这门课是统计学入门课程,将涵盖统计学所有的主要知识,包括:随机变量、均值方差标准差、统计图表、概率密度、二项分布、泊松分布、正态分布、大数定律、中心极限定理、样本和抽样分布、参数估计、置信区间、伯努利分布、假设检验和p值、方差分析、回归分析等内容。

2021-04-07

空空如也

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

TA关注的人

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