blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
660e26aa73ddb6590f5760f4dcded81ff728fa9a
dyeeee/LeetCode_Q
/35_搜索插入位置.py
803
3.90625
4
# 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 # # 你可以假设数组中无重复元素。 # # 示例 1: # 输入: [1,3,5,6], 5 # 输出: 2 # 示例 2: # 输入: [1,3,5,6], 2 # 输出: 1 # 示例 3: # 输入: [1,3,5,6], 7 # 输出: 4 # 示例 4: # 输入: [1,3,5,6], 0 # 输出: 0 class Solution: def searchInsert(self, nums: [int], target: int) -> int: if target...
a332aa904f0297335e3baa296d3f48872978d912
gitttttt/lc
/q290.py
524
3.6875
4
def wordPattern(pattern, str): p = list(pattern) s = str.split(' ') sets = {} for x in list(zip(p, s)): print(x) if not sets.__contains__(x[0]): sets[x[0]] = x[1] elif sets[x[0]] != x[1] and sets: return False sets.clear() for x in list(zip(s, p)):...
515f7ed0741e9e3bc5136b14770fe2179d3e0f73
Leman-Y/2017_CS127_Labs
/08/happyladybugs.py
1,644
4.09375
4
''' Happy ladybugs x=2 y=10 c=10 #for i in range(x,y+1): # print(i) Input example: 4 7 RBY_YBR 6 X_Y__X 2 __ 6 B_RRBR if x<=c<=y: print(c) Notes 10/17/17: -This is how you see if a number is in a certain range -string,b, of length n. ith character bi, ith cell of board -If bi is underscore (_), then ith cell...
c1ccb55c53a37a2b04639d70566520b1ad9fafef
weak-head/leetcode
/leetcode/p0161_one_edit_distance.py
678
3.6875
4
def isOneEditDistance(s: str, t: str) -> bool: """ O(n) n - length of the string """ # for simplicity, we want 's' to be shorter than 't' if len(s) > len(t): s, t = t, s # length difference can't be more than 1 if len(t) - len(s) > 1: return False for i in range(len...
6209106aeb13adde1dd3427bdf500b351cd9cb13
Adikanatbek/python2
/problem8.py
165
3.71875
4
a=int(input('Введите число')) if a>=100 and a<100: print('3-x Zn') else: print ('Ne 3-x Zn') if a>0 and a%2==0: print ('4et') else: print ('Ne 4et')
5554b0a10dadbc5321e2c8764030ad401a6197ff
dawangbaixiaofu/py_project1
/shapener.py
4,019
3.5
4
# 在O(n log n)的时间内使用常数级空间复杂度对链表进行排序 from Leecode class ListNode: def __init__(self, x): self.val = x self.next = None class Interval: def __init__(self, start, end): self.start = start self.end = end class Solution: # 合并排序 def merge_sort_list(self, alist: list): ...
ad6c3b8019edb26953da0b538d8daa12c4f18706
aiifabbf/leetcode-memo
/162.py
478
3.515625
4
""" 找到array里极大值点的下标 挺简单的, :math:`O(n)` 扫描一遍。 """ from typing import * class Solution: def findPeakElement(self, nums: List[int]) -> int: nums = [float("-inf")] + nums + [float("-inf")] # 两边加个负无穷,省得烦 for i, v in enumerate(nums[1: -1], 1): if nums[i - 1] < v > nums[i + 1]: ...
7297c5d7c915efb50293c87158b8f43cf38159e1
johncornflake/dailyinterview
/imported-from-gmail/2020-07-16-validate-balanced-parentheses.py
1,044
4.15625
4
Hi, here's your problem today. This problem was recently asked by Uber: Imagine you are building a compiler. Before running any code, the compiler must check that the parentheses in the program are balanced. Every opening bracket must have a corresponding closing bracket. We can approximate this using strings. Giv...
c15183be247e36826a31cdfa18efc5a254c216a0
abhishekambastha/Drishti
/numpy-basics/declaration.py
459
3.75
4
# ndarray.ndim = the number of axes # ndarray.shape = size of the array # ndarray.size = total number of elements # ndarray.dtype = data type # ndarray.itemsize = the size of each element from numpy import * #creation a = arange(15).reshape(3,5) print a b = array([6,7,8]) c = zeros((3,5)) d = ones((2,3,4), dtype = i...
a2d13bdf3e235f5064628c4183924ebece6765f0
ai-times/infinitybook_python
/chap12_p240_code1.py
202
3.59375
4
import random a = random.randint(2,9) b = random.randint(2,9) dab = a * b n = int( input( "%d x %d = " % (a,b) ) ) if n==dab : print("맞췄습니다.") else : print("땡! 틀렸습니다.")
40984b063685b808c7d0911fd8cc57f803a47d34
kingds/project-euler
/python/solved/Problem_045.py
473
3.734375
4
# Find the next triagonal number after T-285 that is also pentagonal and hexagonal def triangular(n): return n*(n+1)//2 def is_pentagonal(n): return ((((24*n) + 1)**0.5 + 1) / 6).is_integer() def is_hexagonal(n): return (((8*n + 1)**0.5 + 1) / 4).is_integer() def main(): n = 286 while True: ...
f9d28f9cc285e04f2ee253b527b22c120f51efbe
eant/PDD-MJ-N-277
/Clase 3/lib_excel_leer.py
1,109
3.5
4
from openpyxl import load_workbook wb = load_workbook('tabla.xlsx') #sheet = wb['Hoja1'] #Método alternativo de captura de hoja sheets = wb.sheetnames sheet = wb[sheets[0]] #Capturar una columna entera columna = sheet['A'] for valor in columna: print(valor.value) #Capturo un fila entera fila = sheet[2] for v...
f3508a3f5eba51e0bd84d125f7c762d1d6db5161
Noxy3301/AtCoder
/AGC/agc046_a.py
129
3.703125
4
dir = int(input()) x = 360 ans = 0 while x != 0: if x < 360: x += 360 ans = ans + (x // dir) x = x % dir print(ans)
5c3b34a015b7ba62d52dc5f2a30cd04f91cad8fe
mgould1799/Intro-To-Python
/CSCI220/lab 5/Lab5 (1).py
6,783
3.953125
4
# Lab5.py # Name 1: Arianna Tolerton # Name 2: Meagan G. from graphics import * import math def cupConverter(): # Author: RoxAnn H. Stalvey, modified by Walter Pharr # Illustrates getting numeric input through graphics window winWidth = 300 winHeight = 200 win = GraphWin("Convert cups...
48c87e149c19b0693bfd2dc0e95251bcb7103753
chhsambo/python101
/get_digit.py
337
3.65625
4
# my phone number is 092 953375 # def get_digit(value): # i=0 # if type(value) is str: # for x in value: # x != None ? i + 1 # value = "my phone number is 092 953375" # for x in value: # if x == " ": # break # print(x) children = 0 salary = 1000 if children >= 1 else 800 p...
250b9478d11426349ec415a549acd8e79952652c
RuihanGao/16-811
/hw4/code/q1b.py
1,110
3.765625
4
import numpy as np import math import matplotlib.pyplot as plt def f(x): y = np.round(x,3) if y == 1.0: return 0 return np.power(x-1,1./3) def f_derivative(y): a = 3*np.power(y,2) return 1/a def euler(h,N): y = np.zeros(N+1) x = np.zeros(N+1) func = np.zeros(N+1) error = n...
fb8f5a77ec615cae38b0af88685c22a8f33b63ad
Dmitriy21092000/cource-work
/Копытов/2/задача 27.py
422
3.5
4
import numpy as np N = 4 M = 6 H = 3 A = np.random.randint(-10, 10, (N, M)) print("Матрица:" + str(A)) A_bool = A == H col_sum = np.sum(A_bool, axis=1) print("Строки в которых встречается значение: "+ str(H)) print(np.argwhere(col_sum).flatten()) print("Строки в которых нет значения: "+ str(H)) print...
51b5ee96317e31f549886a5ee7129790f4387065
rikuhidaka/syspro2019
/PrimeNumber.py
285
3.59375
4
Prime_number = [2] current = 3 judge = True while True: for num in Prime_number: if current%num == 0: judge = False if judge == True: Prime_number.append(current) if current > 10000: print(current) judge = True current+=1
c753e8d9f808691371c80a98e393426d0ad189a8
vonjyandriah/Maintenance-book
/GUI.py
1,551
3.53125
4
from tkinter import ttk import tkinter as tk import sqlite3 def connect(): conn = sqlite3.connect("entretient.sq3") cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS carburant( id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, now DATE, Lieu...
f9a527931816b1fe999136115c6b156ba296062f
HrithikRai/Bike-Sharing-Demand-Prediction
/Bike_Sharing_Prediction.py
6,500
3.671875
4
# Bike sharing demand prediction using hourly dataset # Importing necessary data processing libraries import pandas as pd import matplotlib.pyplot as plt import math import numpy as np # Loading Data data = pd.read_csv("hour.csv") bikes = data.copy() # Dropping the non essential features bikes.drop(['in...
8e77eabfc8121468428c62e2025d6b90c72f30b2
ArturSargsyans/Homework-sortGpa
/SortbyGpa.py
1,682
3.84375
4
class Student: def __init__(self, fullname = None, gpa = None): self.fullname = fullname self.gpa = gpa self.next = None class Class: list = [] def __init__(self): self.head = None Class.list.append(self) def setHead(self, student, gpa): ...
adb7da1095101e67a9a851a275d0e83f4a1e6b87
erin-koen/Hash-Tables
/resizing_hashtable/r_hashtables.py
4,650
3.734375
4
class LinkedPair: def __init__(self, key, value): self.key = key self.value = value self.next = None class HashTable: def __init__(self, capacity): self.capacity = capacity self.storage = [None] * capacity self.count = 0 def hash(string, max_index): # t...
d7a63471c977bab05dc9b844ce3619b069183812
Topsergey1/python_project_new
/scanerportov.py
676
3.75
4
"""" Сканер портов""" import socket print('Простейший сканер портов на Python') print(' ') host = input('Введите имя сайта или IP адрес:') print(' ') print('Ожидайте идес сканирование портов!') print('-----------------------------------------') for port in range(130, ): s = socket.socket() s.settimeout(1) ...
03680f63e449badc106b0e374f85c9b74b3a0639
batoulalkhatib/Facoders
/Python/week4-2.py
168
3.859375
4
print('Numbers from 1 to 10') x= 5 while True : y=float(input('Guess the number :')) if y==x : print('Great! You did it!') break else: continue
7c109c957956c80d6759b1dedaa2a4d8f2a68592
gtmkr1234/learn-python39
/learn-python39/string_basics/traverse_string.py
251
4.125
4
""" iterating over the string using for loop traversing """ # using iteration st = 'python programming' for ch in st: print(ch, end=' ') # using range function st = 'Python Programming' ln = len(st) for i in range(ln): print(st[i], end=' ')
adc9efc1ea08bba94a98ea171c40a183c540a9ea
akshirapov/automate-the-boring-stuff
/Projects/regex-version-of-strip/regex_version_of_strip.py
392
3.6875
4
#! python # regex_version_of_strip.py - Takes a string and does the same thing # as the strip() import re def like_strip(string, chars=''): regex_str = r'(\s)' if chars == '': regex_str = r'^(\s+)|(\s+)$' regex = re.compile(regex_str) return regex.sub(chars, string) text = ' \t\n Hello, ...
d8331d25ee4cabaac154758eecc22f15d3f030a4
athulmurali/OOD
/ExpressionEval.py
1,243
3.984375
4
# An infix expression based approach # Idea: Construct a tree to store the arithematic expression and evaluvate based on recursive infix eval # Use inheritance and concepts of interfaces and polymorphism to get value of a node. class Expression: def __init__(self,obj): self.obj = obj def ...
295d10b32c864786baa2456241007ba4c5a26a43
dev-arthur-g20r/how-to-code-together-using-python
/How to Code Together using Python/CLASS PYTHON/harshad.py
357
3.625
4
import os class HarshadNumber: def isHarshad(self,n): copy = n sum = 0 while (copy > 0): remainder = copy % 10 sum += remainder copy = copy // 10 if (n % sum == 0): print(n,"is Harshad.") else: print(n,"is not Harshad.") x = HarshadNumber() number = int(input("Number to check if Harshad: ")) x...
1952d1fae514b8c9eee5dfd46a8d0b5a5824071b
rzfeeser/2021-10-04-mycode
/iftest/condition01.py
1,176
4.375
4
#!/usr/bin/env python3` def main(): # grab a string.... then ensure it is all lowercase hostname = input("What is the hostname? ").lower() # test logic with the `if` statement # what to do if this statement is found to be true if hostname == "mtg": print("The hostname was fou...
34c723767b8e4632f1eadeeda4c0e7f1e6fa10f7
nguyenngochuy91/companyQuestions
/facebook/onsite/fractionToDecimal.py
2,008
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 30 20:47:50 2019 @author: huyn """ """ 166. Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses."""...
6cfeabe1e7c1ca240a7e16843ba3e575cf3c5cdc
Hlonela/ID-exercise
/Palidrome-odd/main.py
614
4.25
4
#TASK ONE: #input_numbers = input ("Please enter your integers: ") #Enter the integer #reserved = input_numbers [::-1] # reverse it #def reversed_version (*args): #if input_numbers == reserved: #If the reversed form is the same as the input #return True #else: #return False #p...
f505bb6a0e9a50beb74ff524bf1e4bbc4ea62eca
mindovermiles262/codecademy-python
/08 Practice Makes Perfect/10_censor.py
990
4.40625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 4 12:37:29 2017 @author: mindovermiles262 Write a function called censor that takes two strings, text and word, as input. It should return the text with the word you chose replaced with asterisks. For example: censor("this hack is wack hack", "hack") should return:...
f550a633a04e62f76591eceb2021411db667f1db
DamieOla/Team-Doudna
/Stage0_Morali_Shah_script.py
502
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: List = ["Name = Morali Shah", "email = shahmorali@gmail.com", "slackname = @morali", "biostack = Drug Development"] print (*List, sep = "\n") # In[ ]: def hammingDist(str1, str2): i = 0 count = 0 while(i < len(str1)): if...
3f964d2775cffa1bc89a2aed1442f83fab5499b3
Knutsrepos/Python_Games
/Tic_Tac_Toe.py
6,361
3.734375
4
""" Tic tac toe. Up to now only two player version. I am currently working on a one player version using Monte Carlo. """ import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random import numpy as np #Define some constants GRID_NUMBER=4 GRID_CELL_SIZE=500/GRID_NUMBER #Define some global varaiables that ...
b1ddecc1e186d6ded9ecf91de78a61c70cb3c3f3
williamfried/modelling-infectious-disease
/covid_flu/covid_flu/plotting.py
8,030
3.546875
4
"""Utilities for plotting. """ import numpy as np import matplotlib.pyplot as plt import tensorflow as tf from . import time_series, utils def plot_history(history, ax=None): """Plot a tensorflow history. """ if ax is None: ax = plt.gca() ax.plot(history.history['loss'], label='Training') ...
a8e58802717b1124fb7119638247183b9143f414
rafaelperazzo/programacao-web
/moodledata/vpl_data/95/usersdata/171/55580/submittedfiles/desvpad.py
489
3.765625
4
# -*- coding: utf-8 -*- import math #comece abaixo n=int(input('digite o numero de elementos da lista')) lista=[] soma=0 soma2=0 for i in range(1,n+1,1): valor=float(input('digite o valor:')) lista.append(valor) for i in range(0,len(lista),1): soma=soma+lista[i] media=soma/len(lista) for i in range(0,len(l...
f3d32fd7b6cf4c5709737cdfd1c752cff2b6edfb
longjiazhen/book_price_compare
/use_str.py
1,356
4.1875
4
def format_str(): """ 格式化字符串 """ name = '张三' print('欢迎您,%s' % name) # 整型,float类型 num = 12.33 print('您输入的数字是:%.4f' % num) num2 =54 print('您的编号是:%04d' % num2) t = (1, 2, 3, 5) print('您输入的元组是:%s' % str(t)) #print('您的姓名:%(name)s' % {'name': name}) print('您的姓名:%s' % name) ...
00edcd2bb0c5fc9f8e17572e7cb6ea12d7476604
hammer-spring/PyCharmProject
/pythion3 实例/11_获取最大值函数.py
261
3.71875
4
''' 使用max()方法求最大值: ''' N = int(input('输入需要对比大小数字的个数:\n')) num=[ int(input('请输入第 %d 个对比数字 \n'%(i)))for i in range(1,N+1)] print('您输入的数字为:',list(num)) print('最大值为: ',max(num))
869f1ccf1b1989a8077b2ea1e6041f65dfa9bef5
Aasthaengg/IBMdataset
/Python_codes/p03711/s820545220.py
107
3.53125
4
x, y = map(int, input().split()) group = 'acababaababa' print('Yes' if group[x-1] == group[y-1] else 'No')
52810a339f04250fac7f6cb5e1af09c0f676aa48
Bharathi-raja-pbr/Python-if-else-exercises-
/2b9.py
289
4.5
4
# to find the largest of three numbers n1=int(input("enter a number")) n2=int(input("enter a number")) n3=int(input("enter a number")) if n1>n2 and n1>n3 : print(f"{n1} is the largest") elif n2>n1 and n2>n3 : print(f"{n2} is the largest") else : print(f"{n3} is the largest")
8919d9061b9f4421e8c673a59ee4966b2fedddbc
Wang-Yann/LeetCodeMe
/python/_0501_1000/0857_minimum-cost-to-hire-k-workers.py
2,974
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rock Wayne # @Created : 2020-05-31 08:00:00 # @Last Modified : 2020-05-31 08:00:00 # @Mail : lostlorder@gmail.com # @Version : alpha-1.0 """ # 有 N 名工人。 第 i 名工人的工作质量为 quality[i] ,其最低期望工资为 wage[i] 。 # # 现在我们想雇佣 K 名工人组成一个工资组。在雇佣 一组 K...
64f07fae1c46d16573c885b7d7b6b32d2a8a4cc2
dawoodyang/YL_Integration
/Test/listTest.py
230
3.734375
4
strlist = [] strlist.append('11111') strlist.append('22222') strlist.append('33333') if '11111' in strlist: print('111111') else: print('Not Found in List') if len(strlist)>0 : print('LIST LEN:'+str(len(strlist)))
704a130f955abd237a6d3c39199e917548fe69b5
tuanthanh078/cs106a
/Assignment 6: BabyNames/babygraphics.py
5,938
4.0625
4
""" File: babygraphics.py --------------------- This program builds a powerful visualization of the data contained in the dictionary name_data. The dictionary is formed as {name : {year : rank}} """ import tkinter import babynames import babygraphicsgui as gui # Provided constants to load and draw the baby data FILE...
52a473d47cddbf45c19693abf1de04561a924a0f
OpenTaal/alphabetical-sort
/python/sort-nat.py
791
3.640625
4
#!/usr/bin/env python3 from locale import LC_ALL, setlocale from sys import argv from natsort import ns, natsorted if __name__ == '__main__': if len(argv) != 2: exit(0) words = [] with open(argv[1]) as input_file: for line in input_file: word = line[:-1] words.app...
a7a85d6e00272fef11d324511c39bdaa5b7da6c4
scidam/algos
/algorithms/sorting/mergesort.py
1,732
3.953125
4
__author__ = "Dmitry E. Kislov" __created__ = "15.10.2018" __email__ = "kislov@easydan.com" def combine(left, right): combined = [] left = left[::-1] right = right[::-1] while bool(right) and bool(left): el1 = left.pop() el2 = right.pop() if el1 < el2: combined.appe...
b367b2759bb1ea04cef211553a6938a0ba78735f
davidbethke/pythonVS01
/PythonGitHub Project/source/MainApp.py
405
3.578125
4
import MyFirstClass class MainApp(object): """description of class""" def __init__(self, *args, **kwargs): self.myList=['1','2','3'] self.myDict={} self.myDict['name']='Dave' self.myDict['age']='44' self.myClass=MyFirstClass.MyFirstClass('1','2','3',**self.myDict) def mai...
a9d27259437c09cca479cda43ff455cd00e4d0a4
Santaka1882/mintic2022
/arrays/insertar.py
175
3.5625
4
nombres = ["Antonio", "Johan", "Maria"] nombres.insert(0, "Guttag") print(nombres) nombres.insert(2, "Peter") print(nombres) nombres.insert(len(nombres)//2, 10) print(nombres)
c7324c9dc506608aab996521c1c2fd3b6239706d
xiaojkql/Algorithm-Data-Structure
/LeetCode/Stack/132.py
518
3.5
4
# 132 pattern class Solution(object): def find132pattern(self, nums): """ :type nums: List[int] :rtype: bool """ st = [] s3 = -float("inf") for num in nums[::-1]: # 逆序保证了i<j<k if num < s3: return True # 保证了st维护的是一个降序,要么...
53e731c13fcf0148ce04c2e048416c2b7d208d7a
LuluwahA/100daysofcode
/Day 38.py
245
4.25
4
car =["ford","volvo","BMW"] for x in car: print(x) car =["ford","volvo","BMW"] car.append("honda") print(car) car =["ford","volvo","BMW"] car.pop(0) print(car) car =["ford","volvo","BMW"] car.remove("volvo") print(car)
5a01a414e70e1e2fdcedbec310afdbea49022a08
AdamZhouSE/pythonHomework
/Code/CodeRecords/2118/60698/243245.py
150
3.578125
4
import math def test(): a = int(input()) if(a<=0): print(False) return b = math.log(a,3) print(b % 1==0) test()
1b8d2215589423ddc37cb7b54dfe920c1b4590de
AdeolaAdesina/Intro-to-Python
/4. Indentation/indent.py
125
3.640625
4
for i in range(5): x = i * 10 print(x) #Indentation is done either with four spaces or by pressing the tab key
a8af3b5ec0137e3609b55ea30e7a1b3e7d74ac1b
Trenchevski/internship
/python/ex10.py
541
3.8125
4
# Assigning variable with string value, using \t for tabbed formatting tabby_cat = "\tI'm tabbed in." # Assigning variable with string value, using \ for separating lines persian_cat = "I'm split\non a line." # The same but using double slash for output with \ backslash_cat = "I'm \\ a \\ cat." # Using three double-quo...
62f62cd86bf8f80b70f7213a2a31b7eb07a88f6e
MarcusMarcusMarcusss/Python_POD
/Exercise/2_Find_Odd_Or_Even.py
628
4.3125
4
#reading user inputs and check if the number is odd or even #find last digit from the user input & first digit #first digit import math #digits = (int)(math.log10(userInput)) #firstDigit ...
45796f1f6525d9cc1cfd7feb1f5d1e6af7422a45
eakarpov/mail.ru_python
/additional_tasks/task_4/task_4.py
1,143
3.90625
4
from math import sqrt class Point: def __init__(self, x, y): self._x = x self._y = y def __str__(self): return "Point(x: " + str(self._x) + ", y: " + str(self._y) + ")" def get_x(self): return self._x def get_y(self): return self._y def count_distance(point...
7e797c082e684e276a6712425cc93440eea85616
abid-salahi/Complexity-Dashboard
/src/model/analyzers/e2e_analysis/docker/generated_dockerfiles/Ha1ybOtKQpAvK8Mh18Ms/fibonacci.py
505
3.65625
4
import sys def calc_fib(n: int): if n == 0: return n previous = 1 previous_previous = 0 while n > 1: curr = previous + previous_previous previous_previous = previous previous = curr n -= 1 return previous def all_fib(limit: int): all_fibs = [] w...
9039b26179d87c66dd248654a11dc7120f3441ee
gwako94/RandomPasswordGenerator
/password.py
487
4.15625
4
import string import random special_characters = '#$%&!@*' #This will generate a string consist of all required characters passwrd = string.ascii_letters+string.digits+special_characters length = int(input("Enter the length of the password: ")) def generate_password(): password='' for c in range(length): ...
855cde141b4031b427677a268b0dcd67a6f37b97
gomtinQQ/algorithm-python
/baekjoon/stringPractice/10988.py
697
3.5625
4
''' 10988: 팰린드롬인지 확인하기 문제: 알파벳 소문자로만 이루어진 단어가 주어진다. 이때, 이 단어가 팰린드롬인지 아닌지 확인하는 프로그램을 작성하시오. 팰린드롬이란 앞으로 읽을 때와 거꾸로 읽을 때 똑같은 단어를 말한다. level, noon은 팰린드롬이고, baekjoon, online, judge는 팰린드롬이 아니다. 입력: 첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다. 출력: 첫째 줄에 팰린드롬이면 1, 아니면 0을 출력한다. ''' word = input() prin...
78ffc06cbd9dccb5da75a3808ff7f9e97e346f76
Keramas/Hexxorscii
/hexxorscii.py
800
4.46875
4
#!/usr/bin/env python #This program can be used to XOR hex values with another hex value, and then convert it from hex to ascii. hexList = [] while True: hexValue = raw_input("Enter a two byte hex value (format ex: 5A) or press ENTER to finish: ") if hexValue == '': break else: hexList.append(hexValue) prin...
1c23a204dec2fd6f888cbbe9b968e4ae72d4cfe9
virginiah894/python_codewars
/8KYU/remove_every_other.py
266
3.9375
4
def remove_every_other(my_list: list) -> list: """ This function removes every second element from the array. """ new_list = [] for i, k in enumerate(range(len(my_list))): if i % 2 == 0: new_list.append(my_list[i]) return new_list
98f7568964727b60255c33f570c7cd14fba6f930
ikumen/problems-solvers
/project-euler/solutions/004.py
1,568
4.0625
4
#!/usr/bin/env python ''' 004.py: https://projecteuler.net/problem=4 Largest palindrome product A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' import ...
331595ea7eda800f790bb13e1310b915c3b9396e
zhh666/CanToolAPP_CS
/1.py
214
3.5625
4
def MAX(vector): child_ = [] sum_ = 0 for i in vector: if i > 0: sum_ += i child_.append(i) return sum_,child_ if __name__ == '__main__': sum_,child_=MAX(vector = [1,2,3,4,-5,-34]) print(sum_)
bd9c021f7e59e2bef29e33b6e7f3a7db99f58015
935375572/git_learning
/08function/function_and_while.py
915
4.125
4
""" # 组合使用while循环 给用户打招呼 def get_formatted_nam(first_name, last_name): full_name = first_name +last_name return full_name while True: # 这是一个无限循环 print("告诉我你的姓名可以吗?") xing = input("姓是什么?") ming = input("名是什么?") formatted = get_formatted_nam(first_name="张", last_name="三") print("你好啊" + form...
887dd07171ca926e1b272ea8103d40560e2d6280
lenamax2355/pandas-compare
/pdcompare/helper.py
341
3.53125
4
from pandas import DataFrame def ccounts(series): """ This accepts a PD.Series object and returns a 2 column df showing Value_counts and the percent of total df['count','percent'] """ df = DataFrame([series.value_counts(), series.value_counts(normalize=True)]).T df.columns = ["count", "per...
684661cfa77eadfed3879e7e4d8aa8745c109d0c
NithyaSattu/Nithya_PythonTraining
/77_assgnmt.py
497
4.09375
4
""" 77. Remove duplicates elements of the list without using built in keywords and temporary list. """ def remove_duplicates(list1): list1.sort() i = len(list1)-1 while i > 0: if list1[i] == list1[i-1]: list1.pop(i) i = i-1 return list1 if __name__ == "__main__" : ...
b51c4a517cccf1cdc2f8553210c92b56fc0bd9fb
Aden-Q/LeetCode
/code/445.Add-Two-Numbers-II-v2.py
1,154
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: def reverseList(head): prev = None...
292792eaa996022fbac9b0e46e4c97289e11e687
136772/MyPython
/Mycode/learn/类的方法.py
1,056
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' @author:JaNG @email:136772@163.com ''' class Animal: def __init__(self,name): self.name = name hobbie = 'meat' @classmethod #类方法 只能通过 Animal.talk()不能访问实例变量 def talk(self): print('{} is talking ...'.format(self.hobbie)) @stati...
08964767d4b95014df8e9387040ce501a3888d31
imagineeeinc/Potion-TxT-1-Layer-Encrypter
/Potion TxT 1 layer Encrypt.py
2,364
3.84375
4
'''This can be used for hash table used encryption and remove all the letters for needed ones num = 1 let = 0 for x in range(len(endata)): let = let+num letter = endata[let] if letter == "H": encrydata = encrydata + "s" elif letter == "e": encrydata = encrydata + "V" el...
a3becdee648a7661b6a7c83a0a33bf881597de8f
qcymkxyc/JZoffer
/main/question13/my1.py
3,369
3.65625
4
#!/usr/bin/python3 # coding=utf-8 """ @Time : 18-10-13 上午10:53 @Author : qcymkxyc @Email : qcymkxyc@163.com @File : my1.py @Software: PyCharm """ def edge_check(matrix, current_coordinate): """边界检查 检查当前坐标是否合法(比如col小于0或者col大于matrix的col) :param matrix: tuple(row,col) 方格的行和列数,即row * ...
1a9d50ebff0f37a6ded4fba249625fd90ca7d94c
lianemeth/codeeval
/word_search.py3
1,799
3.609375
4
import sys MATRIX = [ ['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E'], ] def get_neighbours(matrix, pos): neighbours = [] # up if pos[0] - 1 >= 0: neighbours.append((pos[0]-1, pos[1])) # down if pos[0] + 1 < len(matrix): neighbours....
657f00c778bf03795ef5c61b9e7a5956cd8db25d
unclebae/Python3-tutorial
/07.string/countTest.py
163
3.671875
4
str="this is string example...wow!!!" sub='i' print("str.count('i') : ", str.count(sub)) sub='exam' print("str.count('exam', 10, 40) : ", str.count(sub, 10, 40))
3741fed7073deb18214f4d137ba9d552a5481d60
sayan1995/Linked-List-1
/problem2.py
2,219
3.65625
4
# coding=utf-8 ''' Using length of array and 2 passes: Time Complexity: O(L) //Length of list Space Complexity: O(1) Did this code successfully run on Leetcode : Yes Explanation : add an auxiliary "dummy" node, which points to the list head. The "dummy" node is used to simplify some corner cases such as a list with onl...
1f853b7ef5a118871105446b1a2d58b4a1fb94c3
eloyekunle/python_snippets
/sort/insertion_sort.py
1,271
4.25
4
# Naiive insertion sort def insertion_sort(nums_array): for i in range(1, len(nums_array)): # print(nums_array) j = 0 while j <= i and nums_array[i] > nums_array[j]: j += 1 temp = nums_array[i] for k in range(i - j): # print(nums_array) ...
e6c11fa2a51bb09b3938c0dd696a604ccc22ceba
ahtaum/workshop-python
/minggu-05/src/coba3.py
344
3.5
4
import math print (f'the value of pi is approximately {math.pi:.3f}.') table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} for name, phone in table.items(): print(f'{name:10} ==> {phone:10d}') # name:10 buat panjang kolom binatang = 'eels' print (f'My hovercraft is full of {binatang}.') print (f'My hovercraft is...
0d7d970c84891d20cdb25357140a1c2996f79ea3
AlenaVit/Python_learning
/binary.py
544
3.859375
4
# for i in range (386, 388): # print("{0:>2} in binary is {0:>08b}".format(i)) # for i in range (29): # print("{0:>2} in hex {0:>02x}".format(i)) # # # x = 0x20 # y = 0x0a # print(x) # print(y) # print(x * y) # for i in range(0,17): powers = [] for power in range (15, -1, -1): powers.append(2 ** power) ...
81c2ea3d953f748deb8785de32f5704171a24eda
stephenward21/Python-Classes-RPG
/class.rpg.py
3,557
3.65625
4
from Hero import Hero from Vampire import Vampire from Monster import Goblin from Monster import Dragon from random import randint from New_Character import New_Character print ("What is thy name, brave adventurer?") hero_name = raw_input("> ") the_hero = Hero(hero_name) monsters = [] monsters_fighting = int(raw_i...
10b47f847c5b4ac5367105260188eed7d1313072
JaydedCompanion/AcadiaCompSci
/Year 1 - Semester 1/Assignment #3/a3-11130100143996.py
2,388
3.515625
4
#a3-1113-100143996.py #By Juan Callejas #COMP 1113 X1 #Instructor: Darcy Benoit #PART 1 def grid (img): img = gridBuilder (img, 10, 10, black) #PART 2 def grid2 (img, size): img = gridBuilder (img, size, size, black) #PART 3 def grid3 (img, size, color): img = gridBuilder (img, size, size, color) #P...
45e8fc8fe383c1a5c86103a143b22002ff278645
rodpoblete/practice_python
/list_remove_duplicates.py
1,293
4.34375
4
"""Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. Extras: Write two different functions to do this - one using a loop and constructing a list, and another using sets. Go back and do Exercise 5 using sets, and writ...
31355a3e992199426b49d7281456216276873a63
jaruizes/adventofcode2020
/day11/python/main.py
5,515
3.5625
4
class Seat: def __init__(self, x, y, seat_type): self.x = x self.y = y self.seat_type = seat_type self.status = seat_type self.potential_status = seat_type self.last_status = seat_type def fill(self): self.potential_status = '#' def release(self): ...
c1c0cbaacb00cab1caca22e0625993ae9ddcee6f
sanjanajha2001/moreexercise
/QUE9.PY
229
3.59375
4
def is_harshad_number(a): n=a c=n sum=0 while n>0: sum+=n%10 n=n//10 if(c%sum==0): print("is harshad number") else: print("it is not a harshad number") is_harshad_number(17)
a129869a31e54ac5234aa9169a742b9eb4a60f2f
bthia/restpython
/arraymult.py
401
4.03125
4
num = [1, 3, 5] double = [x * 2 for x in num] print(double) # example 2 - text friends = ['Amo', 'Ben', 'Adrian', 'Charles', 'Ali', 'Danny'] start_with_a = [] for name in friends: if name.startswith('A'): start_with_a.append(name) print(start_with_a) friends = ['Amo', 'Ben', 'Adrian', 'Charles', 'Ali', 'Danny...
27cd51d70e148b5b7399f46b2a8f7ea653c4edc5
caiocrocha/COVID-19
/DockFlow_base/bounding_shape.py
9,006
3.765625
4
#!/usr/bin/env python # coding: utf8 ##################################################################### # ChemFlow - Computational Chemistry is great again # ##################################################################### # Author: cbouy - Cédric Bouysset # cbouysset@unice.fr # ...
20f0b609852c0c53b72d577428e048063f957025
DreamingDataScientist/Learnning_R_Python
/Python/Basic/Lab23.py
348
3.890625
4
list=[1,2,3,4,5,6,7,8,9,10] def average(list): # 함수를 완성해서 매개변수 list의 평균값을 return하도록 만들어 보세요. sum = 0 for tot in range(len(list)): sum += tot return sum/len(list) print(average(list)) #total = 0 # 1~50까지의 합 #for n in range(1, 51): # total += n # print(total)
c549a0179d70fa1733a931941e87d647046d3f1d
zhangruochi/leetcode
/1162/Solution.py
1,587
3.84375
4
""" Given an N x N grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized and return the distance. The distance used in this problem is the Manhattan distance: the distance between two cells (x0, y0) and (x1, y...
1d1780f87a41b14fb33500dc5423b0485345e5ec
SampleUser0001/Enum_inPython
/app/SampleEnum.py
561
3.640625
4
# -*- coding: utf-8 -*- from enum import Enum class SampleEnum(Enum): HOGE = ("HOGE",{ "key":"hoge", "hoge":"hogehoge" }) PIYO = ("PIYO",{ "key":"piyo", "piyo":"piyopiyo" }) def __init__(self, id, keys): self.id = id self.keys = keys # 変数名にvalueは使えない。 def getId(self): ...
08a0ca2fa4e330e71dad27400e05026776683d6d
developingAlex/jacow-validator
/src/jacowvalidator/docutils/authors.py
2,723
3.546875
4
import re NON_BREAKING_SPACE = '\u00A0' LINE_TERMINATOR_CHARS = ['\u000A', '\u000B', '\u000C', '\u000D', '\u0085', '\u2028', '\u2029', '\n', '\\n'] # line terminator chars respectively: # line feed, vertical tab, form feed, carriage return, # next line, line separator, paragraph separator def get_author_list(text): ...
0e21757099024c743ae3deb970b025139dbc5af7
marcus-crane/junkcode
/luhn.py
934
3.875
4
from functools import reduce def updateNonCheckDigits(index, num): if (index % 2 == 0): digit = num * 2 if len(str(digit)) >1: return (digit - 9) else: return digit else: return num def calculateChecksum(updatedDigits): nonChecksum = reduce(lambda x, y: x+y, updatedDigits) checksum...
859dc2b2fe9818124c81138c95fe65d6db3698f7
arshjn/ClimbingtheLeaderboard
/code.py
1,556
4.125
4
#!/bin/python3 import math import os import random import re import sys # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY ranked # 2. INTEGER_ARRAY player def insert(list, n): # Searching for the position for i in range(len(list...
be0ac7135f4430af1de9c95bd754acd1726dac74
jfkoehler/calcbook
/_build/jupyter_execute/intro/stats.py
5,424
4.40625
4
#!/usr/bin/env python # coding: utf-8 # # Probability and Statistics # # **OBJECTIVES** # # - Use Binomial Theorem to solve probability problems # - Use functions to model patterns in binomial triangle # - Use summation and product symbols # - Find mean and standard deviation of series # - Use Normal Distribution to...
6c23cb248d45d505f219c3c219b11967d9f7f052
madelinelyons/CrackingTheCodingInterview
/interviewChapter2.py
7,499
3.890625
4
class Node: def __init__(self, data): self.data = data self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext(self, newNext): self.next = newNext ...
e39a475c5045e2f5db97633c4fe860748d9a25e4
retibra/LRP_project
/NBA_draft.py
1,110
4.125
4
#NBA draft simulator available_players = ["Lebron","Durant","Kawhai","Westbrook","Harden","George","Butler","Griffin","Paul","Curry"] team_1 = [] team_2 = [] print "Welcome to the NBA draft" selections = 0 while selections < 3: print "Available players:" print available_players print "" A = raw_input("Team 1 ...
8a4db7329c1e0835ef87c9055a4433be1744020d
alexiosgkikas/DailyCoding
/codesPython/coding668.py
749
3.953125
4
""" Daily Coding Problem: Problem #668 [Easy] Good morning! Here's your coding interview problem for today. This problem was asked by Google. In linear algebra, a Toeplitz matrix is one in which the elements on any given diagonal from top left to bottom right are identical. Here is an example: 1 2 3 4 8 5 1 2 3 ...
e92984556d071bfcb47f984f3013e756801f37a8
sunliang5211/work
/language/python/class2.py
517
3.671875
4
class Calc: count = 0 def print(): print('I\'m sunliang') def printCalc(self,x): foo = lambda x:x*x print(foo(x)) Calc.count += 1 def printCount(self): print(Calc.count) print(Calc.count) a = Calc() a.printCalc(2) b = Calc() b.printCalc(3) print(Calc.coun...
c81ad73735d2d063a32a145953d0ad3de9c0f329
thunderfreak/PY4E
/ex3/ex3.1.py
180
3.890625
4
hrs= float(input('Enter Hours:')) rate= float(input('Enter Rate:')) rpay= hrs*rate if(hrs>40): xpay= 0.5*(hrs-40)*rate pay= rpay + xpay else: pay=rpay print('Pay:',pay)
44d6b5e4a36b14f17c60bb019354c8d3351c83f5
Uakh/Cadence
/cadence/cgl_filter.py
1,371
3.53125
4
#! /usr/bin/env python import csv def main(): with open('blocgame_nations.csv', 'rb') as csvfile_input: with open('filtered_nations.csv', 'w+b') as csvfile_output: nation_reader = csv.DictReader(csvfile_input) columns = nation_reader.fieldnames nation_writer = csv.DictW...
c0a3afb589e76bcc59cad3c42717641390ba5830
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/Week6/Weeek 6 Programming Assignment 3.py
716
4.53125
5
shift = 3 # defining the shift count encrypted_text = input() plain_text = "" for c in encrypted_text: # check if character is an uppercase letter if c.isupper(): # find the position in 0-25 c_unicode = ord(c) c_index = ord(c) - ord("A") # perform the negat...
89824ebdd2ea9f10110cf0ff568c2444160e7660
justintdavis99/hello_UTC
/helloworld.py
219
3.890625
4
print{"Hello World! Written by Justin"} print{"This is my first python code"} x=int(input('Enter an integer: ')) if x%2 ==0; print('') print('Even') else: print('') print('Odd') print('Done with conditional')
16368ba2d0f9fd5aabc1c858c795c2db7cb114b2
a625687551/Leetcode
/TargetOffer/jianzhioffer.py
30,279
3.6875
4
##本部分来自剑指offer ######################################################################## ## 第一章 例题 寻找单向链表的倒数第k个节点 ## ######################################################################## ## 使用双指针法,一个指针先移动k步,然后两个指针一起移动,先移动的到链表尾部的时候,后移动指向倒数第k个 # 双指针法在寻找次序等方面是很有用的方法见编程之美3.5 ## 生成最短摘要,(最小子列表) ...
c5041b7032dcc5b858b28c45e03ea3755bdb84a5
ciblois/Hello-Python
/3.Learn Python - Free Interactive Python Tutorial - Exercise.py
608
4.0625
4
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> #Exercise 3 >>> numbers = [] >>> strings = [] >>> names = ["John", "Eric", "Jessica"] >>> second_name = "Eric" >>> numbers.append(1) >>> ...
cab7df50aa42ca469ae82e458c7558ac3deaf90f
ArsenioMichael93/prework_questions
/python102.py
1,247
4.09375
4
# question 1 def hello_user(username): print("Hello " + username + "!") hello_user('username') #----------------------------------------------- # question 2 current_number = 0 while current_number < 100: current_number += 1 if current_number % 2 == 0: continue print(current_number) #-----...
401a88672799653d6ec7622503562ca9ade096c5
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/539 Minimum Time Difference.py
1,007
3.84375
4
#!/usr/bin/python3 """ Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. Example 1: Input: ["23:59","00:00"] Output: 1 Note: The number of time points in the given list is at least 2 and won't exceed 20000. The input time is ...