blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2eb9bd5d43d8f5d466620d1aa525d3a92107a85e | e8johan/adventofcode2019 | /2/2.py | 1,188 | 3.71875 | 4 | #/usr/bin/env python3
def processor(m):
pc = 0
while True:
if m[pc] == 1:
m[m[pc+3]] = m[m[pc+1]] + m[m[pc+2]]
elif m[pc] == 2:
m[m[pc+3]] = m[m[pc+1]] * m[m[pc+2]]
elif m[pc] == 99:
break
else:
assert False, "Invalid op code at %s... |
f667314db55ae41cf0bac1f881e3fe1b8c6f73cc | Grigorov999/SoftUni-Python | /Python_fundamentals/course_chapters_excercises/RegEx/EX09_3_Find Occurences in text.py | 166 | 3.859375 | 4 | import re
text = input().lower()
target_word = input().lower()
pattern = f"\\b{target_word}\\b"
matches = re.findall(pattern, text)
print(len(matches))
|
5da2845f9bca8a104478194e68ef3b69ab4426ef | coalastudy/python-datascrapping-code | /week4/stage1-2.py | 937 | 3.515625 | 4 |
people = {'korean': 380, 'american': 42, 'japanese': 15, 'german': 26, 'french': 7, 'chinese': 213, 'canadian': 11}
print(people.keys())
print(people.values())
print(people.items())
for p_item in people.items():
print('There are', p_item[1], p_item[0] + 's')
chnInfos = {'하트시그널2': {'hit': 20000, 'like': 3800}... |
234ceac2e5ea146e47aca95a83b2a88c2b7a9d6c | 9Brothers/Learn.Python | /11_if_elif_else.py | 355 | 3.9375 | 4 | # a = 1
# b = 1
# bol = b is a
# if a is 2 :
# a += 10
# print(a)
notas = [ 10, 9, 8 ,9 ,5, 10, 7 ]
for nota in notas :
if nota >= 9 :
print("Aluno nota {n} foi aprovado".format(n = nota))
elif nota >= 7 :
print("Aluno nota {n} está de recuperacão".format(n = nota))
else :
print("Aluno nota {n}... |
49d8efe5f23554002da731e6a159f2039feafd8e | edu-athensoft/stem1401python_student | /sj200116_python2/py200116/output_formatted_5.py | 714 | 4.03125 | 4 | """
positional arguments
"""
print("Hello {0}, your balance is {1:9.3f}".format("Adam",230.2346))
print("Hello {0}, your balance is {1:12.3f}".format("Adam",230.2346))
print("Hello {0}, your balance is {1:2.3f}".format("Adam",230.2346))
print("Hello {name}, your balance is {balance:9.3f}".format(name="Adam",balance=... |
ba6db30c4230ee8f37bb953d50cd7df7da014477 | Dgustavino/Python | /Taller_02/list&dict/dict.py | 788 | 4.125 | 4 | # un dictionario se define asi KEY:VALUE
elemento = '02'
dict_musica = {
'miKey': 1,
'key_2': elemento,
'key3': 3
}
# print the OBJ dict
print(dict_musica)
# print a dictionary key:value
for key in dict_musica:
print(key, dict_musica[k... |
451479f94015c60d010a5fb4224264f2ca274e8d | gadodia/Algorithms | /algorithms/LinkedList/swapNodes.py | 1,215 | 3.96875 | 4 | '''
Given a linked list, swap every two adjacent nodes and return its head.
You may not modify the values in the list's nodes, only nodes itself may be changed.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
Time: O(n)
Space: O(n)
'''
# Definition for singly-linked list.
class ListNode:
... |
d28a5d12cb82856473359351db56a433bde0c82a | sfwarnock/python_programming | /chapter 5/exercise 5.3.py | 873 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 2018
@author: Scott Warnock
"""
# exercise 5.3
#
# # A certain CS professor gives 100-point exams that are graded on the scale 90-100:A, 80-89:B, 70-79:C,
# 60-69:D, <60:F. Write a program that accepts an exam score as an input and prints out the
# ... |
a2eaee306d95c1b1c6ea9e80db7c131bc883323b | Deyber2000/holbertonschool-higher_level_programming | /0x0A-python-inheritance/0-lookup.py | 297 | 3.546875 | 4 | #!/usr/bin/python3
"""Module for lookup()"""
def lookup(obj):
"""Function that returns a list of available attributes
and methods of an object
Arguments:
obj: the object to list attributes of
Returns:
list: list of all attributes
"""
return (dir(obj))
|
77466fe07182b9a647989887f510309eff80f9f1 | imarban/algorithms | /python/algorithms/search_2d/search.py | 872 | 3.609375 | 4 | class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
if not len(matrix) or not len(matrix[0]):
return
first = 0
last = len(matrix) * len(matrix[0]) - 1
... |
97776a074bf18709b051ab90514c4d80318ac27d | m-e-l-u-h-a-n/Information-Technology-Workshop-I | /python assignments/assignment-1/3.py | 228 | 3.640625 | 4 | s=input()
x1=s.find('not')
x2=s.find('poor')
"""because according to example given
for the question (if poor is followed by not) so third condition is applied"""
if x1>0 and x2>0 and x1<x2:
s=s[:x1]+'good'+s[x2+4:]
print(s) |
1299c3bba29a14f982d82ba930a6bf7a5c6a61a2 | IchibanKanobee/MyProjects | /Python/classes/class_1.py | 251 | 3.6875 | 4 | class Person:
def __init__(self):
self.name = "Ara"
self.age = 56
'''
def __init__(self, name, age):
self.name = name
self.age = age
'''
def get_age():
return self.age
def set_age(age):
self.age = age
p = Person()
print (p.age)
|
475e55938f98e1b1b6d1e03bad6c9ef57a9e7e81 | ITlearning/ROKA_Python | /2021_03/03_07/str.py | 169 | 3.609375 | 4 | # str() 함수를 사용해 숫자를 문자열로 변환하기
output_a = str(52)
output_b = str(52.334)
print(type(output_a), output_a)
print(type(output_a), output_b) |
fc63bd1a25a459e3b65d0d6be4e3ff681ac69d84 | aaron0215/Projects | /Python/HW6/game21.py | 2,037 | 4.0625 | 4 | #Aaron Zhang
#CS021 Green group
#Lead user to input random number
#Use accumulation to store the total number
#In main function, divide number of user into two sections
#Compare the numbers in each section and print result
import random
def main():
standard_value = 21
total_num_user=0
total_num_co... |
a75336d26533623a40d629356fca04e8466e0992 | ebiacsan/URI-Online-Judge | /Python/URI 1097.py | 500 | 3.65625 | 4 | ''' /*
*Fazer um programa que apresente a sequencia conforme o exemplo abaixo.
* Não tem entrada, mas a saida deve ser:
* I=1 J=7
* I=1 J=6
* I=1 J=5
* I=3 J=9
* I=3 J=8
* I=3 J=7
* ...
* I=9 J=15
* I=9 J=14
* I=9 J=13
*/
'''
I, J,F,G = -1,5,4,3
f... |
bc7b2c6e6772ba9fd550d4bfb6c792e6877c0476 | Ved005/project-euler-solutions | /code/squarefree_factors/sol_362.py | 819 | 3.546875 | 4 |
# -*- coding: utf-8 -*-
'''
File name: code\squarefree_factors\sol_362.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #362 :: Squarefree factors
#
# For more information see:
# https://projecteuler.net/problem=362
# Problem Statement
'... |
1e4f08b50852f6136a856388f1125b56454a4c2f | moddaser/hackerrank | /hackerrank-problem1.py | 1,170 | 4 | 4 | # HL machine learning: Normal Distribution #1
"""
p(x<b) is calculated using the integral of a gaussian distribution from infinity to b.
Infinity is approximated by a large number INFINITY, and DELTLA for the discrete integral
is approximated by a small number.
"""
import math
def arange(l, h, inc):
"""List of... |
f9ffacd181c7fc240c06f2696a78b93f7e1e75a9 | DiksonSantos/GeekUniversity_Python | /77_Debugando_Codigo_Com_PDB.py | 2,314 | 3.984375 | 4 | '''
PDB -> Python Debigger
'''
'''
def divide(A, B):
print(f'Primeiro Termo={A} Segundo_Termo={B}') #Aqui o PRINT é uma maneira de debugar o Codigo.
try:
return float(A) / float(B)
except(ValueError, TypeError, ZeroDivisionError):
return 'Valores Inserido = Incorretos.'
NUM1 = int(input("Pr... |
0d0de21cf8f2f217bc5e9e4da6acdaf95605458d | ongsuwannoo/PSIT | /Sequence II.py | 154 | 3.796875 | 4 | ''' Sequence II '''
def main():
''' for loop '''
num = int(input())
for i in range(1, num+1):
print(i*i+1-1, end=" ")
main()
|
e0b0d74b0cee96bd1ce123bccac2dfb96f9d2e2e | Moustafa-Eid/Python-Programs | /Unit 3/String Manipulation Uses/ManipulationUsesEx1a.py | 146 | 4.1875 | 4 | entry = input ("Please enter a string: ")
if entry.isalpha() == True:
print ("It is only letters")
else:
print ("it is not only letters") |
417429befced352711defd09e9208eb6363ae91f | soohyun-lee/python3 | /python3-2.py | 280 | 3.734375 | 4 | h = float(input('키:'))
w = float(input('체중:'))
n = w / ((h * 0.01) ** 2)
if n < 18.5:
print('평균 이하입니다')
elif 18.5 <= n < 25.0:
print('표준입니다.')
elif 25.0 <= n < 30.0:
print('비만입니다.')
else:
print('고도 비만입니다.') |
132fe8bc13781bdb55f8595dfb290739975cf078 | aludvik/dna | /deque.py | 1,644 | 3.515625 | 4 | class Deque:
class __Node:
def __init__(self, data):
self.prev = None
self.next = None
self.data = data
def __init__(self):
self.__front = None
self.__back = None
self.__size = 0
def push_front(self, data):
n = Deque.__Node(data)
... |
9f5bace55828c1f64033b3bb5fc20e7065bc4ae2 | Dkabiswa/python-practice | /sorting/quickSort.py | 507 | 4.0625 | 4 | # def quick_sort(list_a):
# if len(list_a) <= 1:
# return list_a
# else:
# pivot = list_a.pop()
# less_than = []
# greater_than = []
# for item in list_a:
# if item > pivot:
# greater_than.append(item)
# else:
# less_than.append(item)
# r... |
0c97749575a93fd773709a606525e14cd540655d | ecwu/SDWII | /python-cpr/6.py | 599 | 4.0625 | 4 | # Zhenghao Wu l630003054
MONTHS = 12
if __name__ == '__main__':
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
user_month, user_day, accumulate = (0, 0, 0)
while user_month > MONTHS or user_month <= 0:
user_month = int(input("Enter the month: "))
while user_day > days_i... |
83e842ac9fb12159f3e09ddac7cb8889507ce728 | saishg/codesnippets | /strings/look_and_say.py | 747 | 3.6875 | 4 | # Implement a function that outputs the Look and Say sequence:
# 1
# 11
# 21
# 1211
# 111221
# 312211
# 13112221
# 1113213211
# 31131211131221
# 13211311123113112211
def look_and_say(input_str=None):
if input_str is None:
return '1'
output_str = ''
count = 0
last_char = ''
for char in i... |
e57353d90c9437ae4a3ab04ee07b000381846e90 | shyamsaravanan/nexwave | /tuple_ex.py | 266 | 3.515625 | 4 | #tuple-class
t1=tuple([10,20,30])
t2=(10,12.5,'python',['a','b'],(10,20))
print(t2)
print(t2[1])
print(t2[-4:4])
print(t2[-4:4:+2])
i=t2.index('python')
c=t2.count(12.5)
print(i,c)
T=(10,20)
L=list(T)
print('L=',L)
l=[30,40]
t=tuple(l)
print('T=',t)
|
29c5b9799c176f2adfdceec0f4783da8389392c2 | agk79/Python | /project_euler/problem_12/sol2.py | 278 | 3.65625 | 4 | def triangle_number_generator():
for n in range(1,1000000):
yield n*(n+1)//2
def count_divisors(n):
return sum([2 for i in range(1,int(n**0.5)+1) if n%i==0 and i*i != n])
print(next(i for i in triangle_number_generator() if count_divisors(i) > 500))
|
ce2f0118736e17a5b497e0e99b00e0836622603c | natejenson/AdventOfCode2016 | /Day 2/day2.py | 1,682 | 3.75 | 4 | class Position:
def __init__(self,x,y):
self.x = x
self.y = y
class Keypad:
def __init__(self, numbers):
self.numbers = numbers
def Number(self, pos):
return self.numbers[pos.y][pos.x]
def Move(self, startPos, direction):
newPos = Position(startPos.x, startPos.... |
5dca6109eff7307a6a9d09f24ffb7cd4e073efbe | Harshhg/python_data_structures | /Hashing/check_common_substring.py | 456 | 4.15625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# Given two strings, determine if they share the common substring
# Time complexity O(N)
# In[3]:
# Function that takes 2 strings as arguments
def twoStrings(s1, s2):
hash={}
string="NO"
for x in s1:
hash[x]=1
for y in s2:
if y in has... |
78136b26d22061efce15acae787757dceb11a711 | ashokjain001/Python | /polygon.py | 364 | 3.953125 | 4 | import turtle
def main(sides,length):
wn = turtle.Screen()
ashok = turtle.Turtle()
wn.bgcolor("darkslategray")
ashok.color("yellow")
ashok.pensize(4)
polygon(ashok,sides,length)
wn.exitonclick()
def polygon(t,sides,length):
degree = 360/sides
for i in range(sides):
t.fo... |
9acb290a34eaf081d97ee32347600a39ea55e7ce | arindam-1521/python-course | /python tutorials/with-block.py | 366 | 4 | 4 | with open("joy.txt") as f:
a = f.readlines() # Here it is not required to close the file .
print(a)
f = open(
"joy.txt", "r+"
) # Here the file will run again because the with open block automatically closes the file after opening ,hence we cans open the file multiple times and read it.
# print(f.readli... |
f4f6265b8da57464607df82f1885bae20b8cfab1 | sunilsm7/python_exercises | /Python_practice/practice_02/evenOdd.py | 354 | 4.34375 | 4 | """
Ask the user for a number.
Depending on whether the number is even or odd, print out an appropriate message to the user.
Hint: how does an even / odd number react differently when divided by 2?
"""
def evenOdd(num):
if num%2 != 0:
return "Odd number"
return "Even number"
num = int(input('Enter number:'))
res... |
c4aa1126ca229c72948a0ddc0dc98c538c52453c | vivekgopalshetty/Algorithms | /squareoot.py | 2,281 | 3.71875 | 4 |
def convert_tobinary(n1,count1):
n1=bin(int(n1))
n2=list(n1)
n3,n4=''.join(n2),''.join(n2[2:])
con=0
if len(n4)<count1:
con=count1-len(n4)
for i in range(0,con):
n4='0'+n4
return n3,n4
def validate_no(n):
length=len(n)
if length%2==0:
n1=n
else:
... |
bfba9e65274b97bef196f8f5be203d1cbf646181 | begora/apuntespython | /Primeras_funciones.py | 315 | 3.890625 | 4 | def suma(num1, num2):
print(num1+num2)
suma(5,7)
suma(2,3)
suma(35,37)
def suma2(n1,n2):
resultado = n1 +n2
return resultado
print (suma2(5,9))
#PRINT puede ir dentro de la función (suma)
#o fuera de la función, cuando la llamas (suma2)
almacena_resultado=suma2(5,8)
print(almacena_resultado) |
f5fec8ac322d17361133ab66e560dc35bfd3cd4f | atulanandnitt/questionsBank | /basicDataStructure/matrix/90DegreeRotation.py | 429 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 26 07:11:03 2018
@author: Atul Anand
"""
def matrixRotation(mat):
print(*mat)
print(mat)
for t1 in (zip(*mat)):
for i in range(len(t1)):
print(t1[len(t1)-i-1] , end=" ")
print()
mat=[[1... |
2cbc1d5791158e5c876b938f97819a9cfe2ad6e6 | KKIverson/python_ds_alg | /num2Base.py | 307 | 3.828125 | 4 | # -*-coding: utf-8-*-
# 将十进制整数转换成任意进制的字符串(使用递归)
def num2base(num, base):
digits = '0123456789ABCDEF'
if num // base == 0:
return digits[num % base]
else:
return num2base(num // base, base) + digits[num % base]
print(num2base(15,16))
|
e7cb8765e4a24012d5e49393aa24da56a0dbc1c5 | Hedyju/hello-world | /code 4.py | 168 | 3.546875 | 4 | score = int(input('성적을 입력하세요 :'))
if score >= 90:
print('통과하셨습니다')
print('축하합니다')
print('수고하셨습니다') |
f492ab525c6f8ab6118688efd93ebb3bf0b59b52 | Srisomdee/Python | /1.py | 407 | 3.921875 | 4 | x = 25
print('เลือกเมนูทำรายการ')
print('จ่ายเเบบเหมาจ่าย กด1 :')
print('จ่ายแบบจ่ายเพิ่ม กด 2 :')
a = int(input('enter your number 1 or 2 :'))
s = int(input('กรุณากรอกระยะทาง(km)')
if a == 1:
print('n equal to 10')
else:
print('n is something else except 10')
|
33ff7727e04bdb12605a865a2fda1e275a1602cc | AkshayPradeep6152/letshack | /Python Programs/Trie.py | 1,880 | 3.84375 | 4 | from collections import defaultdict
class TrieNode():
def __init__(self):
self.children = defaultdict()
self.terminating = False
class Trie():
def __init__(self):
self.root = self.get_node()
def get_node(self):
return TrieNode()
def get_index(self, ch):
re... |
57d1fa2f487012f4994027e12f6c356259f094bd | refeed/StrukturDataA | /meet1/J_gunungSimetris.py | 547 | 3.84375 | 4 | '''
Gunung Simetris
Batas Run-time: 1 detik / test-case
Batas Memori: 64 MB
DESKRIPSI SOAL
Buatlah sebuah deret gunung seperti contoh di bawah.
PETUNJUK MASUKAN
Sebuah bilangan bulat N. (1≤N≤100)
PETUNJUK KELUARAN
keluarkan deret gunung dengan tampilan horizontal (satu angka per baris).
CONTOH MASUKAN 1
5
CONTOH... |
505134f7707cd1c7254c7e82a18d3bfb02e6cfc7 | Suraj-KD/HackerRank | /python/string/text_alignment.py | 862 | 3.53125 | 4 | from __future__ import print_function, division
char = 'H'
space = ' '
def text_align(width):
lines = []
for n in range(width):
lines.append((char*(n*2+1)).center(width*2-1, space))
offset = space*(width*4 - (width*2-1))
for n in range(width+1):
lines.append((char*width).center(width... |
c20ff9503fa2a4ad8277df905e570dba127a6963 | LDStraughan/HarvardX_PH526x_Using_Python_for_Research | /5_Statistical_Learning/5.4_Homework_Case_Study_Part_1/5.4_Homework_Case_Study_Part_1.py | 8,807 | 3.921875 | 4 | #####################
# CASE STUDY 7 PART 1
#####################
# The movie dataset on which this case study is based is a database of 5000 movies catalogued by The Movie Database
# (TMDb). The information available about each movie is its budget, revenue, rating, actors and actresses, etc. In this
# case study,... |
9c7456adafdf5644194adb5816522b81ea6a12b1 | sharangKulkarni2/sorting-in-c-and-python | /q_sort.py | 762 | 3.796875 | 4 | def partition(arr, start, end):
pivot = end
pivot_element = arr[pivot]
i = start
j = end - 1
while i < j:
while arr[i] < pivot_element:
i+=1
while arr[j] > pivot_element:
j-=1
if i < j:
temp = arr[i]
arr[i] = arr[j]
... |
ab2f4d2e89bbce5b1878be5bb0174859dfe8c06f | silvavn/CMPUT175-W2020 | /Assignment-2/UltimateMetaTTT.py | 6,554 | 4.4375 | 4 | #----------------------------------------------------
# Assignment 2: Tic Tac Toe classes
#
# Author: Victor Silva
# Collaborators:
# References:
#----------------------------------------------------
class TicTacToe:
'''
Abstract Class TicTacToe
Implements the general methods for the TicTacToe ... |
1eec8a5365910e0f0318ba81b9b5eead89be3c62 | applepicke/euler | /14.py | 596 | 4.0625 | 4 | #!/usr/bin/env python
import sys
chain = {}
def collatzify(n):
orig_num = n
count = 1
while n > 1:
if chain.has_key(str(n)):
count += chain[str(n)]
break
n = (n / 2) if (n % 2 == 0) else (3*n + 1)
count += 1
chain[str(orig_num)] = count
return count
def longestSequence... |
671c3c09756ddab4eb41297ba9ae3df0125207fa | orakinahmed/Python-Practice | /AdventureTime/pygame1.py | 1,922 | 4.375 | 4 | """
print('What is your name?')
name = input() # Receiving input from the user at the terminal
print('Your name is: ' + name) # String Concatenation
"""
# Create your own text adventure game!
# Present 5 scenarios to a user and give them 2 options to choose from for each scenario.
# Make it ... |
faca6c8f11137ab565bb7099a53a1587043a4e89 | ivSaav/Programming-Fundamentals | /RE06/count.py | 214 | 3.921875 | 4 | def count(word, phrase):
phrase += " "
result = phrase.count(word.upper() + " ") + phrase.count(word.lower() + " ") + phrase.count(word.capitalize() + " ")
phrase = phrase[:-1]
return result
|
6835b294a7d5ffd2240083226c5b1c6e5b0cd1ce | dwallace-web/python-crash-TM | /python_crashcoursefiles/functions.py | 818 | 3.78125 | 4 | # A function is a block of code which only runs when it is called. In Python, we do not use parentheses and curly brackets, we use indentation with tabs or spaces
# create simple function
def sayGoodbye(name):
print(f'Goodbye, until next time {name} ......' + name)
sayGoodbye('Jonathan Doe')
# return values
... |
77621e13f718eaeaeb2bdf0a32988befea67dd74 | rileyjohngibbs/hard-twenty | /adventOfCode/06/solution.py | 2,654 | 3.53125 | 4 | from functools import reduce
from sys import argv
if "test" not in argv:
with open('input.txt', 'r') as inputfile:
coords = [p.replace('\n', '') for p in inputfile.readlines() if p]
else:
coords = [
"1, 1",
"1, 6",
"8, 3",
"3, 4",
"5, 5",
"8, 9",
]
... |
8afce1725e30448dbf9fd75c5b1f4cb6823d2399 | standrewscollege2018/2021-year-11-classwork-SamEdwards2006 | /Ifelse.py | 285 | 4.375 | 4 | #This program demonstrates how an if statement works
#Sets an age limit
CHILD_AGE = 13
#Take the age of the user
age = int(input("How old are you"))
#Checks if the age is above or below the age limit
if age <= CHILD_AGE:
print("You pay the child price")
print("Welcome to the zoo") |
3ed454a1b84dea94a7e23e1b8e2bcb9adaefd6c9 | szhmery/algorithms | /samples/IsPrime.py | 296 | 3.78125 | 4 | import math
def IsPrime(Num):
if Num == 1:
return False
for n in range(2, int(math.sqrt(Num)) + 1):
if Num % n == 0:
return False
return True
oList = []
for i in range(1, 101):
if IsPrime(i) is True:
oList.append(i)
else:
print(oList)
|
9c86d73eb4b67332ab3d18eb61826211b514fd22 | lucasgaspar22/URI | /Iniciante/1012.py | 348 | 3.578125 | 4 | line = input().split(" ")
a = float(line[0])
b = float(line[1])
c = float(line[2])
aTriangle = a*c/2
aCircle = 3.14159*c**2
aTrape = (a+b)*c/2
aSquare = b**2
aRectangle = a*b
print("TRIANGULO: %.3f" %aTriangle)
print("CIRCULO: %.3f" %aCircle)
print("TRAPEZIO: %.3f" %aTrape)
print("QUADRADO: %.3f" %aSquare)
print("RE... |
eabcdd82618932852a2ae9e238f4e105f862acec | daily-boj/dryrain39 | /P2508.py | 1,052 | 3.78125 | 4 | def is_candy(a, b, c, xy):
return (a == '>' and b == 'o' and c == '<' and xy == 'x') or \
(a == 'v' and b == 'o' and c == '^' and xy == 'y')
if __name__ == '__main__':
test_count = int(input())
for _ in range(test_count):
input()
height = int(input().split()[0])
candy ... |
22084869c8fa8f8b8d28bad2ad5ba9076062dfba | arthurdysart/LeetCode | /0209_minimum_size_subarray_sum/python_source.py | 9,756 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Leetcode - Minimum Size Subarray Sum
https://leetcode.com/problems/minimum-size-subarray-sum
Created on Tue Nov 20 13:45:34 2018
Updated on Sun Dec 2 21:09:57 2018
@author: Arthur Dysart
"""
## REQUIRED MODULES
import sys
## MODULE DEFINITIONS
class Solution:
"""
... |
2645b6dee39e29a5440b880943d15c28c6132a16 | atwndmnlght/the_self_taught_prog | /190108.py | 187 | 3.609375 | 4 | colors = ["orange", "pink", "black"]
guess = input("何色でしょう:")
if guess in colors:
print("あたり")
else:
print("hazure")
#これはタプル
("ai",)
|
1d21eb71ced7b647a4c805a22fcaec9d8788aa42 | GreenMarch/datasciencecoursera | /algo/basic/squares-of-a-sorted-array.py | 312 | 3.53125 | 4 | class Solution(object):
def sortedSquares(self, A):
"""
:type A: List[int]
:rtype: List[int]
"""
return sorted([i**2 for i in A])
def sortedSquares2(self, A):
return list(map(lambda x: x**2, A))
data = [1,3,5, 7]
print(Solution().sortedSquares2(data))
|
fa883d11cad9b9d3119dc52291104522eaaf4787 | wgrewe/Project-Euler | /19prob.py | 648 | 3.875 | 4 | # How many sundays fell on the first of a month
# between Jan 1 1901 and Dec 31 2000
# m = 1, t = 2, w = 3, h = 4, f = 5, s = 6, su = 7
# 52 weeks in 364 days, so if year starts on sunday
# then there are 53 sundays. If leap year also fine to start on sat
month_days = {
1:31,
2:28,
3:31,
4:30,
5:31,
6:30,
... |
2fd7f27aaabf194d6d689d2adfb7f9f1e2c1331a | ramvishvas/chegg-sol-2019 | /basic.py | 1,600 | 3.75 | 4 | import random
import math
myArray=[]
size= 50
# populate array with size=50 random integers
# in range 0-1 and repeat for 1000 times
for _ in range(1000):
for k in range(size):
randNum=random.randint(0,1)
# add random number to list
myArray.append(randNum)
#print myArray 50 values per line
for i in range(size... |
69e7ad49b607ea8f7383f3e037ef28001aaee9a6 | LisaHagenau/small-bioinformatic-scripts | /range-of-values.py | 946 | 3.75 | 4 | # find the range of values in column 3 for unique values in column 1 and the most common value in column 2
import csv
# open both files and store sequences from file1 as list
stream = open("file1.txt")
seqlist = list(stream)
seqlist = [element.strip() for element in seqlist]
stream = open("file2.txt")
read... |
eeaa33530d7bcb9f938c68600b0e42fd07aa313e | xi2pi/patent-claim-combination | /combination_analysis.py | 603 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Christian Winkler
"""
def num_combinations(claim_):
num_com_list = [0] * len(claim_)
num_com_list[0] = 1
num_com_list_idx = 0
for i in claim_:
if num_com_list_idx > 0:
for j in i:
num_com_list[num_com_list_idx]... |
c8a24053af3f8de4a2dd96f28c38fe34bd6a3fac | Rodagui/Programas_Teor-aComputacional | /programa4.py | 559 | 3.84375 | 4 | #Programa 4: Cambia los caracteres igual al primero al caracter '$', excepto el primero
def cambiarCaracteres(cadena):
nva = ""
caracter = cadena[0]
nva += caracter
for i in range(1, len(cadena)):
if(cadena[i] == caracter and i > 0):
nva += "$"
else:
nva += cadena[i]
return nva
#------... |
3bbed811fc02dff16ceb34dd1f2fa56778ffca0b | VINSHOT75/PythonPractice | /infytq/pyq4.py | 366 | 3.546875 | 4 | str = input()
lst1 = list(str)
speind = []
spe = []
for i in lst1:
if i == '@' or i == '#':
spe.append(i)
x = lst1.index(i)
speind.append(x)
lst1 = lst1[::-1]
for i in lst1:
if i == '@' or i == '#':
lst1.remove(i)
#print(lst1)
k=0
while k<len(speind):
lst1.insert(speind[k],s... |
d815a614c688a5095b645dcc99331c9be52871da | SyedNaziya/test | /s6_55.py | 82 | 3.921875 | 4 | n=int(input())
a=int(input())
b=n*a
if b%2==0:
print("even")
else:
print("odd")
|
c92fa5763b2ece23d297395f1aab9ba720f0c694 | wataoka/atcoder | /abc120/d.py | 1,339 | 3.59375 | 4 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
self.ans = n*(n-1)//2
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... |
09fefef4a915507c11679a165bb10a5b30966750 | IordachescuAnca/Computational-Geometry | /Lab1/collinearity.py | 2,672 | 4.25 | 4 |
class Point:
def __init__(self, coordinateX = 0, coordinateY = 0, coordinateZ = 0):
self.__coordinateX = coordinateX
self.__coordinateY = coordinateY
self.__coordinateZ = coordinateZ
def readData(self):
self.__coordinateX = float(input("Enter the first coordinate of the point: "))
self.__coordinateY = flo... |
ef69b8b725bf9737eeabecf7330f0289326171dd | pruthvi28994/Basics_Of_Coding_3 | /numpattern2.py | 354 | 3.9375 | 4 | n=int(input('enter the number'));
def numpattern(num):
x=1;
for row in range(num):
if(row % 2 == 0):
for col in range(1,num+1):
print(x,end=" ");
print((x+1),end=" ");
else:
print((x+1),end=" ");
for col in range(1,num+1):
print(x,end=" ");
p... |
8b98a523b681beca19d2dc28977bece86a23ab93 | carterjin/digit-challenge | /PNG_digit_question.py | 2,767 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 11:34:04 2020
@author: Kami
"""
import itertools
testdigits = range(1,10)
# Shunting-yard_algorithm
##https://en.wikipedia.org/wiki/Shunting-yard_algorithm
def op_prec(char):
if char == '*' or char == '/':
return 3
else:
... |
43afe383a035825782d4c915e85ce780cf8cc0e7 | JohnnyHowe/slow-engine | /gameObject/gameObjectHandler.py | 1,111 | 3.546875 | 4 | """ Handles the updating of gameObject components. """
class GameObjectHandler:
# Singleton things
_instance = None
@staticmethod
def get_instance():
if GameObjectHandler._instance is None:
GameObjectHandler()
return GameObjectHandler._instance
def __init__(self):
... |
76a6482db113868ec9d501097f94b993668eef01 | fengjiaxin/leetcode | /code/backtrack/377. Combination Sum IV.py | 1,888 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-07-19 10:18
# @Author : 冯佳欣
# @File : 377. Combination Sum IV.py
# @Desc :
'''
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
Example:
nums = ... |
679418655ba6d983e1efc25c2e36c319ff238b86 | frenzymadness/pycode_carrots_girls_ova | /kamen_nuzky_papir/v2.py | 975 | 3.75 | 4 | #!/usr/bin/env python3
# Do hry z varianty 1 přidejte validaci uživatelského vstupu.
# Hra dá uživateli na výběr následující položky A. Kámen B. Nůžky C. Papír D. Konec hry
# Hra se navíc musí po oznámení vítěze zeptat, jestli má zahájit nové kolo.
pocitac = 'N'
print('Hra kamen, nuzky, papir')
print('Pravidla: káme... |
1773d761f6f268254f0682b7bafddada339e4246 | Drawiin/algoritmos-basicos | /Estruturas de Dados/Threes/AVL2.py | 3,184 | 3.703125 | 4 | class Node:
def __init__(self, key, dad=None):
self.key = key
self.dad = dad
self.left = None
self.right = None
self.hight = None
self.balance = None
self.color = None
class AVL:
def __init__(self):
self.root = None
def insert(self, key):
... |
dbc642b25c33ce604dee3147cd813ee2b7f31a29 | helloexp/Python-100-Days | /公开课/文档/年薪50W+的Python程序员如何写代码/code/Python/opencourse/part02/idiom04.py | 205 | 3.953125 | 4 | fruits = ['orange', 'grape', 'pitaya', 'blueberry']
# index = 0
# for fruit in fruits:
# print(index, ':', fruit)
# index += 1
for index, fruit in enumerate(fruits):
print(index, ':', fruit)
|
c5e39d7ec024eea506e0a69caac33010b26c013b | kirigaikabuto/Python19Lessons | /lesson9/4.py | 473 | 3.953125 | 4 | clothes = [
"футболка",
"шуба",
"джинсы",
]
prices = [
250,
1000,
500
]
n = len(clothes)
i = 0
while i < n:
print(f"{i}.{clothes[i]}")
i += 1
choice = int(input("выбрать:"))
print(clothes[choice], prices[choice])
# программа спрашивает у человека что ты хочешь купить?
# 0.футболка
# 1.шу... |
23115516afb20abbdb33ba422e26fe5b86d9419d | PzanettiD/practice | /scramble.py | 442 | 3.859375 | 4 | # https://www.codewars.com/kata/scramblies/train/python
# If a portion of str1 characters can be rearranged to match str2, return True,
# otherwise returns false.
import collections
def scramble(s1, s2):
# your code here
if len(s1) < len(s2):
return False
s22 = collections.Counter(s2)
... |
3fb4f993135bd0dafa1a24b278a1034fc991630e | kihyo9/RecursiveSudokuSolver | /RecursiveSudokuSolver.py | 942 | 3.859375 | 4 | #numpy is imported to make the grid readable
import numpy as np
#grid with partially filled sudoku
grid = [[5,0,0,0,8,0,0,4,9],
[0,0,0,5,0,0,0,3,0],
[0,6,7,3,0,0,0,0,1],
[1,5,0,0,0,0,0,0,0],
[0,0,0,2,0,8,0,0,0],
[0,0,0,0,0,0,0,1,8],
[7,0,0,0,0,4,1,5,0],
[0,3,0,0,0,2,0,0,0],
[4,9,0,0,5,0,0,0,3]]
#determine possible solu... |
7ede34e6b444084ec85f51c44ca0d26cd7979bd1 | saifsafsf/Semester-1-Assignments | /Lab 05/task 4.py | 280 | 3.71875 | 4 | star = str('*') # Specifying variables
for i in range(1, 14):
print(f'{i}\t', end='') # Using end= so cursor stays in the same line
for j in range(1, i+1):
print(star, end='')
print() # Now moving to next line for the next line of output
|
428dc71d470ccfe5955d77c88540b6671e596a34 | miki-minori/python-work | /AtCoder/215/215A.py | 73 | 3.671875 | 4 | s=input()
if ("Hello,World!" == s):
print('AC')
else:
print('WA') |
e363da063cc12570109d18b5d45aacb350c99b07 | pocceschi/aprendendo_git | /CursoPythonIntermediario/funcoes/funcao_calculo_pagamento.py | 661 | 3.890625 | 4 | # exemplo de um uso para função:
def calcular_pagamento(qtd_horas, valor_hora):
qtd_horas = float(qtd_horas)
valor_hora = float(valor_hora)
if qtd_horas <= 40:
salario = qtd_horas * valor_hora
else:
h_excd = qtd_horas - 40
salario = 40 * valor_hora + (h_excd * (1.5 * valor_hora)... |
75c061c4697c7b30011dfa05284317c3175d2911 | thitemalhar/python_exercise- | /praticepython_org/remove_duplicate.py | 305 | 3.90625 | 4 | list = [int(x) for x in input("Enter numbers to form a list: \n").split()]
def dup(list):
new_list = []
for i in list:
if i not in new_list:
new_list.append(i)
print (sorted(new_list))
def dup2(list):
new_list2 = (set(list))
print (new_list2)
dup(list)
dup2(list) |
702f177e6903acba8849f0a027bb8fd77e77aaab | jeremybwilson/codingdojo_bootcamp | /bootcamp_class/python/practice/enumerate.py | 415 | 4.25 | 4 | # Python program to illustrate
# enumerate function
list1 = ["eat","sleep","repeat"];
s1 = "geek"
# creating enumerate objects
obj1 = enumerate(list1)
print "Return type:",type(obj1)
print list(enumerate(list1))
my_list = ["wine","cheese","beer","eat","drink","merry"];
# creating enumerate objects
obj2 = enumerate(... |
0eff74c28dac3536277cf80fc78ff0e9f90fe6bd | petirgrofin/OurRPGGame | /ModuleToTestScripts.py | 1,036 | 3.859375 | 4 |
class Dog:
def __init__(self, name, is_loyal):
self.name = name
self.is_loyal = is_loyal
def checking_dog_characteristics(self):
print(f"The dog is named {self.name}")
print(f"The dog is loyal: {self.is_loyal}")
akira_dog = Dog(name="Akira", is_loyal=True)
class Cats:
... |
a3b87ae3bf95d6d98a82fa0f531578fa6dee9a7d | YuThrones/PrivateCode | /LeetCode/114. Flatten Binary Tree to Linked List.py | 1,363 | 4.15625 | 4 | # 思路还是分治,先把左子树变成一个链表,然后把右子树放到左子树最后一个节点的后面,然后用左子树替代右子树的位置
# 需要注意的就是各种None的情况的处理,左子树为空时只需要把右子树排成链表并返回右子树最后一个节点即可,不需要额外的替换节点
# 右子树为空时也只需要修改左子树并返回最后一个节点
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# ... |
7096975dc0b2c79ee14c40d872dd35337211fb2c | mxu007/daily_coding_problem_practice | /DCP_8.py | 1,024 | 4.25 | 4 | # Trie
# Two main methods in tries:
# insert(word): add a word to the trie
# find(word): check if a word or prefix exist in the tires
ENDS_HERE = '#'
class Trie:
def __init__(self):
self._trie = {}
# O(k) time complexity for find and insert, where k is the length of the word
def insert(self, te... |
60b53ab1f34b4afafe8f7977474582c3f9d9080d | everaldo/aed_i | /exercicios_18_08_2015/mdc.py | 221 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 24 11:14:13 2015
@author: everaldo
"""
import time
def mdc(a, b):
if b > a:
return mdc(b, a)
if a % b == 0:
return b
return mdc(b, a % b)
|
67ef9263e58b7cb2bfbed1b97705354689d0bab5 | NarekID/Basic-IT-Center_Python | /Homeworks 0 OLD/Password/main.py | 2,913 | 3.71875 | 4 | import random
def input_num(message):
while 1:
try:
i = int(input(message))
return i
except ValueError:
print("Mutqagreq tiv!")
def generate_password(n = 8, upperCases = False, numbers = False, symbols = False):
password = ""
if upperCases:
if numbers:
if symbols:
for i in range(n):
passwo... |
7ccea744fe2d28b6069da88e7fd1d12fbc70f3d2 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/topics/Algorithms/279/armstrong.py | 205 | 3.640625 | 4 | def is_armstrong(n: int) -> bool:
total = 0
for digit in range(len(str(n))):
total += int(str(n)[digit]) ** len(str(n))
if total == n:
return True
else:
return False |
b0e41d008ea4081f7604077c13351a2243e7a22a | Skg-754/MyRenamingApp | /Sources/utils.py | 2,866 | 3.609375 | 4 |
# -*- coding: utf-8 -*-
import re
# utilitaires maison pour l'incrémentation des amorces et la vérification de la validité des noms de fichier
def increment(amorce, nb) :
"""
permet de réaliser l'incrémentation à partir du amorce
amorce numérique
amorce alphabétique
retourne une l... |
c4e816ef399524ecdc0cedab5a35ec435a458f45 | AntonBrazouski/thinkcspy | /12_Dictionaries/12_04.py | 181 | 3.78125 | 4 | # Aliasing and Copying
opposites = {'up': 'down', 'right': 'wrong', 'true': 'false'}
alias = opposites
print(alias is opposites)
alias['right'] = 'left'
print(opposites['right'])
|
48461b6ff3103e5d602b52991ad9fe7fb9f8d1ea | vaskal08/image-classification | /example.py | 1,895 | 3.859375 | 4 | from perceptron import PerceptronNetwork
from bayes import NaiveBayes
# The purpose of this class is to show an example of training the perceptron and naive bayes classifiers with 100% of the digit training data and testing one digit. For use during demos.
# paths
digitTrainingImagesPath = "data/digitdata/trainingima... |
4c93f8e9de9ed1a6c4504f6962dbb42f2840667f | lorentealberto/Speed-Coding | /PixelSmash Tests/pixelsmash/animation.py | 1,843 | 3.859375 | 4 | import pygame as py
from pixelsmash.timer import Timer
class Animation(object):
"""It represents an animation on game.
Parameters:
_name -- Animation name
_frames -- Animation frames
_speed -- Speed (MS) which last each animation frame"""
def __init__(self, _name, _frames, _speed):
#Received by par... |
38224cb19e926fdf79303947504f649243e93ca9 | nsyawali12/Simulated_annealing | /Simulated-Annealling.py | 1,774 | 3.65625 | 4 | import math
import random
tester = ("Hello World!")
print (tester)
print ("This is my first A.I Project : Simulated-Annealling")
tempature = 10000 #inisialisai dengan temperatur bebas aku set dengan 10000
T = tempature
c = 0.06 #nilai diambil sesuai saran dari kertas pak sunjana berikan 0.4 - 0.6
n = 100 #range
de... |
9421740b0673b29b4f9eca9c7b48a99bbfeeeeba | alisazosimova/algorithms | /palindrome.py | 707 | 3.890625 | 4 | def is_palindrome_1(word):
list_from_word = list(word)
if len(list_from_word) <= 1:
return True
else:
if list_from_word[0] == list_from_word[-1]:
return is_palindrome(list_from_word[1:-1])
else:
return False
def is_palindrome(word):
list_from_word = [... |
41d1b99cd41bb0fcfb3b1aa24f176bffdafff1af | ZhiwenYang92/slicer-1 | /tests.py | 1,095 | 3.53125 | 4 | from shapes import Point
from shapes import Triangle
high = Point(0,0,4)
low = Point(0,0,-1)
we = Point(0,0,3)
we2 = Point(0,0,3)
print we.is_equal(high)
print we.is_equal(we2)
tri = Triangle(high,low,we)
print "high: " + tri.z_high.point_tos() + " expected: 0 0 4"
print "low: " + tri.z_low.point_tos() + " expected:... |
bac21a1963c5ec6cd2dedce9b2ce463df01b7660 | JerinPaulS/Python-Programs | /RelativeSortArray.py | 1,287 | 4.28125 | 4 | '''
1122. Relative Sort Array
Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.
Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of arr1 in asce... |
4dcbe1eb5cdb1097fda008793b973c0d5a8b3107 | chien-wei/LeetCode | /0374_Guess_Number_Higher_or_Lower.py | 656 | 3.78125 | 4 | # The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num):
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
hi, lo = n, 1
mi... |
f18f8ca99f0233d688280bad4261b47467ddf85e | SheilaFernandes/Desafios-py | /Desafio074.py | 669 | 3.796875 | 4 | from random import randint
lista = (randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10))
#d = (' ',' ', ' ', ' ', ' ',' ')
print(f'Os valores sorteados foram: ')
for pos, c in enumerate(lista):
print(c, end=' ')
if pos == 0:
maior = menor = c
else:
if maior > c:
... |
b6b13b7cfa7f058bc0c1aabe19c705a259f92c83 | HappyStorm/LeetCode-OJ | /0024. Swap Nodes in Pairs/24.py | 670 | 3.765625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
ans, cur, prev = None, head, None
while cur:
odd, even = cur, cur.next
... |
985570d11268f6ba4d67afe644d31b9e35d20070 | aiwv/PP2_SPRING | /informatics/3547.py | 128 | 3.609375 | 4 | n = int(input())
arr = []
for i in range (1, n + 1):
for j in range (1, i + 1):
print(j, sep='', end='')
print() |
06cae4ca9071b337d0cd21d44f0834adc5a235f9 | longtaipeng/Python_PAT | /第6章函数-2 使用函数求素数和.py | 339 | 3.84375 | 4 | def prime(n):
if n == 1:
return False
for i in range(2, n//2 + 1):
if n % i == 0:
return False
return True
def PrimeSum(num1, num2):
sum1 = 0
for i in range(num1, num2):
if prime(i):
sum1 += i
return sum1
m,n=input().split()
m=int(m)
n=int(n)
pr... |
4199f64aa93e18b5370672fb9bef5dcac4ff5f0c | jessicaice/LPTHW | /ex10.py | 1,505 | 4.125 | 4 | #Defining several variables below to learn about different formatting
#tabbing
tabby_cat = "\tI'm tabbed in."
#splitting a line
persian_cat = "I'm split\non a line."
# adding backslashes
backslash_cat = "I'm \\ a \\ cat."
#writing multiple lines
fat_cat = """
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Gr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.