blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
b22fd594d50af06ad8b7d81d3d686a5e5e2b5cb3 | cristyjeus/Learn-Algorithms | /implementation/knight_of_kingdom.py | 543 | 3.640625 | 4 | def get_move_case(row, column):
steps = [(-2, -1), (-2, 1), (2, -1), (2, 1), (-1, 2), (1, 2), (-1, -2), (1, -2)]
case = 0
for step in steps:
next_row = row + step[0]
next_column = column + step[1]
if 1 <= next_row <= 8 and 1 <= next_column <= 8:
case += 1
return ca... |
d66bd67d697b9442fb06f66a57a5ec3d7e2302db | rcjosue/CoE-16x | /CoE 164 - Computing Platforms/MP1/MP1.py | 2,608 | 3.515625 | 4 | #Ryan Izach Josue, 2018-12231
def main():
global alphas
alphas = alpha(2)
validM = {'L', 'M', 'Q', 'H'} #turn into 2 dicts (v1, v2) with value = # of codewords
codewords = [ {'L':7 , 'M':10, 'Q':13, 'H':17} , {'L':10 , 'M':16, 'Q':22, 'H':28}]
ans = []
try:
T = int(input())
... |
9f6dd5a1540dfbcfb56e3ffb081bc1b3073b5a96 | rcjosue/CoE-16x | /CoE 161 - Introduction to Information and Complexity/A1.0 Frequency Counter/frequency_count_v1.py | 281 | 3.84375 | 4 | def frequency_count(input_string):
frequency = {}
for letter in input_string:
try:
frequency[letter] = frequency[letter] + 1
except KeyError:
frequency[letter] = 1
return frequency
print( frequency_count("CoE 161") )
|
d65bf11690f092441b994ba01e8a59e0db17d9fe | Nike0601/Codekata-Set2-Python | /prog11.py | 104 | 3.828125 | 4 | print("Enter base: ")
a=input()
print("Enter power: ")
b=input()
ans=a**b
print("a^b= "+str(ans))
|
c075959645d354f99c7fdb7da56aa7280b9d6c44 | spencerneveux/FacialRecognition | /detect_face.py | 1,070 | 3.90625 | 4 | #! /usr/bin/env python
import cv2
import sys
def find_face_image():
# image to analyze/Cascade for opencv to perform analysis
imagePath = "YourImagePath"
# You need to download this xml file. It's necessary for the program to run
cascPath = "/YourPath/haarcascade_frontalface_default.xml"
# Read the image an... |
d63b6cc8b8e6c68c88d49e7e22bde8e0a9961df5 | anthonypcersosimo/python_sql | /test_data/rankBy.py | 595 | 3.59375 | 4 | import pandas as pd
data = [['AAPL', "Consumer Discretionary", 12.88], ['TSLA', "Consumer Discretionary", 92.52], [
'NVDA', "Information Technology", 221.37], ['CSCO', "Information Technology", 631.47]]
df = pd.DataFrame(data, columns=['ticker', 'sector', 'price'])
# Create a column called Price_Rank and rank th... |
c1921819df5314ae27796b5b8795552a0b4e49bd | AbhiniveshP/DFS-3 | /MatchSticksToSquare.py | 2,127 | 3.578125 | 4 | '''
Solution:
1. First, check whether the total sum is divisible by 4, sort the array (reverse order).
2. For each sub-group, checking the base condition to be satisified, perform backtracking if the potential sum is
less than the target sum for that sub-group.
3. If the conditions for all 4 sub-groups aren't sa... |
8f0119aff3c1cee2de401d2772ce337cfa5d9b1c | pesobreiro/data-science-journal | /09-Software-Engineering-and-Reproducible-Research/sprint_challenge/acme_report.py | 1,213 | 3.59375 | 4 | from typing import List
from random import choice, triangular
from acme import Product
ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved']
NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???']
NAMES = [x + ' ' + y for x in ADJECTIVES for y in NOUNS]
def generate_products(n=30) -> List[Pro... |
77ac8d3f1e3cde63b09e4993a034bc60faa43dfa | dashrath-chauhan/codeforces-solutions | /41A.py | 129 | 3.828125 | 4 |
#run time: O(1)
word = input()
wrev = input()
if word[::-1] == wrev:
print('YES')
else:
print('NO')
|
0114e153e6afae807b958b0585158be6d96b245f | lymanmcbride/tech-academy-python-projects | /html_challenge/create_html.py | 2,439 | 3.734375 | 4 | import tkinter
from tkinter import *
import webbrowser #necessary for launching the browser
class ParentWindow(Frame):
def __init__(self, master, *args, **kwargs):
Frame.__init__(self, master, *args, **kwargs)
self.master = master
self.master.title('Check files')
self.master.minsi... |
d79703bad72deefc815809643c95f19956d50b96 | KqSMea8/PycharmProjects | /leetcode/venv/lib/python2.7/site-packages/pyutil/pykhtml/pykhtmlutil.py | 3,491 | 3.5 | 4 | import pykhtml
import re
from pykhtml.dom import DOMString
'''a util module for pykhtml'''
def getAttributeValue(elem, attrName):
'''
return the attribute value as a unicode string. The way provided by pykhtml
doesn't work if the attribute value is Chinese.
Parameters:
... |
586067e70fd61e32b9a5248a1566b9bae57aaa88 | Chief-Aathil/Python-Learning | /Basics/NumericalComputations.py | 246 | 3.921875 | 4 | print(1.5//1) #Removes the fractional part of result.
print (2**3) # 2 to the power 3
print(3/2) # division always returns a floating point number
a=1+2j # python has inbuilt support for complex numbers
b=3+4j
print(a+b) # 4+6j |
a66a337067859a1e65f4e7bf1282903e463fe7ee | ernestoalbarran/Rectillinearcrossingnumber | /geometricbasics.py | 5,108 | 3.671875 | 4 | #!/usr/bin/env python
from math import sqrt
from combinatorics import *
from datastructures import *
#funcion para decidir si
#la vuelta es al a izq (-1) o der (1)
#se usa para definir el tipo de orden de un conjunto de puntos dado.
def turn(p0,p1,p2):
t=((p2[0]-p0[0])*(p1[1]-p0[1]))-((p1[0]-p0[0])*(p2[1]-p0[1]))
... |
f3f0b5a537cac79055b391835bceb1c09bb66a4e | VidushiAgarwal/Movie-Ticket-Booking-System | /movie-ticket-booking-system.py | 17,467 | 3.59375 | 4 | from tkinter import * # This line is used to import the GUI interface
import pyqrcode
import png
from pyqrcode import QRCode
from tkinter.messagebox import * # This line of code is used for message box to appear
from twilio.rest import Client
import sqlite3 # Building and Importing the database
root=Tk() # Impor... |
6ac4e48de7f18a18fd1812e03655727f0eb90880 | iYassr/Automatetheboringstuff | /errorExample.py | 860 | 3.609375 | 4 | #! python
import traceback
import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
logging.debug('start of he program')
def factorial(n):
logging.debug('Start of factorial(%s)' % (n))
total = 1
for i in range(1,n + 1):
total *= i
... |
c4833922fe7c1493053cbf633a912ccfa0b24f70 | iYassr/Automatetheboringstuff | /PasswordLocker.py | 543 | 3.75 | 4 | #! python3
# PasswordLocker.py
import sys,pyperclip
import sys
if len(sys.argv) < 2:
print('Usage: python PasswordLocker.py [account] - copy account password')
sys.exit()
account = sys.argv[1] #first command line argument
PASSWORDS = {'email': 'KFADFSDFSDFASD',
'blog,': 'gdfgdf... |
38948cb3c0124a7730ad4bb477fb6db5a5214af6 | heygonzalocaira/Computer-Graphics | /src/Thresholding/plot_practice.py | 719 | 4.0625 | 4 | import matplotlib.pyplot as plt
# plot a line, implicitly creating a subplot(111)
plt.plot([1, 2, 3])
# now create a subplot which represents the top plot of a grid
# with 2 rows and 1 column. Since this subplot will overlap the
# first, the plot (and its axes) previously created, will be removed
plt.subplot(211)
plt.s... |
742ecea8c97e08e476b86cd4f5dcc38cab2bb947 | era153/pyhton | /her.py | 456 | 4.21875 | 4 | name=int(input("no days employee1 work"))
print("no days hour" , name)
name1=int(input("no of hour employee1 work in first day"))
print("no days hour" , name1)
name2=int(input("no days hour employee1 work in second day"))
print("no days hour" , name2)
name3=int(input("no hour employee1 work in third day"))
print("no da... |
1739e8add0778a93658fde5570c4fe972c12b0ec | Linkney/LeetCode | /SwordOffer/O09.py | 1,545 | 4.09375 | 4 | """
用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead
分别完成在队列尾部插入整数和在队列头部删除整数的功能。 ( 若队列中没有元素,deleteHead 操作返回 -1 )
示例 1:
输入:
["CQueue","appendTail","deleteHead","deleteHead"]
[[],[3],[],[]]
输出:[null,null,3,-1]
示例 2:
输入:
["CQueue","deleteHead","appendTail","appendTail","deleteHead","deleteHead"]
[[],[],[5],[2],[],[]]... |
9cb8f89c34398fac7ee7d01a90c67f776eb9c5f7 | Linkney/LeetCode | /SwordOffer/O27.py | 2,023 | 4.40625 | 4 | # Again 2020年11月12日17:08:14 二叉树
"""
请完成一个函数,输入一个二叉树,该函数输出它的镜像。
例如输入:
4
/ \
2 7
/ \ / \
1 3 6 9
镜像输出:
4
/ \
7 2
/ \ / \
9 6 3 1
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
sel... |
38a3cf9e0e117bdf9b605bea872fa91e6ef234b8 | Linkney/LeetCode | /SwordOffer/O32-II.py | 1,309 | 3.875 | 4 | """
从上到下按层打印二叉树,同一层的节点按从左到右的顺序打印,每一层打印到一行。
例如:
给定二叉树: [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回其层次遍历结果:
[
[3],
[9,20],
[15,7]
]
"""
# Definition for a binary tree node.
import collections
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
... |
59ecc6a1f8b87225ef8b8a59365a2bac1f293aa8 | Linkney/LeetCode | /SwordOffer-3/O04.py | 2,026 | 3.859375 | 4 | """
在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序
请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数
示例:
现有矩阵 matrix 如下:
[
[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]
]
给定 target = 5,返回 true。
给定 target = 20,返回 false。
"""
# 从左到右 递增
# 从上到下 递增
cl... |
e6e5ebeb12fa3fb2a199ca2eff6ed08acee9953a | Linkney/LeetCode | /SwordOffer-3/O11.py | 1,420 | 4.1875 | 4 | """
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。
输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。
例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一个旋转,该数组的最小值为1。
示例 1:
输入:[3,4,5,1,2]
输出:1
示例 2:
输入:[2,2,2,0,1]
输出:0
"""
class Solution:
# def minArray(self, numbers: List[int]) -> int:
# 寻找逆序对
def minArray(self, numbers):
for index in range(l... |
18b42aa3c505c566d905393bce4c031ce26320bc | Linkney/LeetCode | /SwordOffer/O26.py | 1,938 | 4.28125 | 4 | # Again 2020年11月11日11:12:00 二叉树匹配
"""
输入两棵二叉树A和B,判断B是不是A的子结构。(约定空树不是任意一个树的子结构)
B是A的子结构, 即 A中有出现和B相同的结构和节点值。
例如:
给定的树 A:
3
/ \
4 5
/ \
1 2
给定的树 B:
4
/
1
返回 true,因为 B 与 A 的一个子树拥有相同的结构和节点值
示例 1:
输入:A = [1,2,3], B = [3,1]
输出:false
示例 2:
输入:A = [3,4,5,1,2], B = [4,1]
输出:true
"""
# Definition ... |
d1d9ecf41295c1c5dba8781f3268085d3e006d3a | Linkney/LeetCode | /SwordOffer/O03.py | 1,649 | 3.921875 | 4 | """
找出数组中重复的数字。
在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,
但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。
示例 1:
输入:
[2, 3, 1, 0, 2, 5, 3]
输出:2 或 3
"""
# 1 暴力双循环 n^2
# 2 快排加一趟遍历 nlogn + n
class Solution:
# def findRepeatNumber(self, nums: List[int]) -> int:
def findRepeatNumber(self, nums):
nums... |
1be1e55b8f1f11dbe63327240d1383ba4409aa43 | Linkney/LeetCode | /SwordOffer-3/O64.py | 946 | 4 | 4 | # Again 2020年12月14日21:17:19 递归 + 逻辑短路
"""
求 1+2+...+n ,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
示例 1:
输入: n = 3
输出: 6
示例 2:
输入: n = 9
输出: 45
"""
# python的 and 操作如果最后结果为真,返回最后一个表达式的值,or 操作如果结果为真,返回第一个结果为真的表达式的值
class Solution:
def sumNums(self, n: int) -> int:
return n and (n + self.sumN... |
6dd308d15c9c25ad5976fc0d1a50931b06135c64 | Linkney/LeetCode | /SwordOffer/O55-I.py | 1,369 | 3.875 | 4 | # Again 2020年12月8日19:21:08 二叉树的深度
"""
输入一棵二叉树的根节点,求该树的深度
从根节点到叶节点依次经过的节点(含根、叶节点)形成树的一条路径,最长路径的长度为树的深度
例如:
给定二叉树 [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回它的最大深度 3
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = Non... |
e7e781d82b62d3ce743303897def57783215758c | Linkney/LeetCode | /LeetCodeAnswer/104.py | 1,032 | 3.875 | 4 | """
给定一个二叉树,找出其最大深度。
二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。
说明: 叶子节点是指没有子节点的节点。
示例:
给定二叉树 [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回它的最大深度 3 。
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
... |
f349772469610dc2e39640ba9a752ff65e8c4cdf | Linkney/LeetCode | /LeetCodeAnswer/39.py | 2,195 | 3.625 | 4 | """
给定一个无重复元素的数组 candidates 和一个目标数 target ,
找出 candidates 中所有可以使数字和为 target 的组合。
candidates 中的数字可以无限制重复被选取。
说明:
所有数字(包括 target)都是正整数。
解集不能包含重复的组合。
示例 1:
输入:candidates = [2,3,6,7], target = 7,
所求解集为:
[
[7],
[2,2,3]
]
示例 2:
输入:candidates = [2,3,5], target = 8,
所求解集为:
[
[2,2,2,2],
[2,3,3],
[3,5]
]
提示:
1 <= c... |
ff0d7fa126917f6e92c9fadb7a62a87c4ae99bf9 | Linkney/LeetCode | /LeetCodeAnswer/64.py | 1,406 | 3.71875 | 4 | """
给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。
说明:每次只能向下或者向右移动一步。
示例:
输入:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
输出: 7
解释: 因为路径 1→3→1→1→1 的总和最小。
"""
# def minPathSum(self, grid: List[List[int]]) -> int:
class Solution:
def pprint(self, grid):
for i in grid:
print(i)
print("----... |
784220b49e782551b03753e9bb1e3d37005c018a | Linkney/LeetCode | /SwordOffer-3/O05.py | 575 | 3.796875 | 4 | """
请实现一个函数,把字符串 s 中的每个空格替换成"%20"。
示例 1:
输入:s = "We are happy."
输出:"We%20are%20happy."
"""
class Solution:
# def replaceSpace(self, s: str) -> str:
def replaceSpace(self, s):
ans = ''
for item in s:
if item == ' ':
ans += "%20"
continue
... |
2f225f5209962861e74aa8b7dc57544936358ada | Linkney/LeetCode | /SwordOffer-3/O10-I.py | 1,174 | 3.671875 | 4 | """
写一个函数,输入 n ,求斐波那契(Fibonacci)数列的第 n 项。斐波那契数列的定义如下:
F(0) = 0, F(1) = 1
F(N) = F(N - 1) + F(N - 2), 其中 N > 1.
斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。
答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。
示例 1:
输入:n = 2
输出:1
示例 2:
输入:n = 5
输出:5
"""
# 递归
# 递推
class Solution:
def fib(self, n: int) -> int:
... |
8f0556954742e0c44b9ea585a25b7f5e09d92a3a | Linkney/LeetCode | /SwordOffer/O15.py | 1,432 | 3.75 | 4 | """
请实现一个函数,输入一个整数,输出该数二进制表示中 1 的个数
例如,把 9 表示成二进制是 1001,有 2 位是 1。因此,如果输入 9,则该函数输出 2
示例 1:
输入:00000000000000000000000000001011
输出:3
解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。
示例 2:
输入:00000000000000000000000010000000
输出:1
解释:输入的二进制串 00000000000000000000000010000000 中,共有一位为 '1'。
示例 3:
输入:111111111111111111... |
eca7785b77a960758c056350f08294fd6d987447 | Linkney/LeetCode | /LeetCodeAnswer/167.py | 1,008 | 3.875 | 4 | """
给定一个已按照升序排列的有序数组,找到两个数使得它们相加之和等于目标数。
函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。
说明:
返回的下标值(index1 和 index2)不是从零开始的。
你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。
示例:
输入: numbers = [2, 7, 11, 15], target = 9
输出: [1,2]
解释: 2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。
"""
# def twoSum(self, numbers: List[int], target... |
b986fc2d29a438a80f51b129419438e2477c10f1 | Linkney/LeetCode | /SwordOffer/O58-I.py | 1,371 | 4.0625 | 4 | """
输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变
为简单起见,标点符号和普通字母一样处理。例如输入字符串"I am a student. ",则输出"student. a am I"。
示例 1:
输入: "the sky is blue"
输出: "blue is sky the"
示例 2:
输入: " hello world! "
输出: "world! hello"
解释: 输入字符串可以在前面或者后面包含多余的空格,但是反转后的字符不能包括。
示例 3:
输入: "a good example"
输出: "example good a"
解释: 如果两个单词间有多余的空格,将反转后单词间... |
5136e60e11f872ee2e86bf22a90ad833a388962c | Linkney/LeetCode | /SwordOffer-3/O45.py | 1,359 | 3.9375 | 4 | # Again 2020年11月26日16:32:23
"""
输入一个非负整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个
示例 1:
输入: [10,2]
输出: "102"
示例 2:
输入: [3,30,34,5,9]
输出: "3033459"
"""
import functools
class Solution:
# def minNumber(self, nums: List[int]) -> str:
def minNumber(self, nums):
def sort_rule(x, y):
# 字符串的拼接
... |
db03e6f78b9d00381d5a99494591c51d37273f82 | Linkney/LeetCode | /LeetCodeAnswer/O11.py | 645 | 4.15625 | 4 | """
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。
输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。
例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一个旋转,该数组的最小值为1。
示例 1:
输入:[3,4,5,1,2]
输出:1
示例 2:
输入:[2,2,2,0,1]
输出:0
"""
# def minArray(self, numbers: List[int]) -> int:
class Solution:
def minArray(self, numbers):
# 憨傻题
for i in range(len(num... |
f814fff32b35f68a92d7d1725fdbe66b7f876de0 | yiruiduan/2018-07 | /2018-06/进程-线程-协程/生产者消费者模型.py | 553 | 3.515625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import threading,time,queue
q = queue.Queue(maxsize=10)
def Porducer():
count=1
while True:
q.put("骨头%s"%count)
print("生产了骨头",count)
count+=1
time.sleep(2)
def Consumer(name):
while True:
print("[%s] 取到 %s并且吃了它"%(name,q.g... |
57405c64df83e5dba32780494da1e061a66148db | cptx032/calcium | /calcium/draw.py | 2,605 | 3.890625 | 4 | # coding utf-8
import math, typing
# RECT
def rectangle(
width: int, height: int, color: int = 1, fill: bool = False
) -> typing.List[int]:
u"""Return a image with a nw-anchored rectangle.
Args:
width, height: controls the size of rectangle
color: 0 or 1
fill: controls the filling... |
876a8ecb9b40ff5820eb2670368b7bf76293abe6 | sroman98/AI_Project1_Linear_Regression | /linear_regression_life_expectancy.py | 2,311 | 3.828125 | 4 | # Sandra Román Rivera
# Dataset obtained from:
# https://www.kaggle.com/kumarajarshi/life-expectancy-who
import numpy as np
import math
import pandas as pd
from sklearn import linear_model
from sklearn.metrics import mean_squared_error, r2_score
# Load data
df = pd.read_csv('Life Expectancy Data.csv', usecols=["Year... |
32234486b9190af85d7f2e1f41e6f92ee87c414f | nathanbreitsch/Columns-And-Buckets | /data/parser.py | 2,692 | 3.578125 | 4 | import json
def make_csv():
file = open("transcript.txt","r")
text = file.read()
file.close()
#get rid of double newlines
#while "\n\n" in text:
# text = text.replace("\n\n", "\n")
text = text.replace("\n", ' ')
#remove all commas
for undesirable in [',','.',';','?', '-']:
... |
9bde6b3a6bb9695cd65748d06be9aa7b4946276b | vpris/passgen | /app.py | 445 | 3.515625 | 4 | import random, string
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--lenght", dest = "password_lenght", default = "16", help="Password length")
args = parser.parse_args()
password_characters = string.ascii_letters + string.digits
password = []
for i in range(int(args.password_leng... |
c3a89078ef56cd4a9a35f7e2a14d533200529e0a | dtdivyansh/Dynamic_Programming | /variable validation.py | 273 | 3.90625 | 4 | def check(var):
if( var[0].isdigit() ):
return False
for s in var[1:]:
if( s.isalpha() or s=='_' or s.isdigit() ):
continue
else:
return False
return True
var = input()
print( check(var) )
|
23ffe47b4ba72ef80a6b5b924d613d3fc9cc540d | dtdivyansh/Dynamic_Programming | /longestFiboSequence.py | 657 | 3.5 | 4 | def findFibo(arr,n):
val = []
m = 0
for i in range(n-2):
for j in range(i+1,n-1):
x = arr[i]
y = arr[j]
z = x+y
l=2
li = [x,y]
while(z in arr):
li.append(z)
x = y
y = ... |
192a8d174aa28a177c941ccd96389b34fb6e3862 | VasilisPitsiavas/Algorithms | /project_euler/ques.py | 515 | 3.859375 | 4 |
class stack:
def __init__(self):
self.stack = []
self.top = 0
def push(self, data):
self.stack.insert(self.top, data)
self.top += 1
def pop(self):
self.top -= 1
lastpoped = self.stack[self.top]
del self.stack[self.top]
return lastpoped
... |
1b3e84a4862a134767ddc134e0bcffd6c6d01d22 | gisturiz/Hash-Tables | /collisions.py | 1,201 | 3.609375 | 4 | import random
def how_many_before_collision(buckets, loops=1):
for i in range(loops):
tries = 0
tried = set()
while True:
random_key = str(random.random())
hash_index = hash(random_key) % buckets
if hash_index not in tried:
tried.add(hash_... |
2c81eec29d0b4743865bedcde501cff6eb104259 | iiagovictor/pratica-una-2021-02-uc-sistemas-distribuidos | /exercicios/estruturaSequencial/ex5.py | 132 | 3.515625 | 4 | metro = int(input('Informe um valor e metro (m): '))
centimetro = metro * 1000
print(metro,'m é equivalente a ',centimetro,'cm')
|
d79ffc14cdb1ad313dffd414de690920f522d0db | iiagovictor/pratica-una-2021-02-uc-sistemas-distribuidos | /exercicios/estruturaSequencial/ex10.py | 156 | 4 | 4 | celsius = float(input('Informe uma temperatura em C° (celsius): '))
fahrenheit = (celsius * 1.8) + 32
print(celsius,'C° equivale a ',fahrenheit,'F°.')
|
502e564da9bda4bc07947c0678819a6297c8682a | iiagovictor/pratica-una-2021-02-uc-sistemas-distribuidos | /exercicios/estruturaSequencial/ex9.py | 164 | 4.03125 | 4 | fahrenheit = int(input('Informe uma temperatura em F° (fahrenheit): '))
celsius = (5 * (fahrenheit - 32) / 9)
print(fahrenheit,'F° equivale a ',celsius,'C°.')
|
028e0b8062b708bfc4ed2a54fd9debcc057d2df2 | iiagovictor/pratica-una-2021-02-uc-sistemas-distribuidos | /exercicios/estruturaSequencial/ex3.py | 184 | 4 | 4 | numero1 = int(input('Informe um número: '))
numero2 = int(input('Informe outro número: '))
print('A soma dos números informados ',numero1,' e ',numero2,' é ',numero1 + numero2,'.') |
1504008a8d33a1bc1fcd9dcca04fcb05221e1eb6 | hiteshpindikanti/Coding_Questions | /DCP/DCP140.py | 950 | 4.125 | 4 | """
This problem was asked by Facebook.
Given an array of integers in which two elements appear exactly once and all other elements appear exactly twice, find the two elements that appear only once.
For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and 8. The order does not matter.
Follow-up: Can you... |
57506f5f93ed9328659d52cfc802de41f0ae402f | hiteshpindikanti/Coding_Questions | /recursion_codes.py | 1,745 | 3.6875 | 4 | def fib(index: int) -> int:
if index == 0:
return 0
if index == 1:
return 1
result = fib(index - 2) + fib(index - 1)
return result
def fib_list(index: int) -> list:
if index == 0:
return [0]
if index == 1:
return [0, 1]
lst = fib_list(index - 1)
lst.app... |
9484cc99d76ae1d45dced6765fb9d850210ed1bc | hiteshpindikanti/Coding_Questions | /DCP/DCP9.py | 1,348 | 4.21875 | 4 | """
This problem was asked by Airbnb.
Given a list of integers, write a function that returns the largest sum of non-adjacent numbers.
Numbers can be 0 or negative.
For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10,
since we pick 5 and 5.
Follow-up: Can you do this ... |
1f7e0f8e5af1f2f26af8d46cfdc55a235fed2168 | hiteshpindikanti/Coding_Questions | /DCP/DCP61.py | 512 | 4.25 | 4 | """
This problem was asked by Google.
Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y.
Do this faster than the naive method of repeated multiplication.
For example, pow(2, 10) should return 1024.
"""
def pow(base: int, power: int) -> int:
... |
fcedd0fd56b0b84c51738c5e1fff640a6d79ffd5 | hiteshpindikanti/Coding_Questions | /DCP/DCP46.py | 1,148 | 4.1875 | 4 | """
This problem was asked by Amazon.
Given a string, find the longest palindromic contiguous substring. If there are more than one with the maximum length, return any one.
For example, the longest palindromic substring of "aabcdcb" is "bcdcb". The longest palindromic substring of "bananas" is "anana".
"""
from copy ... |
890055af08088ea6a059a404b41f58f5a858cd0c | hiteshpindikanti/Coding_Questions | /DCP/DCP102.py | 684 | 4.125 | 4 | """
This problem was asked by Lyft.
Given a list of integers and a number K, return which contiguous elements of the list sum to K.
For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9.
"""
from queue import Queue
def get_sublist(l: list, k: int) -> list:
... |
7134e0ee6a87054c906298ed87461d2e0d7af0eb | hiteshpindikanti/Coding_Questions | /DCP/DCP99.py | 1,089 | 4.15625 | 4 | """
This problem was asked by Microsoft.
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4.
Your algorithm should run in O(n) complexity.
"""
de... |
97412ffe6d9d527dc39cb0fc85454726fb516c76 | hiteshpindikanti/Coding_Questions | /LeetCode/largest_rectangle_in_histogram.py | 1,802 | 4.03125 | 4 | def get_largest_rectangle_area(heights: list) -> float:
if len(heights) == 0:
return 0
elif len(heights) == 1:
return heights[0]
mid = len(heights) // 2
area1 = get_largest_rectangle_area(heights[:mid])
area2 = get_largest_rectangle_area(heights[mid + 1:])
area3 = get_largest_rec... |
06c109a746730300a19490289301893ee335f6e6 | hiteshpindikanti/Coding_Questions | /DCP/DCP90.py | 359 | 4.09375 | 4 | """
This question was asked by Google.
Given an integer n and a list of integers l, write a function that randomly generates a number from 0 to n-1 that isn't in l (uniform).
"""
import random
def generate_random(n: int, l: list) -> int:
return random.choice(tuple(set(range(n)).difference(set(l))))
l = [1, 3, ... |
eb9b1d8621fb6a95ead49b74b38f4d1dfaf7cd58 | hiteshpindikanti/Coding_Questions | /DCP/DCP112.py | 2,669 | 4.03125 | 4 | """
This problem was asked by Twitter.
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Assume that each node in the tree also has a pointer to its parent.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the... |
bbb2c9446144efe8ab3aa7d68004143eecf2b537 | hiteshpindikanti/Coding_Questions | /DCP/DCP138.py | 773 | 3.953125 | 4 | """
Find the minimum number of coins required to make n cents.
You can use standard American denominations, that is, 1¢, 5¢, 10¢, and 25¢.
For example, given n = 16, return 3 since we can make it with a 10¢, a 5¢, and a 1¢.
"""
from collections import defaultdict
DENOMINATIONS = [1, 5, 10, 25]
memo = defaultdict(lam... |
56fe3e955cecc18c2ce1fb1542cfe33b9847ad76 | hiteshpindikanti/Coding_Questions | /LeetCode/72.py | 1,567 | 4.125 | 4 | """
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.
You have the following three operations permitted on a word:
Insert a character
Delete a character
Replace a character
"""
import heapq
def edit_distance(word1: str, word2: str) -> int:
if len(word... |
073d48193e301f1b70c31dc08a65fe7e051797df | hiteshpindikanti/Coding_Questions | /LeetCode/first_missing_positive.py | 1,179 | 3.78125 | 4 |
def missing_number(nums: list) -> int:
print("input array = {}".format(nums))
extra_num = 0
# Remove unwanted numbers
i = 0
while i < len(nums):
if nums[i] < 0 or nums[i] > len(nums):
nums[i] = 0
i += 1
# Marks the index of available numbers
i = 0
while i <... |
793efcdcacb8e3d8865cfcca067fd02c52479fda | hiteshpindikanti/Coding_Questions | /DCP/DCP57.py | 1,263 | 4.15625 | 4 | """
This problem was asked by Amazon.
Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don't break across lines. Each line has to have the maximum possible amount of words. If there's no way to break the text up... |
881036ac893bc0c0e4887938a56b8af1aa7985b1 | ClaudiaSofia222/homework1 | /3 - Strings/8 - Text Wrap.py | 256 | 3.75 | 4 | def wrap(string, max_width):
r = len(string)/max_width
for e in range(r):
g = e*max_width
c = string[g:(g+max_width)]
print c
if r*max_width != len(string):
d = r*max_width
return string[d:]
|
5fbe55aa6abbfda4d1b19a09691d3de06cdc9d57 | rashedrion/python_Assingment_01 | /problem_02.py | 302 | 4.09375 | 4 | #Given a range of the first 10 numbers, Iterate from the start number to the end number, and In each iteration print the sum of the current number and previous number
sum = 0
for i in range(10):
print(i)
sum = sum + i
print('Sum of the current number and previous number is = ', sum)
|
e61320b628ccd54e89313a49dff234bf9e0d955b | justinembawomye/python-fun | /uppercase.py | 144 | 3.96875 | 4 | from cs50 import get_string
before = get_string('Before: ').upper()
print("After: ", end="")
for a in before:
print(a, end="")
print() |
0c03e2f41fce4059b7b56ba1433af5ad221e4c3b | justinembawomye/python-fun | /conditionals.py | 265 | 4.25 | 4 | conditional statements
x = 1
y = 5
if x < y:
print('x is less than y')
else:
print('x is not less than y')
# Else if
if x < y:
print('x is less than y')
elif x > y:
print('x is greater than y')
else:
print('x is equal to y')
|
6a3312ac9e8fc2b178e5239dfa977df5b9977b42 | sdi12/2-13778 | /1zad.py | 701 | 3.703125 | 4 | """Златно сечение:
ако c=a+b и
a:b=b:c, то казваме че имаме златно сечение"""
def golden_ratio(a,b):
r=(a+b)/a
r="%.1f" % (r)
r=float(r)
t=(a+b)/b
t="%.1f" % (t)
t=float(t)
z=a/b
z="%.1f" % (z)
z=float(z)
u=b/a
u="%.1f" % (u)
u=float(u)
if a>b:
... |
29b6f51d1dd62688c8f42488c4134b6a7b7b94f3 | WilliamMass/Voting-App | /client_608_Final.py | 604 | 3.59375 | 4 | # Import socket module
import socket
import sys
# Create a socket object
s = socket.socket()
# Define the port on which you want to connect
port = 4444
# connect to the server on local computer
s.connect(('10.0.0.175', port))
print("You are now connected to your classroom server. Just type yes or no into your input... |
b2e4f714b5309331cf1be2e1c3acc9827f1edb99 | INF1007-2021A/c03_ch4_exercices-NickLopz | /exercice.py | 1,570 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def is_even_len(string: str) -> bool:
total = len(string)
if total%2 == 0:
return True
def remove_third_char(string: str) -> str:
list1 = list(string)
del(list1[2])
string = ''.join(list1)
return string
def replace_char(string: str, old... |
c450950cca74c24d1c7bddb669d21cc7f563a71c | SteveClement/furigana | /furigana/__main__.py | 1,050 | 3.8125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# $ python -m hello
import sys
from furigana.furigana import split_furigana
def return_html(text):
output = ""
for pair in split_furigana(text):
if len(pair)==2:
kanji,hira = pair
output += "<ruby><rb>{0}</rb><rt>{1}</rt></ruby>".... |
650b781f2b2a04c6117706edc71b08cb63d87518 | PiotrWolski1000/random-walk-python | /lista3/lista3_zad4.py | 4,377 | 3.796875 | 4 | import matplotlib
import matplotlib.pyplot as plt
import random
def zad4(N = 10, h = 100):
height = h
differentHeights = []
for i in range(0, 10):#10, const, because we want values for several height values
allWalkerPaths = []
for i in range(1, N + 1):
... |
55e298de10bfdb7daf5768c8303fdea8d3a27e09 | sribeiro2020/multiples | /multiply.py | 208 | 4.09375 | 4 | number = input("Give me a whole number: ")
number = int(number)
lastNumber = number * 2
for number in range (1,11)
multiply number*2 +1
lastNumber = str(lastNumber)
print("Double that is " + lastNumber) |
6cc4272c0992e8e6acae20bac54236f147024781 | cabbagecabbagecabbage/NOTflappybird | /flappy bird raw code.py | 4,480 | 3.546875 | 4 | from pygame import *
from random import randint
init()
screen = display.set_mode((800,600))
score = 0
ingame = 0
clock = time.Clock()
myfont = font.SysFont("Century Gothic", 30)
class bird:
def __init__(self, coor, size, jumping, jumpvelo, jumpacc):
self.coor = coor
self.size = size
... |
438915a655a2f31f85d67ebc9f53b829d648a203 | neeltron/Python-Programs | /mod.py | 90 | 3.921875 | 4 | x = int(input("Enter a num"))
y = int(input("Enter another num"))
print(-y*(x//y) + x)
|
16de159f7820071693722ad87c61b299e10bdd48 | neeltron/Python-Programs | /Lab4.py | 290 | 4.03125 | 4 | # Solutiuon to question number 1 Lab 4
num = int(input("Enter a number: "))
fact = 1
for nums in range(1, num+1):
fact = fact * nums
nums += 1
print(fact);
# Solution to question number 2 lab 4
num = int(input("Enter a number: "))
for nums in range(1, num):
|
cf2daeb46b278c9af6e152993fcee482155a9d0a | shuvrow/monopoly | /gameClasses.py | 3,249 | 3.609375 | 4 | #this class represents a deck of cards like surprize cards or punishment cards
class deck():
def __init__(self,cards):
self.cards=cards
self.discard=[]
def shuffle(self):
pass
#getting a card from the deck
def getCard(self):
if len(deck)==0:
... |
38756dda34cd09f97365275f21c4825db937bf70 | Vivek27951/decision-support-system | /calculation.py | 642 | 3.96875 | 4 | while(1):
print('enter 1st no.')
n1=int(input())
print('enter the operant, for example:+,-,*,/,**')
op=input()
print('enter the 2nd no.')
n2=int(input())
if n1==45 and op=='*' and n2==3:
print('555')
elif n1==56 and op=='+' and n2==9:
print('77')
elif n1==5... |
8c8df8c2dff90763c0ce093ce9be83306ebd04cd | MatthewResendez1996/CIS2348 | /hw11_27.py | 3,613 | 3.78125 | 4 | #Matthew James Resendez
#1431242
players = {}
mylist = []
def sortDictKeys():
mylist = sorted(players.keys())
return mylist
def outputRoster():
mylist = sortDictKeys()
print("ROSTER")
for i in mylist:
print("Jersey number: " + str(i)
+ ", Rating: " + str(players[i]))
... |
b4ccfbd4c56e70ec17c15878cc114c2f1461b0a1 | chiehli/LeetCode | /LongestSubstringNoRepeatingChar.py | 4,057 | 3.84375 | 4 | """
LeetCode 3. Longest Substring without Repeating Characters
Given a string, find the length of the longest substring without repeating
characters
Example 1:
Input: "abcabcbb"
Output: 3 ("abc")
Example 2:
Input: "pwwkew"
Output: 3 ("wke")
"""
class LongestSubstring(object):
def get_length(self, s):
... |
ab6cb30b82a77fdb8d5cc0069735433291dc7aaa | chiehli/LeetCode | /ReverseLinkedList.py | 2,801 | 3.921875 | 4 | """
LeetCode 206. Reverse Linked List
Reverse a singly linked list
"""
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
"""
@property
def val(self):
if not self:
return None
return self.val
@val.setter
def... |
0baa449e814fd50e615f043427820ef9d175379e | chiehli/LeetCode | /LexicographicalNumbers.py | 767 | 3.796875 | 4 | """
LeetCode 386. Lexicographical Numbers
Given an integer n, return 1 - n in lexicographical order
For example, given 13, return [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9]
"""
class LexicographicalNumbers(object):
def get_lexical_order(self, n):
# type n: int
# rtype: list[int]
# crea... |
95548ddd1eecb9f359b6d9ffb469c3635dd8cf8f | MertDemir1638/dsc_gazi_PG1926 | /4.odev.py | 470 | 3.859375 | 4 | sylr=[]
tek_sylr=[]
while True:
sayi = int(input('Sayı : '))
sylr.append(sayi)
if(int(sayi)%2!=0):
tek_sylr.append(sayi)
soru=input("Devam etmek istiyorsanız E yaziniz, Çıkmak istiyorsanız H yaziniz. ")
if soru=="e" or soru=="E":
continue
else:
print("Girdiğini... |
006bea4018aa98977a2720f167bb0c81ed724aca | 4dsolutions/School_of_Tomorrow | /ivm_tetra_edges.py | 3,962 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
See:
https://oeis.org/A007531
Number of contact points between equal spheres
arranged in a tetrahedron with n - 1 spheres
in each edge. - Ignacio Larrosa Cañestro, Jan 07 2013
https://oeis.org/A035006
Number of contact points between equal spheres
arranged in a hal... |
a71d622979053ae23aa850b27e66a6deec37d76b | mstrchf/OOP-With-Python | /student.py | 369 | 3.671875 | 4 | class Student:
school = 'Marina International School'
def __init__(self, name, age, grade):
self.student_name = name
self.student_age = age
self.student_grade = grade
def details(self):
'''gets details of student'''
return f'Name: {self.student_name:>6} \nAge: {self... |
00d03aac67266b79f5fb8c91a33f884ff63f14e4 | abrosen/advent | /11.py | 852 | 3.5625 | 4 | import re
test1 = "hijklmmz"
test2 = "abbceffg"
test3 = "abbegjk"
test = test1
pattern1 = r'[iol]'
pattern2 = r'(\w)\1\w*(\w)\2'
def increment(p):
p = list(p)
for i in range(len(p) - 1, -1, -1):
if p[i] == 'z':
p[i] = 'a'
else:
p[i] = chr(ord(p[i]) + 1)
... |
1bec2c55f061c3fd1f367ba492d0b580950583e3 | santosh1561995/python-practice | /python-variables.py | 429 | 4.125 | 4 | print("For the datatypes in python an variable declaration")
#in python data type will be calculated automtically no need to declare explicitly
#integer type
x=5
print(x)
#float
f=5.5
print(f)
#multiple assignment to variable
a=b=c=10
print(a,b,c)
#assign values in one line
a,b=1,"India"
print(a,b)
#Swapping t... |
3976865add64fdc3573075ca130dd1e7279da423 | tanishi/language-processing-100 | /04.py | 522 | 3.53125 | 4 |
def main():
s = "Hi He Lied Because Boron Could Not Oxidize Fluorine.\
New Nations Might Also Sign Peace Security Clause. Arthur King Can."
s = s.split()
d = {};
single = {1, 5, 6, 7, 8, 9, 15, 16, 19}
for element in s:
if s.index(element) + 1 in single:
d[element[:1]]... |
ba9e398371b0441a34647fa4ae6b510e59558504 | alexrwilson/PythonEuler | /problem20.py | 304 | 3.765625 | 4 | def factorial(number):
return reduce(lambda x, y: x * y, range(1, number + 1))
def sum_digits(number):
return reduce(lambda x, y: int(x) + int(y), iter(str(number)))
def sum_factorial_digits(number):
return sum_digits(factorial(number))
if __name__ == '__main__':
print sum_factorial_digits(100) |
69cba86251ad064401c15b3a52c496026f0e8d3a | aliensmart/in_python_algo_and_dat_structure | /Code_1_1.py | 738 | 4.46875 | 4 | print('Welcome to GPA calculator')
print('Please enter all your letter grades, one per line')
print('Enter a blank line to designate the end.')
#map from letter grade to point value
points = {
'A+':4.0,
'A':4.0,
'A-':3.67,
'B+':3.33,
'B':3.0,
'B-':2.67,
'C+':2.33,
'C':2.0,
'C':1.67... |
f1ed6049e1e0650b29b3aee2b60617188f81f17a | helioelias/CursoPython | /funcoes/funcional.py | 605 | 3.5 | 4 |
def soma(a, b):
return a + b
def sub(a, b):
return a - b
somar = soma
print(somar(3, 4))
def operacao_aritmetica(fn, op1, op2):
return fn(op1, op2)
resultado = operacao_aritmetica(soma, 13, 48)
print(resultado)
resultado = operacao_aritmetica(sub, 13, 48)
print(resultado)
def soma_parcial(a):
de... |
d5ef1977bc4bd1863dd140ea21ddc785c8ceb621 | soumenpasari-grokr/python-assignment | /src/question_6.py | 402 | 3.546875 | 4 | def get_special_nums(enum_var):
for curr_number in range(0,enum_var):
# checking for number 5
if(curr_number != 0):
if(curr_number % 5 == 0):
yield curr_number
elif(curr_number % 7 == 0):
yield curr_number
last_range = int(input('Enter the ran... |
de564bc1d1ca6a017ba6a453c6c6a16339126ff8 | soumenpasari-grokr/python-assignment | /src/question_4.py | 205 | 3.859375 | 4 | '''
question number 4
'''
def generate_3d_array(l):
last_list = []
for loop_count in range(0,l):
last_list.append([0 for i in range(0,3)])
return last_list
print(generate_3d_array(8)) |
d7a791d9afa05b8abb618851b3ca9cf8b2578e17 | CoderStellaJ/Game-Snap | /card.py | 1,895 | 3.671875 | 4 | from random import shuffle
import random
class Card:
def __init__(self, value, suit_type):
self.type = suit_type
self.value = value
def get_type(self):
return self.type
def get_value(self):
return self.value
def match_value(self, card):
if self.get_value() == ... |
979f936eb20d48b37e066f840b58c89c586939ce | Neonbird/spbu_py | /first_hw/1_1.py | 1,573 | 3.65625 | 4 | from string import ascii_uppercase
num_to_let = {}
num = 10
for lett in ascii_uppercase:
num_to_let[lett] = num
num += 1
let_to_num = {}
num = 10
for lett in ascii_uppercase:
let_to_num[num] = lett
num += 1
def base_to_ten(number, base):
number = list(number)
if base > 10:
for index,... |
fd9e0f66f5e149c252111fc35b2cdf7212ce667b | arthur900530/Discrect_mathematics | /permutation.py | 339 | 3.546875 | 4 | import copy
def perAlg(l):
fl = []
for i in range(len(l)+1):
for j in range(len(l)+1):
l2 = copy.deepcopy(l)
if l[i] == l[j]:
fl.append(l)
else:
l2[i] = l[j]
l2[j] = l[i]
fl.append(l2)
print(fl)
pe... |
a615e95b7e5399464f2be8815a826b18ff384d28 | arthur900530/Discrect_mathematics | /factor.py | 226 | 3.75 | 4 | def factorPrime(a):
f = []
n = 2
while a > 1:
if a % n == 0:
if n not in f:
f.append(n)
a /= n
else:
n += 1
return f
print(factorPrime(541))
|
43a00a1b2ffa62e5f0c5d21ef76bf5a19df574ae | JaneEvans/Useful-Python3-Codes | /uniquePrimeFactors.py | 424 | 3.9375 | 4 | import math
def primeDivisors(_n):
primeDiv = []
if _n <=3:
return [_n]
else:
d = 2
n = _n
while d <= int(math.sqrt(_n)+1):
if _n % d != 0:
d += 1
else:
while _n % d == 0:
_n //= d
primeDiv.append(d)
if _n != 1:
primeDiv.append(_n)
if _n == n:
primeDiv = [_n]
return prim... |
2b76e2edb1b06123977985567fafc5a54026741d | MuskanPaliwal/AI-Tic-Tac-Toe | /minimax/Player.py | 2,984 | 3.578125 | 4 | import random
class Human:
''' Class for Human player'''
def __init__(self,marker):
self.marker = marker
self.type = 'H'
def move(self, gameinstance):
while True:
m = input("Input position:")
try:
m = int(m)
except:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.