Sequence

python seed() not keeping same sequence

依然范特西╮ 提交于 2020-05-27 03:07:11
问题 I'm using a random.seed() to try and keep the random.sample() the same as I sample more values from a list and at some point the numbers change.....where I thought the one purpose of the seed() function was to keep the numbers the same. Heres a test I did to prove it doesn't keep the same numbers. import random a=range(0,100) random.seed(1) a = random.sample(a,10) print a then change the sample much higher and the sequence will change(at least for me they always do): a = random.sample(a,40)

Python: How to encode DNA sequence using binary values?

早过忘川 提交于 2020-05-18 18:38:46
问题 I would like to convert a file that contained few DNA sequences into binary values which is as follow: A=1000 C=0100 G=0010 T=0001 FileA.txt CCGAT GCTTA Desired output 01000100001010000001 00100100000100011000 I have tried using this code to solve my problem but the bin output file seem failed to output my desired answer. Can anyone help me? Code import sys if len(sys.argv) != 2 : sys.stderr.write('Usage: {} <nucleotide file>\n'.format(sys.argv[0])) sys.exit() # assumes the file only contains

LCD MIPI DSI简析系列之二【转】

百般思念 提交于 2020-05-09 17:48:23
转自: https://blog.csdn.net/liwei16611/article/details/70245686 MIPI DSI 协议标准支持两种模式:Command模式和Video模式。 1 Command 模式 只有当LCD面板带有显示控制器和帧缓冲区的时候才能使用Command模式。数据传送的格式一般是在像素数据后跟着命令参数(如果有的话)和命令。主机端可以读写LCD控制器的寄存器和帧缓冲区的内容。 每一帧数据开始传输的时间可以由TE信号(由LCD面板输出)来控制也可以使用其的外接管脚,TE线或是直接通过DSI接口传送的TE 触发信息。 1.1 TE 控制信号 为了使用CMD模式,LCD屏需要内置一个时序控制器和缓冲区存储空间(一般为RAM)。为了防止出现Tearing Effect(切屏或分屏)LCD屏需要把它的时序事件信息传递给主机端。在CMD模式下传送这种时序事件可以通过3种方式来实现: • 自动模式:当DSI_VC_TE_i[31]寄存器的TE_START位被设置成0x1的时候软件开始传送数据(这种情况下DSI_VC_TE_i[30]即TE_EN位必须要被置成0x0)。一旦数据传送完成TE_START位会被硬件自动清零。这种模式让数据的传送可以通过软件应用来手动控制或是使用TE中断来控制。如果数据传送跟TE信号不匹配,就有可能会出现切屏或分屏现象。 •

code forces 990C

最后都变了- 提交于 2020-05-09 10:56:37
http://codeforces.com/contest/990/problem/C C. Bracket Sequences Concatenation Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are

CF 1132A,1132B,1132C,1132D,1132E,1132F(Round 61 A,B,C,D,E,F)题解

孤者浪人 提交于 2020-05-09 10:56:06
A.Regular bracket sequence A string is called bracket sequence if it does not contain any characters other than " (" and " )". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters " +" and " 1" into this sequence. For example, "", " (())" and " ()()" are regular bracket sequences; " ))" and " )((" are bracket sequences (but not regular ones), and " (a)" and " (1)+(1)" are not bracket sequences at all. You have a number of strings; each string is a bracket sequence of length 2 2. So, overall you have c n t 1 cnt1 strings " (("

Codeforces Round #459 (Div. 2)

☆樱花仙子☆ 提交于 2020-05-09 10:55:41
A. Eleven time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters. Her friend suggested that her name should only consist of uppercase and lowercase letters ' O'. More precisely, they suggested that the i -th letter of her name should be ' O' (uppercase) if i is a member of Fibonacci sequence, and ' o' (lowercase) otherwise. The letters in the name are numbered

Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) ABCD

旧街凉风 提交于 2020-05-09 10:55:14
A. Single Wildcard Pattern Matching You are given two strings s s and t t. The string s s consists of lowercase Latin letters and at most one wildcard character ' *', the string t tconsists only of lowercase Latin letters. The length of the string s s equals n n, the length of the string t t equals m m. The wildcard character ' *' in the string s s (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of s s can be replaced with anything. If it is possible to replace a wildcard character ' *' in s s to obtain a string t t, then the

CodeForces 917A   The Monster 贪心+思维

萝らか妹 提交于 2020-05-09 10:54:56
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. Thus, he came up with a puzzle to tell his mom his coordinates. His coordinates are the answer to the following problem. A string consisting only of parentheses (' (' and ' )') is called a bracket sequence. Some bracket sequence are called correct bracket sequences. More formally: Empty string is a correct bracket

【贪心】【CF3D】 Least Cost Bracket Sequence

安稳与你 提交于 2020-05-09 09:46:54
传送门 Description 给一个序列,序列里面会有左括号、问号、右括号。对于一个$?$而言,可以将其替换为一个$($,也可以替换成一个$)$,但是都有相应的代价。问:如何替换使得代价最小。前提是替换之后的序列中,括号是匹配的。如果不能替换为一个括号匹配的序列则输出-1。 Input 第一行是序列,序列长度不超过$5~\times10^4$,下面m(m是$m$的数量)行有每行$2$个数据,第一个是$($的代价,第2个是$)$的代价 Output 第一行输出最小代价 第二行输出被转换的序列 Sample Input (??) 1 2 2 8 Sample Output 4 ()() Solution 显然DP可做,然而数据范围太大。 DP不能就尝试一下贪心。 考虑一个特殊性质:对于一个括号序列,如果想要保证他合法,则必须保证在任意一个位置,其前缀左括号数必须不小于右括号数。否则一定不合法。同时这个条件是括号序列合法的充要条件。于是考虑按照这个性质贪心,对于任意一个可以修改的位置,贪心的修改成右括号。当序列不合法时,贪心选取修改代价最小的位置改成左括号。因为修改左括号不会使序列不合法,所以这个贪心使正确的。 Code #include<queue> #include<cstdio> #include<cstring> #define rg register #define ci

【Java】 剑指offer(33) 二叉搜索树的后序遍历序列

泄露秘密 提交于 2020-05-08 09:30:49
本文参考自《剑指offer》一书,代码采用Java语言。 更多: 《剑指Offer》Java实现合集 题目    输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则返回true,否则返回false。假设输入的数组的任意两个数字都互不相同。 思路   二叉树后序遍历数组的最后一个数为根结点,剩余数字中,小于根结点的数字(即左子树部分)都排在前面,大于根结点的数字(即右子树部分)都排在后面。根据遍历数组的这个特性,可以编写出一个递归函数,用于实现题目所要求的判断功能。 测试算例     1.功能测试(左斜树;右斜树;能对应的二叉树;不能对应的二叉树序列)   2.特殊测试(null;一个结点) Java代码 //题目:输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。 //如果是则返回true,否则返回false。假设输入的数组的任意两个数字都互不相同。 public class SquenceOfBST { public boolean verifySquenceOfBST(int[] sequence) { if(sequence== null || sequence.length<=0) return false; return verifyCore(sequence, 0, sequence.length-1); } private