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 |
|---|---|---|---|---|---|---|
f2ca41a40dd8eb971d760b8caeddec4080d994cc | ZykaMyzyka/EGE | /104895/8.py | 747 | 3.921875 | 4 | '''Маша составляет 5-буквенные коды из букв В, У, А, Л, Ь.
Каждую букву нужно использовать ровно 1 раз, при этом код буква Ь не может стоять на первом месте и перед гласной.
Сколько различных кодов может составить Маша?'''
from itertools import permutations
n = 0
a = list(set(list(permutations('ВУАЛЬ',5))))
for... |
685c050fb95139471bcdd284da78a8da49bbfc96 | pablomedinaa/pico-placa | /car.py | 5,903 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 27 16:26:15 2018
@author: Pablo Medina Aizaga
This class allow a user to determinate when a vehicle is able to be in the road
"""
class Car:
#this is the constructor for the class. It is called whenever a Car object is
#created
def _... |
1d0091cda292bb5ba0921e14aab6a0faf0f3665c | KarlosJRodriguez/PracticaPython | /funcione.py | 510 | 3.984375 | 4 | '''def mensaje(): #funcion
print("Estamos aprendiendo python");
print("Estamos aprendiendo instrucciones basicas");
print("Poco a Poco iremos avanzando");
mensaje(); #llamada de funcion
print("Ejecutando codigo fuera de funcion");
mensaje();'''
def suma(num1, num2):
suma=num1 + num2;
resta=num1 - num2;
multi=nu... |
f931f72885d5fd6d78954cf6510fd4c143540ea3 | BhargavAllarapu/Binary-Search-tree | /binarySearchTree.py | 4,431 | 4.03125 | 4 | class BinarySearchTree:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def makeEmpty(self):
if self.data is not None:
self.recursiveMakeEmpty(self)
self.data = None
print("Deleted every node ...Now the tree is em... |
9d1e56544fe55f101cd832741f1a4149bf0ac727 | chelllsea/lesson10 | /Lesson 10/lifebot.py | 244 | 3.5 | 4 | print('*' * 60)
print('Life Decision Bot')
print()
answer = input('Are you happy? ')
if answer == 'Yes':
print('Sing a happy song!')
else:
print("That's too bad.")
print("Sucks to hear that but uh feel better i guess")
print('*' * 60) |
482bfd0bec00faf4bb15ff65c0685ad02e646bb3 | ehuang3/python-polygon-intersection | /Polygon/app/app_plot.py | 3,693 | 3.578125 | 4 | """
Application to plot two polygons drawn from two input files
and to compute their intersection.
Right-click to refresh
"""
import sys
from poly.polygon import Polygon
from poly.point import Point
from hull.convex import computeHull,computeRandom
from poly.convex_intersect import convexInters... |
fa70ad2f38c22ad4356c1e7783d4887ef5a626f1 | ehuang3/python-polygon-intersection | /Polygon/test/util.py | 1,550 | 3.9375 | 4 | """
Utility functions for testing.
To aid testing, we need to compare two polygons to make
sure they are "the same". This is more than the __eq__
method was meant for. These are quick and dirty, but
should do the trick.
"""
from poly.polygon import Polygon
from poly.edge import Edge
from poly.ut... |
833bf847edaa9d31eaaf2bb8191d40cdc5ec4e2a | Prinkesh/Codes | /Practise/Rotate_Matrix.py | 506 | 3.640625 | 4 | # Rotate a N x N Matrix by 90 degree
# Trick Mathematics ??? Rotation of a point around another point
def rotate(i,j,n):
return (abs(-j),-i+n)
arr=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
for i in xrange(len(arr)/2):
for j in xrange(i,len(arr)-(i+1)):
#i=0
currloc=(i,j)
temp=arr[currloc[0]][currlo... |
15130d4da48e171944cff55cf883ef5994bffdf6 | kvegelius/pygame_snake | /my_first_pygame.py | 2,068 | 3.859375 | 4 | #! /usr/bin/env python
import pygame, sys, random, gameBoard, snake, apple, colors
clock = pygame.time.Clock()
Color = colors.Color
GameBoard = gameBoard.GameBoard
Snake = snake.Snake
Apple = apple.Apple
class Main:
def __init__(self, width, height):
self.main_loop(width, height)
def new_apple_on_board(self, ga... |
ae66153b1a667b2fdca4e9699aba6cbffc979fef | YuriYuriHentai/Yuri | /test.py | 376 | 4.15625 | 4 | #я долбаеб
x=float (input("Введите первое число:"))
z=input ("Введите действие (+, -, /, *, //)")
y=float (input("Введите второе число:"))
if z=="+":
res=x+y
elif z=="-":
res=x-y
elif z=="*":
res=x*y
if z=="/":
res=x/y
elif z=="//":
res=x//y
print ("Результат =", res)
|
eff36c9d4afaf47cefb12b19d80742c94508288d | jmacxx/btcs | /mph-opcodes | 3,848 | 3.625 | 4 | #!/usr/bin/env python3
# Easy Perfect Minimal Hashing
# By Steve Hanov. Released to the public domain.
#
# Based on:
# Edward A. Fox, Lenwood S. Heath, Qi Fan Chen and Amjad M. Daoud,
# "Practical minimal perfect hash functions for large databases", CACM, 35(1):105-121
# also a good reference:
# Compress, Hash, and Dis... |
cee5a13067c418f0dcdc49fa1c7fc653fcecf265 | zwnong/Python | /python_100_day_master/day02/字符串常用操作.py | 648 | 3.78125 | 4 | # coding = utf-8
"""
@All-project: python_100_day_master
@author: ZWNONG
@file: 字符串常用操作.py
@time: 2020-09-03 15:56:38
"""
# 字符串常用操作
str1 = 'hello world!'
print('字符串的长度:', len(str1))
print('单词首字母大写:', str1.title())
print('字符串变大写:', str1.upper())
print('字符串是不是大写:', str1.isupper())
print('字符串是不是以hello开头:', str1.endswith(... |
b8b6232637c4d1c731915c928ea5233e71c1cf7b | aphymi/advent-of-code | /y2019/day03.py | 2,020 | 3.5 | 4 | from collections import defaultdict
from typing import Dict, List, Set, Tuple
from util.parse import *
parse_input = split_on(",")
WirePath = List[str]
WirePaths = List[WirePath]
Point = Tuple[int, int]
def trace_paths(path: WirePath) -> Set[Point]:
"""
Return a set of all points that the given wire path visits.
... |
8cf717197f2401ad4e314f85b1d57ffe8b28d336 | CODE-Lab-IASTATE/MDO_course | /04_programming_with_scipy/newton_conjugate_gradient.py | 1,066 | 3.875 | 4 | #Tutorials for optimization in python
#2D
#Newton Conjugate gradient
#This is a modified Newton algorithm that uses the CG algorithm to approx invert the local hessian
#Requires both the gradient and hessian information
#Import libraries
from scipy import optimize
import numpy as np
#Objective function
def f(x): # ... |
cb2a90a4869b762145f3e48160d7448ad0fda3a4 | CODE-Lab-IASTATE/MDO_course | /03_programming_with_numpy/arrays.py | 889 | 4.40625 | 4 | #Numpy tutorials
#Arrays
#Import the numpy library
import numpy as np
a = np.array([1, 2, 3])
#print the values of 'a'
print(a)
#returns the type of 'a'
print(type(a))
#returns the shape of 'a'
print(a.shape)
#prints the value of 'a'
print(a[0], a[1], a[2])
# Change an el... |
e1149cb29e086ab38ad2f83d3a6f66412507a345 | noamtoeg/21_06_19 | /TicTacTow_4x4.py | 5,969 | 4.28125 | 4 | board = [['_','_','_','_'],['_','_','_','_'],['_','_','_','_'],['_','_','_','_']]
def player_1_Pick_X_or_O(): #This function lets the first player chose X or O and assigns O or X to the second player
player1_XorO = -1
while player1_XorO != (0 or 1):
player1_XorO = input('Please choose X or O (1 f... |
99062d5ffbba3bd8868f903216ed590e16798625 | demyank88/datastructureAlgorithm | /greedy/insertionSort/trial.py | 673 | 4 | 4 |
def insertionSort(arr):
idx = 0
while idx < len(arr) - 1:
for idx2 in range(idx, -1, -1):
nextIdx = idx + 1
nextValue = arr[idx + 1]
if arr[idx2] < nextValue:
arr[idx2 + 1:nextIdx + 1] = [arr[nextIdx]] + arr[idx2 + 1:nextIdx]
break
... |
6f8b9609f72c09d0dca1c12313f6785e19c0508f | demyank88/datastructureAlgorithm | /greedy/selectionSort/trial.py | 666 | 3.734375 | 4 | import sys
def selectionSort(arr):
idx = 0
while idx < len(arr):
idx2 = 0
targetIdx = idx
minVal = arr[idx + idx2]
while idx + idx2 < len(arr):
tmp = arr[idx + idx2]
if tmp < minVal:
minVal = tmp
targetIdx = idx + idx2
... |
cb3c16cae8164f495dd73644ec16ea267f8c0814 | NickosLeondaridisMena/nleondar | /shortest.py | 1,560 | 4.375 | 4 |
# Create a program, shortest.py, that has a function
# that takes in a string argument and prints a sentence
# indicating the shortest word in that string.
# If there is more than one word print only the first.
# Your print statement should read:
# “The shortest word is x”
# Where x = the shortest word.
# The wo... |
c527a2d7aa83ba214a6cace7b78ed76e2a8a6712 | IgoAlgo/Problem-Solving | /choieungi/NewThisIsCT/12_12 기둥과 보.py | 868 | 3.765625 | 4 | def check_possible(ans):
for x, y, installed in ans:
if installed == 0:
if y == 0 or [x - 1, y, 1] in ans or [x, y, 1] in ans or [x, y - 1, 0] in ans:
continue
return False
elif installed == 1:
if [x, y - 1, 0] in ans or [x + 1, y - 1, 0] in ans ... |
f4e30c867b51e0d6c2a34737437d838d079d778b | IgoAlgo/Problem-Solving | /AejiJeon/programmers/0217sprint/신규아이디_simple.py | 823 | 3.53125 | 4 | def solution(id):
answer = ''
# 1
id = id.lower()
# 2
for c in id:
if c.isalpha() or c.isdigit() or c in ['-', '_', '.']:
answer += c
# 여기서부터는 id말고 answer가지고 다룸
# 3 내장함수 replace 사용
while '..' in answer:
answer = answer.replace('..', '.')
# 4
... |
b0af79f28d599fefcbb999e46c3815033253ab65 | IgoAlgo/Problem-Solving | /AejiJeon/ThisIsCT/otherAlgos/primenumber.py | 306 | 3.75 | 4 | import math
4
m, n = map(int, input().split())
Isprime = [True]*(n+1)
Isprime[1] = 0 # False
for i in range(2, int(math.sqrt(n)) + 1):
if Isprime[i]:
j = 2
while i*j <= n:
Isprime[i*j] = False
j += 1
for i in range(m, n+1):
if Isprime[i]:
print(i)
|
5dd6186e0768278c9611a67373dc24ec6e983643 | IgoAlgo/Problem-Solving | /AejiJeon/CodeUp/기초100제/cu_1075.py | 114 | 3.8125 | 4 | # countdown from n-1 to 0 for an input integer n
a = input()
a = int(a)-1
while a >= 0:
print(a)
a -= 1 |
59543ebff301ed4e52f4b6b7a351757e45494286 | IgoAlgo/Problem-Solving | /AejiJeon/programmers/210523sprint/전화번호목록.py | 533 | 3.90625 | 4 | # 해쉬 이용한 풀이
# 시간 복잡도: O(n)
def solution(phone_book):
answer = True
phone_dict = {}
for phone_number in phone_book:
phone_dict[phone_number] = 1
for phone_number in phone_book:
temp = ""
for number in phone_number:
temp += number
# phone_number의 접두사인 temp... |
6fb9cec62aa23646d323bdfc24119eccf8cbb3db | IgoAlgo/Problem-Solving | /choieungi/codeup_basic_100¬_just_easy/basic_1075.py | 55 | 3.640625 | 4 | a= int(input(''))
while a!=0:
print(a-1)
a-=1
|
a8c3e67c479b11711e752d618a64e6d5f14d3cec | IgoAlgo/Problem-Solving | /AejiJeon/CodeUp/기초100제/cu_1025.py | 118 | 3.65625 | 4 | # integer -> sizes of digits
integer = input()
i=4
for a in integer:
print("[%d]" %(int(a)*pow(10,i)))
i -= 1
|
8c9ada6eac01d00473bc07c334f5bae68f1d27d5 | IgoAlgo/Problem-Solving | /AejiJeon/CodeUp/기초100제/cu_1088.py | 150 | 3.828125 | 4 | # print 1 2 ... n except for numbers divisible to 3
a = int(input())
for i in range(1, a + 1):
if i % 3 == 0: continue
print(i, end = ' ')
|
e2e1dc36ac5a5267a68a1f0c4b2bfe24e88f90a6 | IgoAlgo/Problem-Solving | /AejiJeon/ThisIsCT/implementationProblem/외벽점검/14.py | 954 | 3.59375 | 4 |
def solution(n, week, dist):
num_people = len(dist)
num_week = len(week)
dist.reverse() # [4,3,2,1]
for i in range(1, num_people+1): #1명부터~ 늘려가기
group = [] # 조사하러 나가는 사람들 [4,3]
for j in range(i):
group.append(dist[j])
for start in... |
8a3d6a3e4d3943a9dd7d52ac186820cd996dbe4f | IgoAlgo/Problem-Solving | /AejiJeon/ThisIsCT/binarysearchProblem/배열에서특정수개수/27_re.py | 1,011 | 3.828125 | 4 | def first_binary_search(array, target, start, end):
while True:
if start > end:
return -1
mid = (start + end) // 2
if array[mid] == target and (mid == 0 or array[mid-1] < target):
return mid
elif array[mid] == target or array[mid] > target:
... |
1ee250040b7b1043a325f2e759db5d396c83803e | brianbrost/crowdai-example-evaluator | /example_evaluator.py | 1,855 | 3.734375 | 4 | import pandas as pd
import numpy as np
class ExampleEvaluator:
def __init__(self, answer_file_path, round=1):
"""
`round` : Holds the round for which the evaluation is being done.
can be 1, 2...upto the number of rounds the challenge has.
Different rounds will mostly have different ground truth file... |
7e13a6736cdae035792dec2400a1ec76e63289ce | SebasJ4679/CTI-110 | /P5T1_KilometerConverter_SebastianJohnson.py | 670 | 4.625 | 5 | # Todday i will create a program that converts kilometers to miles
# 10/27/19
# CTI-110 P5T1_KilometerConverter
# Sebastian Johnson
#
#Pseudocode
#1. Prompt the user to enter a distance in kilometers
#2. display the formula so the user knows what calculation is about to occur
#3 write a function that carri... |
1f36046a49acf3d0ce5fd0a0c040697a73735066 | ffmaer/sort-python | /pigeonholesort.py | 409 | 3.875 | 4 | import random
def pigeonholesort(arr,k):
#assuming range: [0,k]
holes=[[] for i in range(k+1)]
for i in range(len(arr)):
num=arr[i]
holes[num].append(num)
new_arr=[]
for i in range(1,len(holes)):
new_arr+=holes[i]
for i in range(len(arr)):
arr[i]=new_arr[i]
k=100... |
5be3af1cefd7fda7ceb3a3ef38a1c163c42ff508 | JonahMerrell/LinearAlgebraPackage | /MatrixSolvers/matrix_solve_jacobian.py | 1,483 | 3.734375 | 4 | '''
coding language: Python 3.7.0
written by: Jonah Merrell
date written: April 12 2019
written for: Homework6 Task6
course: Math 5610
purpose: This method will find the solution of a matrix using the jacobian iteration
'''
import sys, os
sys.path.append(os.path.abspath... |
96d057c83f75129f0a4e7dcf995e7514470f353e | JonahMerrell/LinearAlgebraPackage | /MatrixSolvers/matrix_solve.py | 1,143 | 3.90625 | 4 | '''
coding language: Python 3.7.0
written by: Jonah Merrell
date written: November 5 2019
written for: Homework5 Task5
course: Math 4610
purpose: This method will perform elementary row operations on a matrix to take the matrix to row echelon form
'''
import sys, os
sys... |
dd6a8a3f85a7ed0bd8ebf2adeb60219f4f56d5d9 | JonahMerrell/LinearAlgebraPackage | /MatrixMethods/matrix_inverse_power_iteration.py | 1,489 | 3.578125 | 4 | '''
coding language: Python 3.7.0
written by: Jonah Merrell
date written: April 27 2019
written for: Homework8 Task2
course: Math 5610
purpose: This method will find the smallest eigenvector of a matrix using the power iteration. Additinally, this
met... |
7b8fed981371c34945e3916d6d306e71450c400a | JonahMerrell/LinearAlgebraPackage | /EquationSolvers/root_solve_secant_hybrid.py | 1,065 | 3.625 | 4 | '''
coding language: Python 3.7.0
written by: Jonah Merrell
date written: October 2 2019
written for: Homework3 Task5
course: Math 4610
purpose: For this ask, we were asked to implement a hybrid method for approximate solution of root
finding problems... |
7688a6fcfc64b6131f34fa9d5f99f44466f94d2c | mindcrusher11/Mytest | /processWords/python_scripts/address_coordinates.py | 2,596 | 3.578125 | 4 | import urllib, urllib2, json
from pygeocoder import Geocoder
def decode_address_to_coordinates(address):
params = {
'address': address,
'sensor': 'false',
}
url = 'http://maps.google.com/maps/api/geocode/json?' + urllib.urlencode(params)
response = urlli... |
752ea63db524e5f8ac5a2803f0c7dd5db3257fae | DhulipudiSindhu/oop- | /oop_submissions/oop_assignment_004/complex_number.py | 2,094 | 3.546875 | 4 | import math
class ComplexNumber:
def __init__(self, real_part = 0, imaginary_part = 0):
if type(real_part) == str and type(imaginary_part) == str:
raise ValueError("Invalid value for real and imaginary part")
if type(real_part) == str:
raise ValueError("Invalid v... |
1fe2e6996607181d6f32ad81733e0d0fd85d3c49 | MinaPecheux/Advent-Of-Code | /2019/Python/day10.py | 8,294 | 4 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2019 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 10: Monitoring Station
### =============================================
from math import atan2, sqrt, radians, pi
class ... |
3120f4f73f6bec7f02ea96bb0552a20932528435 | MinaPecheux/Advent-Of-Code | /2015/Python/day1.py | 2,603 | 3.96875 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2015 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 1: Not Quite Lisp
### =============================================
# [ Input parsing functions ]
# ---------------------... |
286f4b317d1c482636c89a8574926ef02bc376dc | MinaPecheux/Advent-Of-Code | /2015/Python/day17.py | 2,258 | 3.984375 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2015 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 17: No Such Thing as Too Much
### =============================================
from itertools import combinations
# [ In... |
ef6bbd734fab85805b79b47a88fb6eccd82ee6e0 | MinaPecheux/Advent-Of-Code | /2019/Python/day7.py | 5,367 | 3.5625 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2019 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 7: Amplification Circuit
### =============================================
import itertools
from intcode import IntcodePr... |
50f818ceb0a188f4c560a8a3192f022bc61cc944 | MinaPecheux/Advent-Of-Code | /2015/Python/day5.py | 3,826 | 4 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2015 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 5: Doesn't He Have Intern-Elves For This?
### =============================================
import re
# [ Input parsing f... |
b80e7c6feeb57a17fdf0f613dbeb031afd48494a | MinaPecheux/Advent-Of-Code | /2019/Python/day12.py | 7,301 | 4.09375 | 4 | ### =============================================
### [ ADVENT OF CODE ] (https://adventofcode.com)
### 2019 - Mina Pêcheux: Python version
### ---------------------------------------------
### Day 12: The N-Body Problem
### =============================================
import re
from itertools import combinations
... |
4d02b229dac8b02d2e41cafeebc135e2f74de2c9 | yashprakash13/PieOrg | /pieorg/app.py | 11,196 | 3.6875 | 4 | import sqlite3
from sqlite3 import Error
import click
from art import text2art
def connectToDb(dbname):
try:
conn = sqlite3.connect(dbname)
return conn
except Error:
print(Error)
def getNewTableIfNotExistsQuery(fandomname):
query = """CREATE TABLE IF NOT EXISTS %s_table
... |
da7e43229a85bcec0f634b91097db07c61459e4c | remithiebaut/Coinche | /Card.py | 1,272 | 3.671875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 15:48:39 2019
@author: rthiebaut
"""
class Card():
"""
a game Card
"""
def __init__(self, number, color, rest=True):
self.number=number #prend la valeur none quand inexistant ACHANGER
self.color=color
self.rest=rest #utilisé ... |
c01c55a907fe67c0d33de9b789b5c981c7519f7d | huynhtastic/friendly-parakeet | /solution.py | 4,823 | 4.09375 | 4 | """
Requirements: Write a program that reads in a paragraph form a file (input.txt) and generates a histogram
of the words used, sorted from most occurrences to least. The output will consist of the word followed by a
pipe character ("|"), a number of equal signs that are proportional to the number of occurrences found... |
73a6faba6d52f04536a51da574df3d8b50aff00a | gammar07/python | /Coin Flips.py | 637 | 3.859375 | 4 | import random
outcome = []
heads = 0
tails = 0
def flip():
flip = random.randint(0,1)
if flip == 0:
return ('H')
else:
return ('T')
def main(num):
for i in range(num):
outcome.append(flip())
print('Result is ' + ''.join(str(e) for e in outcome))
... |
4f430fef4a8b4dafb42e209af4b8508fe2efb245 | nate2411/Adding-numbers | /main.py | 1,233 | 3.6875 | 4 | import tkinter as tk
from tkinter import Entry, Button, Label, END
root = tk.Tk()
root.geometry("230x150")
root.title("Adding Numbers")
label_1 = Label(root, text="Num 1: ")
entry_1 = Entry(root, width=20)
label_2 = Label(root, text="Num 2: ")
entry_2 = Entry(root, width=20)
label_1.place(x=10, y=0)
entry_1.pl... |
c96326ac6ccd24e869c5866c1ed2f3c76c56fcee | hodasartem/homework1 | /Task3.py | 187 | 3.84375 | 4 | my_str = ('''Petya saved the cat from the tree
Petya rescued a few people from the fire
A thief was stopped by Petya yesterday evening ''')
a =my_str. replace('Petya', 'Artyom')
print(a) |
049f49eb279d683d12d04539e5cd5b42924b207e | seungbin-lee0330/2021 | /thisi_is_coding_test/ch7_binary_search/7-1-sequential-search.py | 658 | 3.703125 | 4 | def sequential_search(n,targe,array):
for i in range(n):
if array[i] == target:
return i + 1
print("생성할 원소 개수를 입력한 다음 한 칸 띄고 찾을 문자열을 입력하세요")
input_data = input().split() # 값들이 리스트안에 저장된다.
n = int(input_data[0])
target = input_data[1] # n,target = map(int,input().split()) 쓰면 한줄로... |
e36d712ff99326eec24d78e4995a3ca6365a1046 | seungbin-lee0330/2021 | /programmers_coding_test/42583.py | 762 | 3.859375 | 4 | # 입력받은 인자들을 최대한 잘 활용해서 새로운 문자를 최소화하자
def solution(bridge_length, weight, truck_weights):
answer = 0 # 경과시간
bridge = [0] * bridge_length # 전형적인 초기화 방법 도로를 시각화 함
current_weight = 0
while bridge:
answer += 1 # 시간을 먼저 더하고 시작하는게 맞다
current_weight -= bridge.pop(0) # 리스트를 큐처럼 쓰고싶을 때 자주쓴다
... |
9ddb75c2015e29885a5181b223218160c7953760 | seungbin-lee0330/2021 | /thisi_is_coding_test/ch12_problem/12-6.py | 986 | 3.609375 | 4 | def possible(answer):
for x,y,stuff in answer:
if stuff == 0: # 기둥인 경우
if y == 0 or [x-1,y,1] in answer or [x,y,1] in answer or [x,y-1,0] in answer:
continue
return False
elif stuff == 1: # 보인 경우
if [x,y-1,0] in answer or [x+1,y-1,0] in answer or ... |
a4f1d2e1f81f1fe0568e53dd206759e4d81efa12 | seungbin-lee0330/2021 | /thisi_is_coding_test/ch10_graph/10-1-disjoint sets.py | 838 | 3.953125 | 4 | def find_parent(parent,x): # 루트노드 찾기
if parent[x] != x:
return find_parent(parent,parent[x])
return x
def union_parent(parent,a,b):
a = find_parent(parent,a)
b = find_parent(parent,b)
if a < b:
parent[b] = a
else:
parent[a] = b
v,e = map(int,i... |
8a2be379d72656819967b743facb0c1bff21c568 | levf18/TallerExercism | /scrabble-score/scrabble_score.py | 513 | 3.625 | 4 | def score(palabra):
totalPuntos = 0
acum = ''
valores = {
'A': 1, 'E': 1, 'I': 1, 'O': 1, 'U': 1,
'L': 1, 'N': 1, 'R': 1, 'S': 1, 'T': 1,
'D': 2, 'G': 2, 'B': 3, 'C': 3, 'M': 3, 'P': 3,
'F': 4, 'H': 4, 'V': 4, 'W': 4, 'Y': 4, 'K': 5,
'J': 8, 'X': 8, 'Q': 10, 'Z': 10
... |
9236063776a54785b5b08ca9df09703434f3d179 | segunricardo/Homework_Repository | /PyPoll_Ricardo_M_Salas.py | 1,769 | 3.890625 | 4 | # PyBank Code
import os
import csv
# tells computer about path to dataset
csvpath = os.path.join("election_data.csv")
with open(csvpath, 'r', newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
next(csvreader, None) # Orders computer to skip first row of data (headers)
#creating variables ... |
85a855261320a7b58a6de882320aac52b3781c65 | Ishikanagar07/dynamic_programming | /grid_traveller_using_tabulation.py | 928 | 3.671875 | 4 | #Method 1
def grid_traveller(row, col):
table = [[0] * (col+1) for _ in range(row+1) ]
table[1][1] = 1
for i in range(1, row):
for j in range(1, col):
table[i][j + 1] += table[i][j]
table[i + 1][j] += table[i][j]
# right-most column
for i in range(1, row):
tab... |
8b863fa9ba0f6e729a5443ff270c072b8719ddf1 | Ishikanagar07/dynamic_programming | /howSum_using_memoization.py | 589 | 3.828125 | 4 | def howSum(targetSum, numbers, memo = None):
if memo == None:
memo = {}
if targetSum in memo:
return memo[targetSum]
if targetSum == 0:
return []
if targetSum < 0:
return None
for num in numbers:
ans = howSum(targetSum-num, numbers, memo)
if ans != No... |
241cd23eba6a5f431135a90918708ce6a351f4f9 | Saman-Afshan/Practice_automation | /Title.py | 383 | 3.515625 | 4 | from selenium import webdriver
class title():
def test(self):
driver = webdriver.Chrome(executable_path="F:\\Selenium_Pyhton\\chromedriver.exe")
url = "https://www.amazon.in/"
driver.get(url)
titl = driver.title
print("Title of the web page is: " + titl)
... |
82a0a6fb2202765ef891a935cb60032dc7009ec6 | RaglandCodes/Algos | /Boy or Girl.py | 227 | 3.71875 | 4 | '''
Codeforces A. Boy or Girl
https://codeforces.com/problemset/problem/236/A
'''
user_name_len = len(list(set(list(input()))))
if user_name_len%2 == 0:
print("CHAT WITH HER!")
else:
print("IGNORE HIM!") |
d5b7159f0fe5c9661f0c6330639812b1086be94f | RaglandCodes/Algos | /Pow(x, n).py | 695 | 3.53125 | 4 | '''
LeetCode 50. Pow(x, n)
https://leetcode.com/problems/powx-n/
'''
class Solution:
def myPow(self, x: float, n: int) -> float:
def power(xx, nn):
if nn == 0:
return 1
if nn == 1:
return x
if nn%2 == 0:
... |
734fddeb9b1f9d62e342f4ce775c8f2519c26d07 | RaglandCodes/Algos | /Count Number of Teams.py | 1,181 | 3.6875 | 4 | '''
LeetCode 1395. Count Number of Teams
https://leetcode.com/problems/count-number-of-teams/
How to append by value
https://stackoverflow.com/questions/8744113/python-list-by-value-not-by-reference
This is a brute force solution
'''
class Solution:
def numTeams(self, rating: List[int]) -> int:
... |
23fbb1664c7a0010392acca93dd152c2e756e45d | RaglandCodes/Algos | /Keyboard Row.py | 1,245 | 3.640625 | 4 | '''
LeetCode 500. Keyboard Row
https://leetcode.com/problems/keyboard-row/
'''
class Solution:
def findWords(self, words: List[str]) -> List[str]:
row1 = 'qwertyuiop'
row2 = 'asdfghjkl'
row3 = 'zxcvbnm'
a = []
for word in words:
... |
e042dbc6a56da02b66fa7f3ebf6c9aed37c5e255 | RaglandCodes/Algos | /Intersection of Two Linked Lists.py | 1,197 | 3.625 | 4 | '''
LeetCode 160. Intersection of Two Linked Lists
https://leetcode.com/problems/intersection-of-two-linked-lists/
Solution idea from Cracking the Coding Interview [Book].
'''
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self... |
b13207da1c1ff46d3c2cf86b8179e481cb5359ef | RaglandCodes/Algos | /Convert Integer to the Sum of Two No-Zero Integers.py | 802 | 3.75 | 4 | '''
LeetCode 1317. Convert Integer to the Sum of Two No-Zero Integers
https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/
'''
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
def noZero(num):
# Maybe this is slower.
#return st... |
99f64100cde51855fb28bac84325e418c04893eb | RaglandCodes/Algos | /Middle of the Linked List.py | 1,140 | 3.984375 | 4 | '''
LeetCode 876. Middle of the Linked List
https://leetcode.com/problems/middle-of-the-linked-list/
One can also use the runner technique.
The second pointer is travelling twice as fast and we just print the value of the node where the slow pointer is when the fast pointer reaches the end
https://leetcode.... |
0718fac8092c3b568b2b2ccc181f302d9a7c4738 | RaglandCodes/Algos | /Maximum Subarray.py | 527 | 3.59375 | 4 | '''
https://leetcode.com/problems/maximum-subarray
Solved using Kadane\'s Algorithm
https://www.youtube.com/watch?v=86CQq3pKSUw
'''
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
maxSum = nums[0]
thisSum = nums[0]
for i in range(1, len(nums)):
if(nums[... |
c437d86f6daa10852643affe1f4971472d927272 | RaglandCodes/Algos | /N ary Tree Postorder Traversal.py | 864 | 3.6875 | 4 | '''
LeetCode 590. N-ary Tree Postorder Traversal
https://leetcode.com/problems/n-ary-tree-postorder-traversal/
Answer from https://leetcode.com/problems/n-ary-tree-postorder-traversal/discuss/155806/Python-iterative-and-recursive-solution-with-explanation
'''
"""
# Definition for a Node.
class Node:
d... |
9ae4797fadcf8c7f4df5a1fed1544da536987e73 | RaglandCodes/Algos | /Unique Email Addresses.py | 687 | 3.5625 | 4 | '''
LeetCode 929. Unique Email Addresses
https://leetcode.com/problems/unique-email-addresses/
'''
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
for i, email in enumerate(emails):
at_index = email.index('@')
local_name = email[:a... |
0f5bc3dfd05cbf5f55d182e924444d7546644f23 | GabrielAlmeidaF/infosatc-lp-avaliativo-01 | /exercicio26.py | 156 | 3.8125 | 4 | n1 = float(input("Digite aqui um valor em metros quadrados a ser convertido: "))
n2 = n1*0.0001
print("{} metros quadrados são {} hectares".format(n1, n2)) |
f3c8be5f5f1bd0cc08ecb5b5985a60a066bee434 | GabrielAlmeidaF/infosatc-lp-avaliativo-01 | /exercicio20.py | 142 | 3.734375 | 4 | n1 = float(input("Digite aqui um valor em quilogramas a ser convertido: "))
n2 = n1/0.45
print("{} quilogramas são {} libras".format(n1, n2)) |
858ac4bf0083edb987503467ebc4951d4febc5d7 | thucdx/AoC2016 | /day03.py | 642 | 3.5 | 4 | from helper import *
IS_TEST = False
inp = 'input/day03'
if IS_TEST:
content = get_content_from_file(inp + '.sample')
else:
content = get_content_from_file(inp)
def is_triangle(arr):
arr = list(map(int, arr))
return 2 * max(arr) < sum(arr)
res = 0
# PART 1
# for pair in content:
# if is_triangl... |
5a0140214311146ac707e669b23c0924a62c6062 | eneajorgji/Laboratorium_podstawy_programowania | /Enea_Jorgji_lab_1.py | 1,071 | 3.609375 | 4 | # # Zadanie 1
# liczba_a = int(input("Podaj liczbe a: "))
# liczba_b = int(input("Podaj liczbe b: "))
#
# suma_a_i_b = liczba_a + liczba_b
#
# print(suma_a_i_b)
#
# # Zadanie 2
# licz_a = int(input("Podaj a: "))
# licz_b = int(input("Podaj b: "))
#
# if licz_a != 0:
# licz_x = -(licz_b / licz_a)
# else:
# print... |
adb146a8445075fef656188d91aadd9b358a7164 | YILINQ/leetcode_practice | /矩阵最大(String, Matrix, decima-binary).py | 1,049 | 3.75 | 4 | # 给定一个n*n的只包含0和1的二维矩阵,请你计算出该矩阵的最大值。
# 计算方式为将每一行的元素组成二进制数的十进制数相加,每一行元素可以进行左移右移(实质就是求出每行的最大值相加
# 比如说10001向左移一位就是00011
def binary_to_decimal(string):
n = len(string)
result = 0
for i in range(n):
result += int(string[i]) * (2 ** (n - i -1))
return result
def convert_row_max(row):
# row is a st... |
bb962659470d66cc4c40985467f96fc8b7eb19d0 | YILINQ/leetcode_practice | /House Robber III(DP on tree).py | 711 | 3.578125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rob(self, root: Optional[TreeNode]) -> int:
def DFS(root):
# lst[0]: use root
... |
d0de9f4a94d395499f87c7c304a70cc4e6055de2 | AkshatTodi/Machine-Learning-Algorithms | /Supervised Learning/Regression/Simple Linear Regression/simple_linear_regression.py | 1,693 | 4.46875 | 4 | # Simple Linear Regression
# Formula
# y = b0 + b1*X1
# y -> dependent variable
# X1 -> independent variable
# b0 -> Constent
# b1 -> Coefficient
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Salary_Data.csv')
# When... |
5e14397a2248c2ecfd54df6cd5834798645ee385 | cantseemy/py | /Project_5_4.py | 503 | 3.921875 | 4 | #! /usr/bin/env python3
import math
print("a * x^2 + b * x + c = 0 ")
a = int(input("a = "))
if a == 0:
while a == 0:
a = int(input("a = "))
continue
b = int(input("b = "))
c = int(input("c = "))
d = b**2-4*a*c
if d == 0:
x = -1*b/2*a
print("D = 0, Коренем рівняня є : ",x)
elif d < 0:
print("D < 0, Корені... |
a7832ef316383315e6b5dff34fd3e48fa9694a7e | cantseemy/py | /Project_4_2.py | 388 | 3.75 | 4 | #! /usr/bin/env python3
import math
a = float(input("Введіть змінну а : "))
b = float(input("Введіть змінну b : "))
c = float(input("Введіть змінну c : "))
'''
d = ((1)/(c*math.sqrt(2*math.pi)))
e = ((a-b)**2)*(-1)
g = (2*c)**2
h = math.exp(e/g)
print(d*h)
'''
print(((1)/(c*math.sqrt(2*math.pi)))*(math.exp((((a... |
565486d56e1ef32a751aab4bbc7653d5fce2ecef | AkiraKaneshiro/math295 | /HW5/HW05/work/Problem_2a.py | 2,742 | 3.515625 | 4 | import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
import collections
data = np.loadtxt("data/txtdata.csv")
n = len(data)
plt.bar(np.arange(n), data, color="#00dd2f", ec='none')
plt.xlabel("Day")
plt.ylabel("Number of texts received")
plt.title("Texts received over time.")
plt.xlim(0, n);
plt.save... |
16a7e58777a91a8c08e3d251fdde61fd2824addd | stokekld/foundations | /Python/chunkify.py | 505 | 3.90625 | 4 | def chunkify(s, n, fill='x'):
res = []
lenght = (len(s) / n)
filler = n - (len(s) % n)
if filler < n:
lenght += 1
first = 0
for x in range(0, lenght):
second = n * (x + 1)
res.append(s[first:second])
first = second
if filler < n:
for x in range(0, fi... |
88f62744497bdb5c5be2928b934762d1f132dfe3 | leeGYPlus/WayToPython | /LearnWithVideo/lesson27.py | 307 | 3.515625 | 4 | import json
# 字典转化为 json 对象
str = {'code':1025,'name':'mk','age':23}
print(json.dumps(str))
# json 对象转化为 字典
jsonObject = '{"id":353,"name":"3t35","age":35}'
print(json.loads(jsonObject))
#字典和json对象的区别 : ‘’ 和 “”(单引号和双引号的区别)
|
3fe433f784438c7a43d0cb8c488385d5fddb7980 | leeGYPlus/WayToPython | /one/Higher-orderfunction.py | 185 | 3.6875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a = 1
print (a)
#print a
def f(x):
return x * x
print(list(map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])))
print(list(map(str,[2,4,6,78,9,9]))) |
0e5aa24df3c189e21bca45e3eba3388e151edbde | JoeyCipher/Kattis | /quadrant.py | 183 | 3.8125 | 4 | x = int(input())
if x > 0:
y1 = int(input())
if y1 > 0:
print(1)
else:
print(4)
else:
y2 = int(input())
if y2 > 0:
print(2)
else:
print(3) |
d2cecdb8debdfb5b613df137eecbbd17ec5cb322 | mafsan786git/computer-graphics | /ellipse.py | 1,826 | 3.765625 | 4 | #Midpoint Algorithm to draw ellipse.
#Ellipse is symmetrical about quadrants.
#We need to consider about 1st quadrant of ellipse.All other three pixel we can get from corresponding pixel in 1st quadrant
#@Mkchaudhary 14th Sept 2018
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import sys
... |
ca7f41fa1bf6a654bc0a43608195df54d40a1644 | mafsan786git/computer-graphics | /para_circle.py | 1,113 | 3.75 | 4 | #Parametric form of circle drawing
#@MKchaudhary 15th sept 2018
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from math import *
import sys
def init():
glClearColor(0.0,1.0,1.0,0.0)
glColor3f(1.0,0.0,0.0)
glPointSize(2.0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(-640.0... |
81d28f7e974c142d2792a4983342723fb8e7a712 | SarahMcQ/CodeWarsChallenges | /sortedDivisorsList.py | 618 | 4.1875 | 4 | def divisors(integer):
'''inputs an integer greater than 1
returns a list of all of the integer's divisor's from smallest to largest
if integer is a prime number returns '()is prime' '''
divs = []
if integer == 2:
print(integer,'is prime')
else:
for num... |
2013f87ced194165833a135c1cc6224e081a4594 | juankmiloh/Ejercicios | /ex17_More Files.py | 708 | 3.625 | 4 | from sys import argv
from os.path import exists
fileOne = 'test.txt'
fileTwo = 'new_file.txt'
argv.extend([fileOne, fileTwo])
script, from_file, to_file = argv
in_file = open(from_file, 'w')
text = raw_input("Write your text here:\n\t>>>")
in_file.write(text)
print "Copying from %s to %s" % (from_file, to_file)
# W... |
56703aff17eaeb7119ebf0907e435fc29cb04a9c | kem424/python-challenge | /PyPoll/main.py | 1,947 | 3.65625 | 4 | #Modules
import os
import csv
#open CSV file
file=os.path.join('Resources','election_data.csv')
with open (file, 'r', newline= "") as csvfile:
reader=csv.reader(csvfile, delimiter= ",")
#variables
total_votes = 0
candidates= []
individual_votes = []
for row in reader:
#Total Votes
total_vo... |
b399078d2064fddda523b1c14c3a662abc0e7285 | raymondhcyu/pythonSerialReadAndPlot | /pythonSerialRead.py | 6,067 | 3.578125 | 4 | # INFO
# Read and receive data from serial port and print to console_output
# Print serial only; for plotting see other file
# User input COM and baud rate with exceptions if error
#
# QUICK START
# 1) Flash microcontroller board with operational code
# 2) Press and hold reset button microcontroller board to begin tran... |
53a9a0785f2a819917acd81c0c54bc0a680aaff9 | edjrbashian/piglatin | /piglatin.py | 462 | 3.9375 | 4 | #English to pig-latin translator
#Edward Djrbashian
#define suffix
pyg = 'ay'
#ask used for word
original = raw_input('Enter a word:')
#define first letter of string
first = original[0]
if len(original) > 0 and original.isalpha():
#check if vowel or consonant
if first == ('a' or 'e' or 'i' or 'o' or 'u'):
... |
eefb19d29a24ee3f9e2c4f5ac6bce1b8c65d31ab | LuongMonica/cit270L | /10/Monica-Luong-lab10-sec2-exer2.py | 826 | 3.84375 | 4 | #!/usr/bin/python3
# this script gets name of a server log file,
# reads it and censors the first 3 segments of all IP addrs
# i.e: 123.4.56.78 --> xxx.xxx.xxx.78
# used for regex
import re
# used for renaming file
import os
# get input for server log file
log = str(input("Enter the server log file you want to censo... |
94d15f497b9ca771ec1a7102545d9b285a7caae8 | ceneri/Artificial-Intelligence | /P2/p2/search.py | 9,061 | 3.5 | 4 | # search.py
# ---------
# Licensing Information: Please do not distribute or publish solutions to this
# project. You are free to use and extend these projects for educational
# purposes. The Pacman AI projects were developed at UC Berkeley, primarily by
# John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.be... |
fc710e578300d9371f3d88acced0b05128bb466f | Rebeljah/Alien_Invasion | /alien.py | 5,414 | 3.515625 | 4 | import pygame as pg
import random
import os
from settings import scale
class AlienFleet(pg.sprite.Group):
"""Class used to control the fleet of aliens on screen, inherits from Group"""
def __init__(self, game):
super().__init__()
"""
Find the best spacing between each alien in the fle... |
4572945889f6fa7508835e33bb95cd51988b0de5 | technodumb/Mission-Impossible | /Hackerrank/Project Euler/2.py | 360 | 3.75 | 4 | def evenfib(n):
if n < 1:
return n
elif n==1:
return 2
else:
return (4 * evenfib(n-1))+evenfib(n-2)
for _ in range(int(input())):
n = int(input())
i,s = 1,0
while True:
term = evenfib(i)
if term>n:
break
else:
... |
fcccf43cbf41525c6fd00a5e7f695d2e79b91ecd | technodumb/Mission-Impossible | /Hackerrank/Code Actually/day20.py | 210 | 3.8125 | 4 | n = int(input())
l = list(range(2**n))
for c in range(1,n):
for j in range(2**c, 2**n, 2**(c+1)):
l[j:j+2**c] = reversed(l[j:j+2**c])
for i in l:
print(i,end=' ')
# 0 1 3 2 4 5 7 6
# n = 3
|
3fcd8e7835d6f5b898660fcee3c6bbe598809350 | adikele/data-science-course | /mainExercise2approach2.py | 4,962 | 3.921875 | 4 | '''
Part Solutions to Exercise 2
This exercise uses two approaches to create a summary dataframe
-- Option1: using groupby -- summary dataframe that groups flights according to ORIGIN
-- Option2: summary dataframe has been created from dictionaries, grouping flights according to ORIGIN
'''
import pandas as pd
import n... |
0c61bf656a1059d69c60a21417ea8c77accd10e1 | gic91/script_lang | /Small_map_state.py | 716 | 3.578125 | 4 | import game_framework
import urllib.request
from tkinter import *
from tkinter import font
from tkinter import Tk, ttk, StringVar,messagebox
name = "Main"
#나라 이름
def Nation_name(name):
global nation_name
nation_name = name
def enter():
run()
def exit():
pass
def pause():
pass
def Back():
pass
... |
d9ee14c8656a23d993673b0d275be99e65488131 | EliaDassio/TPSIT | /movement_turtle.py | 831 | 3.65625 | 4 | import turtle
bor = 200
player = turtle.Turtle()
player.shape("circle")
player.color("pink")
play = turtle.Screen()
player.left(90)
def up():
player.forward(50)
print("up")
def left():
player.left(90)
player.forward(50)
player.right(90)
print("left")
def down():
p... |
2137cdfeb8ec4f7ac998b57dab3fa35e864af3e8 | AidenTran15/My-Powers | /convert_weight.py | 502 | 3.828125 | 4 | import sys
weight = input("enter your weight: (kg or lbs)")
if " " not in weight:
print("Please have space between the number and unit in your input")
sys.exit()
weightArr = weight.split()
weightNum = float(weightArr[0])
unit = weight[1]
if "kg" in weightArr:
weight_lbs = weightNum / 0.45359237
... |
372da9a90f509c50a08b41fe2c5f725d02a3ac50 | AidenTran15/My-Powers | /calculate_age.py | 85 | 3.65625 | 4 | birth_year =int(input("Enter your birth year: "))
age = 2019 - birth_year
print(age) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.