blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
473d55d332a06d0e77cc245fa025452c15e3f931 | godisu524/BaekJunQuiz | /string/10809.py | 174 | 3.640625 | 4 | S=input()
result=""
for a in range(ord('a'),ord('z')+1):
if chr(a) in S:
result+=" "+str((S.index(chr(a))))
else:
result+=" -1"
print(result.strip()) |
a3b61abb6a0c7df08cd87b8b23417d45713ac021 | godisu524/BaekJunQuiz | /string/2941.py | 227 | 3.765625 | 4 | words=["c=",'c-','dz=','d-','lj','nj','s=','z=']
n=input()
w_count=0
for a in words:
if a in n:
w_count+=n.count(a)
n=n.replace(a,"/",n.count(a))
n=n.replace("/","")
w_count+=len(n)
print(w_count)
|
4329194d637741f170ab1f92a5f88f545d419976 | godisu524/BaekJunQuiz | /programmers/stackqueue2.py | 408 | 3.5625 | 4 | from collections import deque
def solution(heights):
answer = []
for i in range(len(heights)-1,-1,-1):
temp=0
for j in range(i-1,-1,-1):
# print(i,j)
if heights[i]<heights[j]:
temp=j+1
break
answer.append(temp)
answer.reverse()... |
6b5ea6034f8c61a49e6cd3de90df3cef31d8d093 | PangYiMing/tensorflow- | /00 Python基础/08 List之index.py | 344 | 4 | 4 | int_month=[1,2,3,4,5]
'''
# 理解下标
index=len(int_month)-1
# list从零开始,如果取5报错
last_value=int_month[index]
print(len(int_month))
print(last_value)
# 倒着数
print(int_month[-2])
'''
'''
# 取片段
# 不含4
print(int_month[2:4])
# 如果取5不报错,因为不含5
print(int_month[2:5])
print(int_month[2:])
'''
|
3d99e9023c87bade8ce6d072039fe578751da521 | somarajukeerthiamulya/python | /day2.py | 1,154 | 3.875 | 4 | #prime with while
"""
n=int(input())
c=1
i=1
while(n>=i):
if(n%i==0):
c=c+1
i=i+1
if(c==2):
print("prime")
else:
print("not prime")
"""
#elif
"""
marks = int(input())
if(marks==100 and marks>=92):
print("grade a+")
elif(marks<=91 and marks>=82):
print("grade... |
5159a0e44dc8383a6d33e68e3800dcc869d70461 | kimjiwan0619/jiwan_gitHub | /ddd.py | 1,725 | 3.6875 | 4 | def ad_calc(text):
index_sub = int(text.find("-"))
index_add = int(text.find("+"))
while(True):
index_sub = int(text.find("-"))
index_add = int(text.find("+"))
if index_add>index_sub:
num1=int(text[:index_sub])
a =int(text.find('+',index_sub+1))
... |
cac52f68e490df8db71bbc1ba4b936c1f68d1ba2 | darrenvong/advent-of-code-2018 | /day1.py | 1,393 | 4.09375 | 4 | """
Solution for Day 1 of Advent of Code 2018.
Problem: Chronal Calibration
Part 1: What is the resulting frequency after all changes of frequency (from input file)
has been applied?
Part 2: What is the first frequency your device reaches twice?
For more details of what the problems were, go to https://adventofcode... |
111e9981ccb0703ddeae457950c61f7cffc0e09d | RahulChauhan1989/Machine-Learning-Tutorial | /PracticeArea/NaiveBayesClassifier.py | 1,421 | 3.765625 | 4 |
# Step 1 - Load data
import pandas as pd
data=pd.read_csv("Datasets/iphone_purchase_records.csv")
X=data.iloc[:,:-1].values
Y=data.iloc[:,3].values
# Step 2 - Convert Gender to number
from sklearn.preprocessing import LabelEncoder
labelEncoder_gender=LabelEncoder()
X[:,0]=labelEncoder_gender.fit_transform... |
311ff835b6c547ea857684c4f0f6e78aff539e15 | Jeffhyper/CSE | /Programmer.py | 633 | 3.734375 | 4 | class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def work(self):
print("%s goes to work" % self.name)
def grow(self):
print("%s grows up" % self.name)
class Employee(Person):
def __init__(self, name, age, job):
super(Employe... |
fcb05f39e5b52f6c046ad0df09b34c2010db1ce8 | Colin-Bradshaw/python3 | /Exercise7.py | 1,248 | 3.875 | 4 | from random import randint
for num in range(1500, 2701):
if num % 7 == 0 and num % 5 == 0:
print(num, end = ", " )
print()
print('Enter the temperature in C you would like to convert to F')
temp = int(input())
print(temp * (9/5) + 32)
rand = randint(1, 9)
guess = -1
while guess != rand:
... |
ff0ea0f931a3d955458e09148fa05de828f5cf32 | Mermaid-Liu/Python_training | /wzry.py | 1,028 | 4.09375 | 4 | # 简易王者荣耀
# 1.设计王者荣耀中的英雄类,每个英雄对象可以对其他英雄对象使用技能
# 2.英雄具备以下属性英雄名称,等级,血量和Q_hurt,W_hurt,E_hurt 三个伤害属性,表示各技能的伤害量
# 3.具备以下技能Q W E三个技能都需要一个敌方英雄作为参数,当敌方血量小于等于0时输出角色死亡
class Hero(object):
def __init__(self,name='',rank='',blood='',Q_hurt='',W_hurt='',E_hurt='' ):
self.name=name;
self.rank=rank;
self.b... |
ea36b0ca08a1bb7c8056b4f157aef8584b34569f | cathyxingchang/leetcode | /code/119_E_(118,119).py | 1,007 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 119_E_(118,119)
# Created by xc 13/03/2017
"""
完全和118一样的思路,只是最后把最后一层输出出去
归纳就算法有点冗余
"""
class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
if rowIndex == 0:
retu... |
701b75fb0ba1180382d833d357f740edcd3dbcd5 | cathyxingchang/leetcode | /code/38_E_Count and Say.py | 1,108 | 3.59375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 38_E_Count and Say
# Created by xc 28/03/2017
import copy
class Solution(object):
def countAndSay(self, n):
"""
:type n: int
:rtype: str
"""
if n == 1:
return "1"
last_list = [1]
for turns in range(2... |
bdff5499ac8fe1959d0c997b2a2958f9a647213c | cathyxingchang/leetcode | /code/14. Longest Common Prefix.py | 707 | 3.703125 | 4 | class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
if len(strs) == 0:
return ""
min_len = len(strs[0])
for str in strs:
min_len = min(min_len, len(str))
if min_len == 0:
... |
d7de35f734a2c917f06029acc33b3cde27d41f8f | cathyxingchang/leetcode | /code/153. Find Minimum in Rotated Sorted Array(M).py | 760 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 153. Find Minimum in Rotated Sorted Array(M)
# Created by xc 18/04/2017
"""
不会做 参考别人的算法
"""
class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) == 0:
return
... |
68c7bfac4e33a1847837c736aa3e0345606eb474 | cathyxingchang/leetcode | /code/wangyi_1.py | 490 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# wangyi_1
# Created by xc 25/03/2017
import sys
for line in sys.stdin:
str = line.split()
a = str[0]
result = int(a[0])
for index in range(1, len(a),2):
fuhao = a[index]
cur_num = int(a[index+1])
if fuhao == '+':
result... |
437407de38779674d1393f30525ad6ba0e8359b6 | cathyxingchang/leetcode | /code/1160. Find Words That Can Be Formed by Characters.py | 1,050 | 3.609375 | 4 | class Solution(object):
def countCharacters(self, words, chars):
"""
:type words: List[str]
:type chars: str
:rtype: int
"""
# 一个字母只能用一次
chars_dict = {}
for item in chars:
if item in chars_dict.keys():
chars_dict[item] += 1
... |
0d9cb9e400656e7bb1ef68b8712b2fdaadafddaf | cathyxingchang/leetcode | /code/43. Multiply Strings(M)_2.py | 2,928 | 4.03125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 43. Multiply Strings(M)
# Created by xc 12/04/2017
"""
大数乘法
可以简化,把小数的乘法(从0-9提前计算好)
Your runtime beats 3.39% of python submissions.
优化完好像速度更慢了....
"""
import copy
class Solution(object):
def multiply(self, num1, num2):
"""
:type n... |
8c3b64a37a405e9dc5031ab771ed2cc67b69a235 | cathyxingchang/leetcode | /code/171. Excel Sheet Column Number(E).py | 478 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 171. Excel Sheet Column Number(E)
# Created by xc 17/04/2017
"""
计算excel表格的数字 相当于是一个26进制
"""
class Solution(object):
def titleToNumber(self, s):
"""
:type s: str
:rtype: int
"""
result = 0
for item in s:
... |
eb5abdae2fddfbecb956e2c2f4845ad6e3690b25 | cathyxingchang/leetcode | /code/53. Maximum Subarray.py | 783 | 3.78125 | 4 | class Solution(object):
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# 需要单独考虑的是,如果全是负数的话,那么最小的那个是最大值
if len(nums) == 0:
return 0
max_num = max(nums)
if max_num < 0:
return max(nums)
max_sum = 0... |
795a539f68eb8a0db22d72134fb15d6c7d84e090 | cathyxingchang/leetcode | /code/96_M.py | 787 | 3.53125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 96_M
# Created by xc 23/03/2017
"""
题目要求:对于一组数据,可以生成多少个同分异构的二叉搜索树
f(0) = f(1) = 1
f(2) = f(1)(0) + f(0)f(1)
f(k) = f(k-1)f(0) + f(k-2)f(1) + ... + f(0)f(k-1)
f(n) = f(n-1)f(0) + f(n-2)f(1) + ... + f(0)f(n-1)
最终的结果是 C(2n,n)/(n+1)
"""
class Solu... |
1938ee51cdef47156c1693ee0f1af6b2bf7f5bde | cathyxingchang/leetcode | /code/728. Self Dividing Numbers_E.py | 809 | 3.78125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 728. Self Dividing Numbers_E
# Created by xc 30/11/2017
class Solution(object):
def selfDividingNumbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
result = []
for num in rang... |
ea6d6c5e0b869087280ebd3a9368825bbb9e53f2 | cathyxingchang/leetcode | /code/LinkList/21_E.py | 1,147 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 21_E
# Created by xc 16/03/2017
"""
合并两个有序的链表
"""
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def mergeTwoLists(self, l1, l2):
"""... |
a31aaf076982e785b506f3530c32f2a25cbb5232 | cathyxingchang/leetcode | /code/53_E.py | 1,433 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 53_E
# Created by xc 19/03/2017
"""
找到题目里面连续序列里最大的值
思路:
动态规划:
开始想的是,从前往后,以当前元素为结尾的最大值.
但是下一个元素因为是要跟上一个元素有联系的,这样的话,可能顺序就乱了.所以这样的顺序不对
因为题目要求是连续,而下一个状态无法知道是不是前一个元素被使用了
所以这个思路不对,再换个思路了.
改成从d[i]为,从第i的元素开始的最大值
为了保证顺序性,说明这个d[i]"必须必须必... |
02d02579cac475fb117ad23774b21b65fb5b5f0b | cathyxingchang/leetcode | /code/90. Subsets II (M).py | 926 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 90. Subsets II (M)
# Created by xc 11/04/2017
import itertools
class Solution(object):
def __init__(self):
self.result_map = {}
self.result = []
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[... |
fd8afb99d6db815ab7e9d037cd120161cc92cf55 | cathyxingchang/leetcode | /code/Backtracking/22_M.py | 1,148 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 22_M
# Created by xc 24/03/2017
"""
所有的括号
"""
import copy
class Solution(object):
def __init__(self):
self.result = []
def generateParenthesis(self, n):
"""
:type n: int
:rtype: List[str]
"""
if n == 0:
... |
1b3c99f95170208aad9d8bbd5e10fa5c09f23b80 | cathyxingchang/leetcode | /code/127. Word Ladder.py | 1,701 | 3.625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 127. Word Ladder
# Created by xing 2017/4/2
import copy
class Solution(object):
def __init__(self):
self.lists = []
def ladderLength(self, beginWord, endWord, wordList):
"""
:type beginWord: str
:type endWord: str
:type wo... |
f00a69d97ff29a2d7dd05fc50907057078ee673a | cathyxingchang/leetcode | /code/127_xingchang.py | 2,108 | 3.640625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# xingchang
# Created by yangchao 02/04/2017
import time
class Solution(object):
def __init__(self):
self.lists = []
def ladderLength(self, beginWord, endWord, wordList):
"""
:type beginWord: str
:type endWord: str
:type wor... |
0d4d145563a1af96d238c9395365a91325ad3ff4 | cathyxingchang/leetcode | /code/wangyi3_11.py | 867 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# wangyi_3
# Created by xc 25/03/2017
#coding = utf-8
import sys
import copy
if __name__ == "__main__":
# 读取第一行的n 一共要处理的工作数
n = int(sys.stdin.readline().strip())
m = 2
ans = 0
machine_time = []
for i in range(0,1):
# 读取一行
line = s... |
723be5a6a780c1a31366fc3e17fcaa7b6f23fbaf | cathyxingchang/leetcode | /code/Tree/101_E.py | 1,188 | 3.796875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 101_E
# Created by xc 19/03/2017
"""
判断一棵树是不是二叉镜像树
大概是这样的? 最开始,把一棵树拆成最优两个子树,然后同时进行
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class... |
ecc2c8f71cc5b48ece6b016c394a50f9ddd67d37 | cathyxingchang/leetcode | /code/127. Word Ladder_3.py | 2,196 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 127. Word Ladder
# Created by xing 2017/4/2
"""
随用随生成字典
39 / 39 test cases passed.
Status: Accepted
Runtime: 948 ms
"""
import time
class Solution(object):
def ladderLength(self, beginWord, endWord, wordList):
"""
:type beginWord: str
... |
7921b65d53e57572cf831c2a95ece3bc5b17b037 | cathyxingchang/leetcode | /code/406. Queue Reconstruction by Height.py | 2,453 | 3.890625 | 4 | """
思路 (h, k)中,h从大到小排序,从小到大排序
特别需要注意的地方时数组为[]的情况,提交的两次报错都是这个原因
"""
import numpy as np
class Solution(object):
def reconstructQueue_1(self, people):
"""
:type people: List[List[int]]
:rtype: List[List[int]]
"""
if len(people) == 0 or len(people) == 1:
re... |
a2f8ff3aa0bc642895abc51cc243ed2296ecfa0c | cathyxingchang/leetcode | /code/73_M.py | 968 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 73_M
# Created by xc 21/03/2017
import copy
class Solution(object):
def setZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
m = len(matrix)
... |
d758c9721d0dca662663abb11d8a558673dd36e4 | Yllcare/bootrain | /assignment_28.py | 1,186 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 8 19:04:28 2021
@author: illcare
"""
import pandas as pd
import numpy as np
#
print('''
Age : Discrete
Salary : Continuous ratio
Income : Continuous ratio
Customer type : Nominal, in some cases might be ordinal
Stock price : Con... |
7c1cbd0d318669ea8b5b71b6cca57a580dcb6fd8 | MoIzadloo/Dead-Gear | /modules/sqlite.py | 8,272 | 4.125 | 4 | import os
import sqlite3
class sqlite():
'''
###############################
This class will help you with sqlite3 lib
And automate many things for an easier user
Interface
dbName = the name of database file (str)
###############################
'''
def __in... |
4b96bf7819e791356cc376a2b830fe5a2956bdbd | rodrigopscampos/python-lp | /listas/ex1.py | 139 | 3.921875 | 4 | #Crie uma lista e preencha com os números de 1 a 10
lista = []
a = 1
while a <= 10:
lista.append(a)
print(lista)
a = a + 1
|
7df2210b6377905d51b920f6b054ba8d9ee0278f | rodrigopscampos/python-lp | /ifs/ex4.py | 210 | 3.953125 | 4 | #Leia um número, se < 10, criança, se < 18 adolescente, se não, adulto
a = int(input('Informe uma idade: '))
if a < 10:
print('Criança')
elif a < 18:
print('Adolescente')
else:
print('Adulto') |
d0ce49ffccd59b642e3ed9e2be8ac36342e51a41 | rodrigopscampos/python-lp | /variaveis/ex4.py | 210 | 3.71875 | 4 | #Leia três números, some e imprima o resultado
a = int(input("Primeiro número: "))
b = int(input("Segundo número: "))
c = int(input("Terceiro número: "))
r = a + b + c
print('A somatória é: ' + str(r)) |
cb55ae9fb2a81e80fe336ef08b65425404e32d25 | rodrigopscampos/python-lp | /metodos/respostas.py | 931 | 4.03125 | 4 | #Implemente um método input_int(),
# que lê uma linha do console e converte o valor para int
def input_int(texto):
r = input(texto)
return int(r)
#Implemente um método e_positivo que recebe um número
# e diz se é positivo ou não.
def e_positivo(n):
return n >= 0
#Implemente um método somar, que soma t... |
9c628e42e25604b7a1a839a4e688c1c4d7446d1d | wy89050/numpy_test | /p88.py | 117 | 3.546875 | 4 | #從數值範圍建立陣列
import numpy as np
a = np.arange(12)
print(a)
a = np.arange(12).reshape(4,3)
print(a) |
216933cb5b6467d8abb6e6c390e2144ffcd9d7d7 | almachay-lpsr/class-samples | /guap.py | 736 | 4 | 4 | # for every roll of paper towel, you get a $0.25 rebate
# but if you buy more than 10 rolls, you get $0.35 rebate for each one
# but if you're a value club member,
# you get $2 rebate for buying at least one
# finf out if user is a value club member
print("Are you a value club member? Respond yes or no.")
club = raw... |
b484dc7020e2c4474ab73c2283728b62c2e85a84 | almachay-lpsr/class-samples | /6-3 CaesarCipher/applyCipher.py | 979 | 3.953125 | 4 | # applyCipher.py
# A program to encrypy/decrypt user text using Caesar's Cipher
#
# Author: rc.chayjocol.alma [at] leadsps.org
# makes a mapping of encoded alphabet to decode alphabet
# argument: key
# returns: dictionary of mappped letters
def createDictionary():
# placeholder
return{}
# gets the encr... |
da5dab16f7ebb3a28d7cc47584ff9f7c8e68cf37 | almachay-lpsr/class-samples | /numberer.py | 127 | 3.625 | 4 | num = 1
# print the numbers from 1 to 10 on seperates lines
while num <= 10:
print(str(num) + " missisippi")
num = num +1
|
e6d28fd8daf188407c96e6b0c0f6a9c21fad3a65 | HossamEmam95/Network_Project | /programming_assignment_1/generator.py | 903 | 3.546875 | 4 | def xor (m,n):
result = []
for i in range(1,len(n)):
if m[i] == n[i]:
result.append('0')
else:
result.append('1')
return ''.join(result)
def division(data,divisor):
""" Modulo 2 Division to get reminder """
size = len(divisor)
y = data[:size]
while... |
c9fee72e79b93ffb1c3f33662645b7803946cf29 | Ahmed-Hussein-Abdelwahed/sorting-algorithms | /count_sort.py | 728 | 4.0625 | 4 | def count_sort(arr):
# complexity : O(n + k)
# is not in place algorithm
# is stable algorithm
# can not be used for sorting negative numbers
# used only for sorting positive integer numbers
# need huge space
max_element = max(arr)
sorted_elements = [0] * (max_element + 1)
... |
334920f67ac6cafe8e47cfcff0d6859d4307c05f | NAKSEC/finance_book | /fin_scrapy/maya/string_utils.py | 625 | 3.515625 | 4 | import re
def is_year_by_regex(string):
regex_pattern = "(19|20)\d{2}"
result = re.match(regex_pattern, string)
return result
def remove_empty_key_value_from_dictionary(dictionary_of_strings):
new_dictionary = {}
regex = re.compile(r'[\(*\)\n\r\t]')
for elem in list(dictionary_of_strings.keys(... |
32ba50899ee8bf8a1d80cfaa2a518cb0397537e7 | Aryan021/honeybot | /honeybot/plugins/riddle.py | 2,475 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
[riddle.py]
Riddle Plugin
[Author]
Angelo Giacco
[About]
Returns a riddle
[Commands]
>>> .riddle
returns a random riddle
"""
import random
class Plugin:
def __init__(self):
pass
def riddle(self):
riddles = [
'The more you have of it, the less you see.... |
1423d12d368b5f3c3b624bbf774de35cd0c69d75 | edwinoo8/Hamon-Interview-test | /isprime.py | 204 | 3.875 | 4 | import math
def isprime(n):
if n%2 == 0 or n%3 == 0 or n%5==0:
return False
for i in range(7, math.floor(math.sqrt(n)), 2):
if n%i == 0:
return False
return True
|
4c433c7b5a878c1c64bda318ff2a6abdc8d8c5f5 | miami-mars/programming_problems | /project_euler/ex_5.py | 347 | 4.0625 | 4 | def smallest_multiple_n(n):
counter = n
number_found = False
while not number_found:
for i in range(2, n + 1):
if counter % i != 0:
counter += 1
break
if i == n:
number_found = True
return counter
if __name__ == '__main__':
pri... |
de28550f159dad2a4d896c5ab6b22cff491dce90 | kolotev/python-pmc-ctxdecoextended | /src/pmc/ctxdecoextended/core.py | 3,013 | 3.671875 | 4 | from contextlib import ContextDecorator, AbstractContextManager
from typing import Callable
class ContextDecoratorExtended(ContextDecorator, AbstractContextManager):
"""
This class is an extension of a contextlib.ContextDecorator
(enables a context manager to also be used as a decorator)
that adds an ... |
3441b7a8791fb60f3bad52c68f2f08295f29dae2 | BryanPozo-cmd/Phyton | /while2.py | 210 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 15:24:27 2021
@author: pc
"""
x=input('Ingrese el numero que contare:')
x=int(x)
y=1
while True:
print(y)
y+=1
if y>x:
break |
9aaeba17fb0478f95e265625eb331d25ca5b8263 | MKhanGit/Perceptron-API-Cancer-Cell-Classifier | /api/neural_network.py | 7,361 | 3.546875 | 4 | import numpy
from scipy import special
class NeuralNetwork:
def __init__(self, input_nodes, hidden_nodes, output_nodes, learning_rate):
"""
Constructs a shallow perceptron network with randomized weights using the provided parameters.
:param input_nodes: Number of input nodes in the netwo... |
06cdd3a37617bef549c811491ddaacf6a4bef8cc | mariial1/pythonProject | /test.py | 4,112 | 3.859375 | 4 | # 1)Дан лист:
# list = [22, 3, 5, 2, 8, 2, -23, 8, 23, 5]
# - найти min число в листе
# - удалить все одинаковые значения
# - заменить каждое четвертое значение на "Х"
# - вывести элемент листа, значение которого ближе всего
# к среднему арифметическому всех элементов этого же листа
# пример:
# [1, 2, 3, 4, 5, 6, 7, 8,... |
9c65b018d47f5712b4eb2a617b1035048bc44e32 | sivakothuru/python-practicing | /ex3.py | 1,016 | 4.34375 | 4 | print " I will now count my chickens:" # printing statement
print "Hens", 25.0 + 30.0 / 6.0 # mathematical operation doing addition and division
print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 # mathematical operation doing substraction, multiplication and modulation
print "now i will count ... |
0dd6b5133619e3bfca6ddd751c59ac20fb7e024d | sivakothuru/python-practicing | /ex29.py | 531 | 3.875 | 4 | people = 50
cats = 20
dogs = 30
if people < cats:
print "Too many cats. The world is doomed"
if people > cats:
print "Not many cats. The world is saved"
if people < dogs:
print "The world is drooled on!"
if people > dogs:
print "The world is dry!"
dogs +=5
if people >= dogs:
print "People are ... |
1217f44d9ff4c9891e1e680d434fe42d983c2e56 | prithuls/GRAD-778 | /Intro To Python/Course Materials/Module 3 - String Data/3_Strings.py | 2,705 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
String Data Examples and Operations
Intro to Python Workshop
"""
# String Data are immutable - that means we can't change them (can't change contents)
# We have to create a new string to make changes
# Working with string data - starting with an iconic southern Arizona peak
mount... |
e4c34d08f0e1b2f0e88d7c225fa79d73cfd7ff9e | prithuls/GRAD-778 | /Intro To Python/Course Materials/Module 4 - Integer and Float Data/4_Numeric.py | 2,015 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Working With Integer and Float Data
Intro to Python Workshop
"""
# Python does have some considerations with numeric data
# First, it works under the PEMDAS workflow
# Second, here are your operators
# +, -, *, /, **, %
# addition, subtraction, multiplication, division, exponent... |
8da4db00da420dad3e24695b9c79684f04123349 | DAVIDnHANG/TL-PythonAllProject-CS | /LCS%--Graphs/Joshuaadv.py | 2,833 | 3.5 | 4 | from room import Room
from player import Player
from world import World
import random
from ast import literal_eval
# Load world
world = World()
# You may uncomment the smaller graphs for development and testing purposes.
# map_file = "maps/test_line.txt"
# map_file = "maps/test_cross.txt"
# map_file = "maps/test_lo... |
64f226ddcd10bf37fb26bea6f635e8adaa30db92 | DAVIDnHANG/TL-PythonAllProject-CS | /LSC%--Challenge--Algorithms/Short-Answer/benjamin ON.py | 472 | 4.03125 | 4 | a) The runtime complexity is O(n). This is because a is equal to n * n, and the while loop only runs on a single additional * n
b) b) The runtime complexity is O(n^2). This is because we enter a loop inside of a loop that are both n based. So we will have to run over n * n
c) c) The runtime complexity... |
53cdcfa40f86ac59424d78aac95741edb20a8295 | DAVIDnHANG/TL-PythonAllProject-CS | /LSC%--hash-tables/hashtables/ex1/ex1Tevvin.py | 1,763 | 3.828125 | 4 | def get_indices_of_item_weights(weights, length, limit):
"""
YOUR CODE HERE
"""
# Your code here
weight_table = {}
# create table with weight as key and index as value by mapping weight in 'weights'
for i in range(length):
weight = weights[i]
# this is to take ca... |
8b4675d80bf1c882a26de8acb586e962edb98ef0 | DAVIDnHANG/TL-PythonAllProject-CS | /LSC%--hash-tables/hashtables/ex4/ex4Joshua.py | 791 | 4.1875 | 4 | def has_negatives(a):
"""
YOUR CODE HERE
"""
# Your code here
dictionary = {}
result = []
#go over everything in the provided list, absolute value it and add
#to dictionary with a number, if the absolute value is already present
#increment the number
for num in a:
... |
4bbcd8224b0c1365ad0b9d80e8f340426ac84e92 | hpzhong/eclipse | /python/file.py | 281 | 3.6875 | 4 | '''
@author: zhonghuiping
'''
file = open("tmp.txt",'w')
file.write("Hello, World")
file.close()
try:
fn = raw_input("Enter file name:")
fo = open(fn, 'r')
for el in fo:
print el,
fo.close()
except IOError, e:
print "file open error:", e |
067bc5cebd4baade948e938c0136208cca4a1575 | morinlab/HotMAPS | /src/graph.py | 1,126 | 4.125 | 4 | def bfs(G, s):
"""Perform Breadth-first search.
Parameters
----------
G : dict
a graph with nodes as keys with values as a set of destination nodes
s : tuple
node to start BFS
Returns
-------
seen : set
set of seen nodes while using BFS
"""
seen = set([s... |
20f615df37f0649c81204c488b76d4b6fa025952 | akshaybogar/learning_python | /itertools/itertools_ex.py | 1,015 | 4.53125 | 5 | '''
This program shows examples of how to use itertools which is part of python
standard library
'''
import itertools
#Using cycle which is infinite
names = ['Kane', 'Virat', 'Steve', 'Root']
c = itertools.cycle(names)
print(next(c))
print(next(c))
print(next(c))
# Using count from itertools which is also infinite.
... |
62c93bcd7bbcd71cc327d3a9e3aa474305d68781 | akshaybogar/learning_python | /class_and_object/working_with_attributes.py | 779 | 3.9375 | 4 | class Colors():
def __init__(self):
self.red = 50
self.green = 75
self.blue = 100
# Called everytime when attributes are accessed
def __getattr__(self, attr):
if attr == 'rgbcolor':
return(self.red, self.green, self.blue)
else:
raise Attribute... |
09b3551b919ce57d322203372205bf60384b0f10 | hopeniitssaa/olimpiada9 | /olimp2.py | 143 | 3.53125 | 4 | n=int(input("Numarul total de alune: "))
p=n//3
r=n-(p*3)
print("Fiecarui purcel iau revenit", p ,"alune, iar Ritei i-au ramas", r ,"alune") |
f660c882e4257ef7d620c30e7b9637ee4a7fe7f9 | GDrAnimal123/Language-Translation | /helper.py | 1,533 | 3.765625 | 4 | import numpy as np
def get_data_nmt_dataset(path, start="", end=""):
# Open and read all the contents of the data-file.
with open(path, encoding="utf-8") as file:
return [start + line.lower().strip().split("\n")[0] + end for line in file]
def get_training_data(src, dest):
encoder_input_data = ... |
8b4cabc331c3d03b02128c95f488d298cb091b7f | Saravanakumar-TN-au5/bitcoin-price-notifier | /makeAPICall.py | 665 | 3.53125 | 4 | # requests module required to make API calls
import requests
def get_data(currency_code):
try:
# GET call to get data from API
response = requests.get('https://blockchain.info/ticker')
# Check if API call is successfull
if response.status_code == 200:
# Resultan... |
3f9b9b30bec2ab509f3e15a264ba053036064ecc | xpqz/aoc-17 | /day4.py | 757 | 3.515625 | 4 | class PhraseInvalidException(Exception):
pass
def read_data(filename="data/input4.data"):
with open(filename) as f:
return [l.split(" ") for l in f.read().splitlines()]
if __name__ == "__main__":
data = read_data()
count = 0
for l in data:
if len(set(l)) == len(l):
cou... |
0a86ec79d2d1e4d96730b623f9e4a39d02fec120 | xpqz/aoc-17 | /day17.py | 619 | 3.78125 | 4 |
def ins(circle, value, current, step):
c = (current + step) % len(circle) + 1
if c >= len(circle):
circle.append(value)
else:
circle.insert(c, value)
return c
if __name__ == "__main__":
circle = [0]
step = 356
current = 0
for value in range(1, 2018):
current ... |
013e72eec3cbdc223496cd921303b16f8bff3e44 | kamachisundaram/Python_Codes | /RandomPasswordGenerator/Password_Generator.py | 1,292 | 3.6875 | 4 | import string
import random
pw_size=int(input('Enter the size of the password required\n'))
def sumfind(l):
if len(l) <= 1:
return l[0]
return l[0]+sumfind(l[1:])
def roundingtheChars(s):
small_chars=round(s*0.7)
cap_chars=round(s*0.1)
numbers=round(s*0.1)
symbols=round(s*0.1)
retu... |
b861d879db2d6b58de1747e271b1939e35411be6 | stanislavkozlovski/python_exercises | /hackerrank/algorithms/warmup/staircase.py | 245 | 3.984375 | 4 | # https://www.hackerrank.com/challenges/staircase
print('\n'.join((' '*(n-i) + '#'*i) for i in range(1, int(input()) + 1)))
n = int(input())
for i in range(1, n+1):
spaces = ' ' * (n - i)
hashtags = '#' * i
print(spaces + hashtags) |
df9e38e4a79425f88ffa69ba26da573bc910b69f | stanislavkozlovski/python_exercises | /codeforces/round_410/mike_and_strings.py | 723 | 3.65625 | 4 | string_count = int(input())
strings = [input() for _ in range(string_count)]
min_count = float('inf')
for curr_str in strings:
round_count = 0
for str_to_change in strings:
if curr_str == str_to_change:
continue
curr_count = 0
max_count = len(str_to_change)
while st... |
e69a1fe1a2047f24413b58fef8e147f8358d0285 | stanislavkozlovski/python_exercises | /hackerrank/algorithms/graph_theory/savita_and_friends.py | 5,063 | 3.703125 | 4 | def floyd_warshall(graph, a, b):
"""
Find the closest path from each node to each other node
"""
for k in range(len(graph)):
for i in range(len(graph)):
for j in range(len(graph)):
# if (i == a and b == j) or (j == a and b == i):
# continue
... |
b07ea8169b538b93280ca340505e8c1ed1b48045 | stanislavkozlovski/python_exercises | /hackerrank/hourrank_18/1.py | 263 | 3.5 | 4 | """
5 3
2 5
7 10
2 9
"""
m, n = [int(p) for p in input().split()]
marbles = [False for _ in range(11)]
marbles[m] = True
for _ in range(n):
a, b = [int(p) for p in input().split()]
marbles[a], marbles[b] = marbles[b], marbles[a]
print(marbles.index(True)) |
3b648b66ace4b76d2edfa09af288d0e7eb8e98ad | stanislavkozlovski/python_exercises | /hackerrank/week_of_code_28/boat_trips.py | 470 | 4 | 4 | def check_trips(total_passengers_per_trip: int):
for passengers_count in (int(p) for p in input().split()):
if passengers_count > total_passengers_per_trip:
return False
return True
def main():
trip_count, boat_capacity, boat_count = [int(p) for p in input().split()]
total_passenge... |
eafdfecaaec104c75ea530621395c2da11808da4 | stanislavkozlovski/python_exercises | /util/get_string_subseq_palindromes.py | 1,736 | 3.59375 | 4 | """ This basically returns a list of all the palindromes from subsequences of a string"""
def get_palindromes_for_string(string: str):
if len(string) == 1:
return [string]
from pprint import pprint
def get_i_j(l:list):
len_l = len(l)
if len_l == 2:
return 0, 1
if ... |
66ac1481d0495132c1d1373f5be16921e19eb8f6 | stanislavkozlovski/python_exercises | /hackerrank/world_code_sprint_9/weighted_uniform_string.py | 547 | 3.671875 | 4 | from string import ascii_lowercase
string = input()
weight = [ascii_lowercase.index(a) + 1 for a in string]
last_weight = None
# print(weight)
mod = []
last_sum = 0
for w in weight:
if last_weight is None or w == last_weight:
mod.append(last_sum)
last_weight = w
last_sum += w
else:
... |
dbfd1793a7c69fe12a5dd0a7d93f09afd897890b | stanislavkozlovski/python_exercises | /hackerrank/algorithms/dynamic programming/stock_max.py | 1,525 | 3.625 | 4 | # https://www.hackerrank.com/challenges/stockmax
# get the index of the maximum number and the index of the maximum number after it
def get_max_and_next_max_idx(arr):
max_num, next_max = 0, 0
m_idx, nm_idx = -1, -1
for idx, num in enumerate(arr):
if num > max_num:
max_num = num
... |
916715beb0c71218281997cdcfa73854f9da9aef | stanislavkozlovski/python_exercises | /hackerrank/hourrank_13/sum_vs_xor.py | 123 | 3.625 | 4 | n = int(input())
unset_bits = 0
while n:
if (n & 1) == 0:
unset_bits += 1
n = n >> 1
print(1 << unset_bits) |
ba3a599bcbd6b2793a46e5d6509babf1c38a2cd5 | stanislavkozlovski/python_exercises | /8.Exam Preparation/medicine_size.py | 1,660 | 3.625 | 4 | import csv
INDEX_M_NAME = 0
INDEX_M_WIDTH = 1
INDEX_M_HEIGHT = 2
INDEX_M_DIAMETER = 3
"""
minimum dimension of A < minimum dimension of B &&
median dimension of A < median dimension of B &&
maximum dimension of A < maximum dimension of B
"""
try:
width = float(input())
height = float(input())
diameter =... |
c01f6e17c69871deadf6605b2c580a38356b09d1 | stanislavkozlovski/python_exercises | /9.Exam Preparation 2/anagram.py | 740 | 4.1875 | 4 | """
Given a path to a text file, whose contents are one word per line. Find the anagrams of a given word.
sample input:
./words.txt
horse
"""
from collections import Counter
def is_anagram(str1: str, str2: str):
return Counter(str1.lower()) == Counter(str2.lower())
try:
file_path = input()
word = input(... |
ba1dce31f1836d950c9c0f6f18fa87e271144358 | stanislavkozlovski/python_exercises | /hackerrank/simplified_chess_game.py | 14,442 | 3.59375 | 4 | from copy import deepcopy
from pprint import pprint
def derive_banned_positions(banned_x_y: set(), piece_type, piece, new_x, new_y) -> set():
"""
In the case where a piece has another piece in its way,
find the positions that piece is stopping us from getting to
Example:
Rook - X - Y - Rook - Z ... |
ad6655cad841200755d95caf479c125348b82910 | stanislavkozlovski/python_exercises | /hackerrank/hourrank_18/2.py | 464 | 3.796875 | 4 | def get_all_substrings(input_string):
length = len(input_string)
return [input_string[i:j+1] for i in range(length) for j in range(i,length+1)]
number = input()
count = 0
# print(get_all_substrings(number))
for substr in get_all_substrings(number):
count += 1 if ((int(substr) % 6) == 0 and substr[0] != '0') or... |
3ef4d52aa48995b6f663e22222787dd4365111d5 | stanislavkozlovski/python_exercises | /hackerrank/CodeAgon/fifth_problem.py | 1,008 | 3.5 | 4 | from collections import deque
GRAY, BLACK = 0, 1
def topological(graph):
order, enter, state = deque(), set(graph), {}
def dfs(node):
state[node] = GRAY
for k in graph.get(node, ()):
sk = state.get(k, None)
if sk == GRAY: raise ValueError("cycle")
if sk == ... |
69c5bb7f93c215f485da6eeafe9fb9a989432a78 | stanislavkozlovski/python_exercises | /random_interview_prep/topological_sort.py | 1,838 | 3.828125 | 4 | from collections import deque
graph = {
4: [0, 1],
2: [3],
5: [2, 0],
1: [], # add 4 here to create a cycle
3: [1],
0: []
}
other_graph = {
4: [3, 2],
3: [2, 1],
2: [1], # add 3 here to create a cycle
1: []
}
tp_sorted_nodes = []
visited = set()
visited_this_iter = set()
de... |
6b21c47c93731cfaec9d2d1cfd795ec9de86dfe6 | stanislavkozlovski/python_exercises | /hackerrank/algorithms/dynamic programming/longest_common_subsequence.py | 2,062 | 3.96875 | 4 | # https://www.hackerrank.com/challenges/dynamic-programming-classics-the-longest-common-subsequence
# construct the matrix
def build_matrix(arr, arr2):
"""
Returns the appropriate matrix for the solution of this problem
ex: arr1 = 'aba', arr2='arab'
0 0 a b a
0 0 0 0 0
a 0 0 0 0
r 0 0 0 0
... |
d0ad94ac8889839c587d832f6fac158081490b50 | stanislavkozlovski/python_exercises | /hackerrank/algorithms/implementation/bon_apetit.py | 354 | 3.71875 | 4 | # https://www.hackerrank.com/challenges/bon-appetit
_, k = [int(part) for part in input().split()]
items = [int(part) for part in input().split()]
anna_bill = (sum(items) // 2) - (items[k] // 2) # the amout anna should pay
charged_money = int(input())
if charged_money == anna_bill:
print('Bon Appetit')
else:
... |
3a0fc9ca3972e8dff31192d9750bd83e67cc1594 | antonlebedjko/Information-Extraction-of-Seminars | /tagging/taggers.py | 10,102 | 3.59375 | 4 | import re
def names_to_string(file):
names = ''
for ch in file:
names += ch
return names
#tagging the end of event times. If we want to tag all time appereances in the text, we should run our endTimeTagger before startTimeTagger, they deppend from each other
def end_time_tagger(email):
# conve... |
b07219f0eb0e3f4e5a3eac503f469f24754fc2bd | Prithamprince/Python-programming | /string56.py | 80 | 3.578125 | 4 | l=input().split(" ")
for i in l:
m=sorted(i)
print(*m,sep="",end=" ")
|
1aee406b412f312eff2aca637a01450bdcc8ed6e | Prithamprince/Python-programming | /number48.py | 119 | 3.625 | 4 | f=input()
if(f>=-2**15+1 and f<=2**15+1):
print("INT")
elif(f>=-2**31+1 and f<=2**31+1):
print("LONG")
|
978d54bc83911a55f2425af088296c8f2b9e57ff | Prithamprince/Python-programming | /number207.py | 128 | 3.65625 | 4 | l,m=input().split(" ")
n=input()
p=n.replace(m,"")
q=p.replace(" "," ")
if(len(q)<1):
print("empty")
else:
print(q)
|
6c6da3138fc09bae61abcd04b88dcb0aa48edd0e | Prithamprince/Python-programming | /prg43.py | 90 | 3.59375 | 4 | f,g=list(map(str,(input().split(" "))))
if g in f:
print("yes")
else:
print("no")
|
29b8f7d3af54ff4ccb52db020dedf60eb099b76c | Prithamprince/Python-programming | /string48.py | 187 | 3.65625 | 4 | d=input()
d=d.strip()
e=len(d)
flag=0
for i in range(2,e//2):
if(e%i==0):
print("no")
flag=1
break
if(flag==0):
print("yes")
|
d2a562966ea84a22a0d02a0a69b53c113cf00c49 | Prithamprince/Python-programming | /string60.py | 204 | 3.59375 | 4 | c=list(input())
d=""
e=""
for i in c:
if(i=="A" or i=="E" or i=="I" or i=="0" or i=="U" or i=="a" or i=="e" or i=="i" or i=="o" or i=="u"):
d+=i
else:
e+=i
d+=e
print(d)
|
46cef93bbeefb4f805983c350b7eb479ddaab377 | Prithamprince/Python-programming | /number44.py | 88 | 3.703125 | 4 | f=int(input())
if(f and(not f & (f-1))):
print("yes")
else:
print("no")
|
c9a0b54561a57c37bffdfcf1009d06e96bd8f8e3 | Prithamprince/Python-programming | /string9.py | 128 | 3.546875 | 4 | p=input()
p=list(p)
c=0
for i in p:
if(p.count(i)==2):
c=c+1
if(c==0):
print("Yes")
else:
print("No")
|
24be0d69a2db5e82cec870c0ddecbf46002cd295 | Prithamprince/Python-programming | /multiplication.py | 98 | 3.59375 | 4 | p=int(input())
l=[]
for i in range(1,6):
q=p*i
i=i+1
l.append(q)
print(*l,sep=" ")
|
8f95815380a3ca9369051c0d6b21149d3d6f95f2 | Prithamprince/Python-programming | /vowel2.py | 222 | 3.78125 | 4 | c=input()
d=0
for i in c:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
d=1
if(d==1):
print("yes")
else:
print("no")
|
eae889362dee2cf57324b12c08adfa705cd9cacd | Prithamprince/Python-programming | /string11.py | 90 | 3.625 | 4 | e=input()
l=[]
for i in e:
if(i.isnumeric()):
l.append(i)
print(*l,sep="")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.