blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3a976446c78485e0769b189467893be1ec943b11
tcoln/Python-Leetcode
/31.NextPermutation.py
979
3.625
4
class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. :note: 分两步走:首先从后往前遍历i,找到i后面比i 大 且 最小数minJ,交换i和minJ;然后将i后面的数升序排序 """ #nums = [2,3,1] #nums = [3,2,1...
6ab8e0401658ecc3716f2f1d3fbebcca294ea1df
tcoln/Python-Leetcode
/112.路径之和_判断是否存在.py
1,802
3.984375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def hasPathSum(self, root, suma): """ :type root: TreeNode :type sum: int :rtype: bool ...
5f03412064f1b805e66fb89b722afb51562c2b00
gustavomachadods/cienciadedados
/fala_usuario2.py
99
3.65625
4
# Entrada de dados y = input("Qual seu nome? ") # Saída de dados print("O seu nome é: ",y)
3e7768464f2dcd33e7b8806d37a4c01786cb14b7
plasticanthony/random-scraper
/random-scraper.py
1,534
3.5625
4
import requests from bs4 import BeautifulSoup import random # Enter valid username and password for Princeton account. username = 'USERNAME' password = 'PASSWORD' url = 'https://www.princeton.edu/collegefacebook/search/' # Select the number of random names you would like. num_to_scrape = 30 # Format query based on ...
d32e0e66e23845ea42b97f857657a1e7e1037bce
chinmay-d/assignments
/contact.py
1,575
4.0625
4
class Contact(object): def edit_cont(self) : name = input('Enter name: ') fh = open('contact.txt') for line in fh : line = line.rstrip() if line.startswith('Name: ') : nm = line[0] + line[1] if nm == ('Name: ') + name : ...
7b63eb5ae049dd1c863cb57370533ea892e995b1
hoka-sp/NLP100
/knock100/knock06.py
674
3.75
4
# “paraparaparadise”と”paragraph”に含まれる # 文字bi-gramの集合を,それぞれ, XとYとして # 求め,XとYの和集合,積集合,差集合を求めよ. # さらに,’se’というbi-gramがXおよびYに含まれる # かどうかを調べよ. def n_gram(str, n): return [str[bit:bit + n] for bit in range(len(str) - n + 1)] sample1 = 'paraparaparadise' sample2 = 'paragraph' X = n_gram(sample1, 2) Y = n_gram(sample2, 2)...
a21da387f0bf7619a3115340754c4d77f6cb6245
hoka-sp/NLP100
/knock100/knock17.py
702
3.6875
4
import sys def make_line_list(file, split): result = [] for line in file: r_strip_line = line.rstrip('\n') list_in_list = r_strip_line.split(split) num_box3 = list_in_list.pop() num_box2 = list_in_list.pop() list_in_list.append(int(num_box2)) list_in_list.append...
92ad8b03ded02cf8612e91616e2af7a7b3cd2196
kylekizirian/honey
/python/src/honey/binarysearch.py
734
3.84375
4
""" Binary Search Given a sorted list, finds the index of a given element in log(n) time. """ from typing import List def binary_search(list_: List, element) -> int: """Given sorted list_, returns index of element or -1 if not found If the element exists multiple times in the list, any index where it ex...
de62967b2fc7227e29c38c335915aa47be2aef22
annadebiasi/HybridSorting
/DoublyLinkedList.py
8,486
3.578125
4
""" PROJECT 3 - Quick/Insertion Sort Name: Anna De Biasi PID: """ from Project3.QuickSort import quick_sort class DLLNode: """ Class representing a node in the doubly linked list implemented below. """ def __init__(self, value, next=None, prev=None): """ DO NOT EDIT Construct...
36d5558222203f876f7dcfc77e45e91ba1c67d4e
AmeySaware/value-of-e
/e_as_sum_of_random_numbers.py
889
3.78125
4
# Created by Amey Saware """ In the book "The Simpsons and their mathematical secrets" Simon Singh states that if you generate random numbers and add them, the average of numbers required for the sum to exceed 1 tends to e as number of trials tends to infinity. This program tests this conjucture for its validity by m...
57287771f08d250297b4f4613433d7c6d5dff7d1
olufemi424/algorithms
/ALGO/PY/sortColors.py
1,396
4.09375
4
# Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. # We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. # You must solve this problem withou...
956ec13c5d47ba9738ec2ce585db86dbf6f3bc40
Movesky98/python
/2017038072 권동천 6주차 과제2.py
547
3.875
4
import threading import time class calculator : cal = 0 def calculation(self, maxnumber, i) : for self.i in range(1, maxnumber+1, 1) : self.cal += self.i print("\n1+2+3+ . . . +%d = " % maxnumber) print(self.cal, end='') time.sleep(0.1) cal1 = calculator() cal2 = ...
e1a53eec046f5ff32c4aa6401539f2b3f264ec69
sparsht123t/python
/input.py
1,065
3.890625
4
import sqlite3 import datetime def insert(roll_no,fname,lname,day,status): conn=sqlite3.connect("college.db") cur=conn.cursor() # print(roll_no,fname,lname,day,status) cur.execute("INSERT INTO attendance VALUES (?,?,?,?,?)",(roll_no,fname,lname,day,status)) conn.commit() conn.close() ...
eff399c6aab49dad0baa2534ab7cac726f54c40e
felipemesina/StringsAndLists
/stringsandlists.py
561
3.859375
4
words = "It's thanksgiving day. It's my birthday, too!" print words.find("day") newwords = "It's thanksgiving day. It's my birthday, too!" print newwords.replace("day", "month") x = [2, 6, 8, 1, 20, 11, 3, 7] print (min(x)) print (max(x)) y = ["name", 20, "hi", "bye", 7, "hello", 1, 4] print y[0] print y[-1] z=[y[0]...
93119f94b6368c868556d23f4ac001598587408a
KIRINPUTRA/TOOLS-GENERAL
/sort_csv.py
627
3.984375
4
import csv, sys, operator filename = input("Please enter the name of the .csv file you want sorted.\n") if filename[-4:] != ".csv": filename += ".csv" key_col = int(input("Which column do you want to sort by? Enter 1 to sort by the first column, 2 to sort by the second column, and so on.\n")) - 1 with open(filen...
b85fce57444c566298af2487d0e32f4c48a15830
mgardner3901/String-Jumble
/stringjumble.py
1,649
4
4
""" stringjumble.py Author: Morgan Gardner Credit: stackoverflow.com, Billy Bender Assignment: The purpose of this challenge is to gain proficiency with manipulating lists. Write and submit a Python program that accepts a string from the user and prints it back in three different ways: * With all letters in rever...
b12c1e13904ab246f433840dfbae1c3c892a872f
dhruv-pandit/MSPBookDatabasesProject
/GUI-SEARCHBAR.py
3,007
3.703125
4
# Graphic User Interface from functools import partial from tkinter import * # in tkinter canvas/window where every graphical element is located in root from database_holder import SearchData, update root = Tk() # ----------------------------------------------------------------------------------------------...
703291041cd3b1630b2e5b9a64077875d5f7e39e
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 3 ( Introducing Lists )/Exercises/3-10every-function.py
708
4.125
4
list_of_things_excited = ['Yamishibai Season 8', 'Disenchantment Part 3', 'Halo Infinite', "Five Nights At Freddy's: Security Breach"] list_of_things_excited.reverse() # Regardless if you reverse the order, I still am excited for them all list_of_things_excited.reverse() # Reversing the list back to its original sta...
e901e8d3c28752ba84f4935828137199a490528b
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 7 ( User inputs and while Loops )/Exercises/7-2restaurant-seating.py
245
4.09375
4
group_number = input("How many people are in your table group? ") group_number = int(group_number) if group_number > 8: print("Unfortunately, you'll have to wait for another table to become vacant.") else: print("Your table is ready.")
2c600d367c865d4c06a4163886e1137e94f07ebc
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 3 ( Introducing Lists )/Exercises/3-8seeing_the_world.py
645
4.34375
4
places = ['Brazil', 'England', 'Australia', 'Disneyland', 'Kitten Land'] # please let Kitten Land be a place. print(places) print( sorted(places) ) print(places) # Printing out the original list print( sorted(places, reverse=True) ) # printing out a reverse alphabetical version of the list print(places) # Still pr...
c7cc882a779a8fd6f4f403ac519516386910bbac
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 5 ( If Statements )/Exercises/5-7favorite_fruit.py
458
4
4
favorite_fruits = ['banana', 'apple', 'orange'] # I really don't eat that many fruits :l if 'banana' in favorite_fruits: print("You really like bananas!") if 'apple' in favorite_fruits: print("You really like apples!") if 'orange' in favorite_fruits: print("You really like oranges!") if 'pineapple' in ...
e588d31db5665b6f3664d9c3b8209bbfbca4b365
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 5 ( If Statements )/Exercises/5.2more_conditional_statements.py
1,024
3.96875
4
first_word = "cookie" second_word = "Cookie" # These if statements are case sensitive if first_word == second_word: print("\nYes") if first_word != second_word: print("\nFirst_word is not equal to second_word") # This conditional statement should be case insensitive if first_word.lower() == "cookie": pr...
75d91a7c4ef845befdb004318a27ddad8a5beca2
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 6 ( Dictionaries )/Exercises/6-9favorite_places.py
376
4.03125
4
favorite_places = {"Am" :['Akhibara, Japan'], "S" :['Mumbai, India'], "E" :['Lagoona Lake'], "A" : ['Chipotle'], "C" : ['Lotus Cove'] } for name, place in favorite_places.items(): print(f"The person's name is {name} an...
85b9003383b0eb815bb3a83854e81f4a65ff3c7d
SomethingRandom0768/PythonBeginnerProgramming2021
/Chapter 6 ( Dictionaries )/Exercises/6-3glossary.py
800
4.46875
4
words = {'List': 'Structure containing objects, strings, or numbers', 'Conditional test': 'Simple expression to test whether something is equal or not', 'Pop method': 'Method used to remove the last index of a list but allow you to use that value', 'elif': 'else - if, used if the first condi...
8980d2995f4ac0c2d1c5b54816574596a027a316
ridgekimani/bucket_list
/tests/unit_tests.py
14,034
3.8125
4
""" This module is for testing some of the implementations that will be used through out the app """ import datetime import unittest from app.app import DB, app from flask_testing import TestCase def load_data(): """ This function is used to load data that will be used for the tests :return: """ ...
c4a8bf3756935a1b8876fbb15c3c5335bf489c4e
monjurul003/algorithm-problems
/extractTargetSubstrings.py
757
4.125
4
#Extract all the the combinations of a target substring that appear in a source string. I.e: target: #"abc", source:"abcdefgbcahijkacb12df", solution: {abc, bca, acb} def hash_function(s): if s == None or len(s) == 0: return 0 hash = 0 for c in s: hash = hash + 26 * (ord(c) - ord('a')) return hash def fin...
e5251b1efbe2343305dacc14762d8630e5ebe887
monjurul003/algorithm-problems
/quickSort.py
514
3.9375
4
# recursive version of quicksort def partition(arr, l, h): x = arr[h] i = l-1 for j in xrange(l, h): if arr[j] < x: i = i + 1 temp = arr[i] arr[i] = arr[j] arr[j] = temp temp = arr[i+1] arr[i+1] = x arr[h] = temp return i+1 def quickSort(arr, l, h): if l < h: p = partition(arr, l, h) q...
c2f841591b64c7dd5f0d93269fa39be0bc80a4c7
monjurul003/algorithm-problems
/word_one_edit_transform.py
1,827
3.96875
4
# Given a dictionary of words, write a function that takes two words as input and returns the minimum number of # transformations (intermediate words) to reach from the source to destination word. At each transform step, only # one character can be edited or changed at that time. At each step the generated intermediate...
362d7bcd4950b434f132e972f89cdb1a895915b9
monjurul003/algorithm-problems
/inOrderSuccessor.py
511
3.84375
4
## aLgo to find inorder successor of a node ## inputs to the function are root node and the node ## for which we find the successor from BSTLib import * if __name__ == "__main__": a = map(lambda x: int(x), raw_input().split(" ")) root = None bst = BST() for d in a: root = bst.insertNode(root, d) print "Ini...
b3e4d12a323d27a40ce1ce7ac739f1e9efa133d2
monjurul003/algorithm-problems
/min_platforms_trains.py
909
3.875
4
# Given two arrays containing arrival and departure times of trains from a station, find the min number of platforms # required such that no train waits def find_min_platforms(arrs, deps, N): if not arrs: return 0 if len(arrs) == 1: return 1 platforms_needed = 1 result_max = 1 i...
a62877b50b977bb045614a7c7b30a57129d81714
monjurul003/algorithm-problems
/TernarySearchTree.py
894
4.21875
4
# A Basic Ternary Search tree implementation # It allows insertion, search and nearest word lookups. class Node: def __init__(self, c): self.char = c self.left = None self.right = None self.equal = None self.end = False class TernarySearchTree: def __init__(self): self.root = None def insert(self, wo...
9035eb58277c48d254cdb293a5653ebb1a171791
monjurul003/algorithm-problems
/naive_pattern_matcher.py
554
3.875
4
# Given a text T[0...n-1] and patter p[0...m-1], find all the indexes where the pattern matches the string def naive_pattern_matcher(text, pat): if not pat: return True if not text: return False N = len(text) M = len(pat) for i in range(N-M+1): for j in range(M): ...
61871c98fb68c3a61172e07befd0de52fe5c709e
millicentwanjiku/revisiononprime
/primeno.py
584
4.0625
4
def prime_num(number): ''' The function returns a list of prime numbers ''' primenumbers = [] isdivisible = True if not isinstance(number, int): return "only intergers are allowed" if number < 0: return "Negative numbers not allowed" else: for i in range(2, numbe...
3c21fc239f4dd9e6dce9d206842da65e1d8dcfff
Lex99/project
/ET.py
25,808
4.1875
4
import math # split a string into mathematical tokens # returns a list of numbers, operators, parantheses and commas # output will not contain spaces def tokenize(string): splitchars = list("+-*/(),") # surrounds any splitchar by spaces, numbers are left alone: tokenstring = [] for c in string: ...
39503031a21bf088eed59ab65a950dd46ac20d4e
digital-diplomat/Project-Eurler
/pEuler1.py
232
3.53125
4
# Euler project Q.No 1 def sum_of_multiplies(n, m): mult_sum = 0 for i in range(3, 1000): if i % n == 0 or i % m == 0: mult_sum += i return mult_sum print(sum_of_multiplies(3, 5)) # answer: 233168
17c025ef6df80bd73fb340a22fc48cfb69cb0d64
ValentinLeMorvan/Ariadne-s-Thread
/LongestPath.py
1,469
3.734375
4
def BellmanFord (AdjacencyMatrix, start, end): weight = {} pred = [] AdjacencyList = {} level = 0 longestPath = [] #creation of the adjacency list for the given matrix for i in AdjacencyMatrix: l = [] level +=1 j = 0 for val in i: j += 1 ...
d171a9335758f9de1f9dde2daf9bfba0874e892d
loucq123/Coursera
/IP_Python/part1/guess-the-number.py
1,386
3.984375
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random # helper function to start and restart the game def new_game(): global trueNumber, steps # define event handlers for control pan...
c6c9aef3bb2494dea5821f0c58c0055b938ad8b8
newking9088/BCH5884-Programming-For-Chemist-and-BioChemist
/classWorks/OOP_example_2.py
1,232
4
4
#!usr/bin/env python3 class Employee: def __init__(self,name,idnum,salary=0): self.name = name self.idnum = idnum self.salary = salary def work(self): print(self.name, "does stuff") def giveraise (self,percent): self.salary = self.salary + (self.salary * percent/100)...
f3180699c36eb5ca386e3aea258de445396969c5
sheridanwall/Python_Functions
/Homework_4_functions_Wall.py
17,947
4.3125
4
#!/usr/bin/env python # coding: utf-8 # ## homework 4.2: investigating lists and dictionaries using functions # # In this assignment I will ask you to pick five relatively short texts (poems, paragraphs, short essays, song lyrics, whatever interests you). The main thing is to make sure that each text is around 10 - 2...
81c67a30a1970473a4bc74fe5dd41a9a2fb5b161
ammar-abu-yaman/Simple-wep-calculator
/Calculator/BackEnd/Calculator/Calculator.py
5,274
3.84375
4
from math import cos, sin, tan, atan, acos, asin, sqrt, pi, e, log10, log def tokenize(exp): tokens = list() exp = " " + exp + " " prev = " " # prev is used to notify the algorithm when parsing (-) to know whether it is subtraction or a minus sign of a number n = len(exp) i = -1 while i < n:...
da099bcabde84a4e91237df4bd726b030d867884
danrneal/show-me-the-data-structures
/blockchain.py
2,893
4.59375
5
"""Implement a blockchain as a linked list. Usage: blockchain.py Classes: Blockchain() Block() """ import hashlib from datetime import datetime class Blockchain: """Blockchain object that stores blocks as a linked list. Attributes: prev_block: A Block object representing the most recently ...
7d86b7fa662aecceb28da1d5694fe4e719110833
Ramkumar6868/coursera_data_structer
/week2_algorithmic_warmup/4_least_common_multiple/lcm.py
363
3.5625
4
# Uses python3 import sys def lcm_naive(a, b): if a > b: c, tmp = a, a d = b else: c, tmp = b, b d = a while c % d != 0: c = c + tmp # for l in range(c, a*b+1): # if l%a == 0 and l%b==0: # return l return c # return a*b a, b = map(int...
fc74253581ece4b38ead55bdd9f2a949c283262d
WMBYCK/Variables
/ClassExercises_RevisionExercise_1.py
514
3.828125
4
# William Craddock # 17-09-14 # Class Exercises - Revision Exercise - 1 print("Enter four integers and the total will be displayed") print() input_number = int(input("Please enter the first number? ")) input_number1 = int(input("Please enter the second number? ")) input_number2 = int(input("Please enter the th...
dffc7afdad1d56e55d831518318674fdf5f4dff8
Devang-25/Interview-Process-Coding-Questions
/LeadSquared/totalDistanceByStreetLights.py
1,331
3.984375
4
""" Coding Test - Round 1 Given N street lights, and an array of tuples which signify the start and end distances of street covered by that street light. Find the total distance covered by all the street lights Ex:1 N = 1 arr = [(5,10)] Number of street lights = 1 and distance covered by street ligh...
7c680424dadd285d84bac00206313c77e8e37aae
jdzz112/data-analysis-project
/bikeshare.py
6,242
4.125
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name o...
9dc528c7f6cb9b9b4442fc44e30c1f1b42e66873
GhazaryanLusine/Python_1_ASDS
/problem3.py
239
3.703125
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("text", type=str) args = parser.parse_args() print("The given text:", args.text) print("All lowercase:", args.text.lower()) print("All uppercase:", args.text.upper())
0d115e25deaad784bca69faf019aa2ce5a63a37c
m-alansary/Mathematical-Thinking-in-Computer-Science-Assignments
/is_even_permuations.py
516
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 20 15:32:41 2018 @author: Ansary """ def is_even_permutation(p): sign = 0 s = 0 n = len(p) while s < n: u = s while u < n: if p[u] < p[s]: tmp = p[s] p[s] = p[u] ...
49b527c94ebbfb29778c2541a8127363c4b33a7c
toropippi/2D_Fluid_Simulation_Python-HSP
/cfd.py
5,371
3.609375
4
import numpy as np import matplotlib.pyplot as plt DELTAT=0.5#Δt OMEGA=1.8#SORの加速係数 #移流。壁のところは速度を更新してないことに注意 def Advection(x,y,vx,vy): vx_after = np.zeros((x + 3, y + 2), dtype=np.float64) # x速度 vy_after = np.zeros((x + 2, y + 3), dtype=np.float64) # y速度 #x方向の移流 for i in range(2,x+1): for j i...
8cbeaf0c0c063e155861b05994c1ad62aadcf24c
DyuldinKS/stepik.algorithms
/6.4/1.py
845
3.890625
4
def merge_counting_inversions(a, b, invs = 0): merged = [] while a and b: if a[-1] <= b[-1]: merged.append(b.pop()) else: merged.append(a.pop()) invs += len(b) merged.reverse() merged = (a or b) + merged return merged, invs def count_inversion...
d8cc408aa5ed76531b904423b5c6d98023ff21fc
qdonnellan/projecteuler
/python/problems/problems_01_25/problem_25.py
153
3.5
4
# What is the first term in the Fibonacci sequence to contain 1000 digits? a, b, n = 1, 1, 2 while len(str(b)) < 1000: a, b, n = b, a+b, n+1 print n
d80c78b6a8bf3c04d519cf9246490e13fd3bda83
qdonnellan/projecteuler
/python/problems/problems_01_25/problem_24.py
233
3.5
4
# What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? from itertools import permutations s = permutations('0123456789') s = list(s) print s[999999] #index 999999 is the 1,000,000th element
295ead955ebc09d697ba58dfab2427dde3e118a4
qdonnellan/projecteuler
/python/problems/problems_01_25/problem_14.py
956
3.765625
4
# The following iterative sequence is defined for the set of positive integers: # n => n/2 (n is even) # n => 3n + 1 (n is odd) # Using the rule above and starting with 13, we generate the following sequence: # 13 => 40 => 20 => 10 => 5 => 16 => 8 => 4 => 2 => 1 # It can be seen that this sequence (starting at 13 an...
8eb54c51898c1078b6e4ef8e0822f86097536a5d
qdonnellan/projecteuler
/python/problems/problems_01_25/problem_06.py
300
3.984375
4
def sum_squared_less_squared_sum(first_n): """ return the result: A - B where A is the square of the sum of all first_n ints and B is the sum of the suquare of all first_n ints """ A = sum(range(1,first_n+1))**2 B = sum([x**2 for x in range(1, first_n+1)]) return A-B
3e166da3c118e2c213f5a29610b2de517c41c73d
akshaynannaware/Codeshef-problems
/Smallest_KMP.py
1,979
3.84375
4
'''. He also has another string P, called pattern. He wants to find the pattern in S, but that might be impossible. Therefore, he is willing to reorder the characters of S in such a way that P occurs in the resulting string (an anagram of S ) as a substring. Since this problem was too hard for Chef, he decided to ask...
f2c71f033caa3993a3d7b6fee96da3d21643e760
anticlockwise/challenges
/python/level15.py
514
3.6875
4
#!/usr/bin/python # -*- coding: utf-8 -*- ''' File: level15.py Author: rshen <anticlockwise5@gmail.com> Description: The Python Challenge Level 15 (Whom?): http://www.pythonchallenge.com/pc/return/uzi.html ''' import datetime # he ain't the youngest, he is the second # todo: buy flowers for tomorrow # Check on Googl...
4f183827b7bdfe297c68b5542f4df47cd6262d67
tails1434/Atcoder
/ABC/081/A.py
134
3.546875
4
S = str(input()) count = 0 if S[0] == '1': count += 1 if S[1] == '1': count += 1 if S[2] == '1': count += 1 print(count)
a1b78124258c61c19ce5202eda64bb15d7d94237
tails1434/Atcoder
/ABC/144/D-1.py
351
3.71875
4
import math from decimal import * def main(): a, b, x = map(int, input().split()) if Decimal(a) * Decimal(b) / Decimal(2) >= Decimal(x) / Decimal(a): else: c = Decimal(b) * Decimal(b) * Decimal(a) ans = math.degrees(math.atan(Decimal(c)/decimal(x))) print(90 - ans) if __n...
0c925281ff737e042cc099ea9814750ca506ac0b
tails1434/Atcoder
/ABC/097/C.py
217
3.5
4
def main(): s = input() K = int(input()) S = set() for i in range(len(s)): for j in range(1, K+1): S.add(s[i:i+j]) sort_S = sorted(list(S)) print(sort_S[K-1]) main()
fdecc2cbdc667882fa1b5f771a4eb45452740fae
tails1434/Atcoder
/ABC/053/B.py
241
3.515625
4
s = input() index_A = float('inf') index_Z = -1 for i in range(len(s)): if s[i] == 'A': if i < index_A: index_A = i elif s[i] == 'Z': if i > index_Z: index_Z = i print(index_Z - index_A + 1)
6d95439edd8faec3237c0a8f8a84a48aea4404e1
tails1434/Atcoder
/ABC/152/E-1.py
497
3.5
4
from fractions import gcd from functools import reduce def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) def main(): N = int(input()) A = list(map(int, input().split())) MOD = 10...
5650ae57eedebcd316625d0f70c10183ec66001b
tails1434/Atcoder
/ABC/143/D-1.py
648
3.640625
4
def isOK(a,index,key): if a[index] >= key: return True else: return False def binary_search(a,key): ng = -1 ok = len(a) while abs(ok - ng) > 1: mid = (ok + ng) // 2 if isOK(a,mid,key): ok = mid else: ng = mid return ok def ...
e61dee99275319a92cc0dae27f3d7116536a7870
tails1434/Atcoder
/ABC/151/F.py
1,884
3.65625
4
from math import hypot def half_point(p1,p2): x = (p1[0] + p2[0]) / 2 y = (p1[1] + p2[1]) / 2 r = hypot(p1[0] - p2[0], p1[1] - p2[1]) / 2 return (x, y, r) def three_points_on_a_line(p1,p2,p3): dx1 = p1[0] - p2[0] dy1 = p1[1] - p2[1] dx2 = p1[0] - p3[0] dy2 = p1[1] - p3[1] return d...
bd341bf15d69ed64394f6c79d09462c22609904d
tails1434/Atcoder
/ABC/106/B.py
244
3.53125
4
def main(): N = int(input()) cnt = 0 for i in range(3, N + 1, 2): div = 0 for j in range(1,i+1): if i % j == 0: div += 1 if div == 8: cnt += 1 print(cnt) main()
1682f7480c9b42e43061bb892e5f927b95761e6d
tails1434/Atcoder
/ABC/043/Unhappy_Hacking.py
249
3.546875
4
s = input() output = "" cnt = 0 for i in s: if i == "0": output += "0" cnt += 1 elif i == "1": output += "1" cnt += 1 elif i == "B": if output != "": output = output[:-1] print(output)
90613714d73fce83a32ef116433eb1df20374aee
tails1434/Atcoder
/ABC/011/substraction.py
363
3.5625
4
N = int(input()) NG = [int(input()) for _ in range(3)] if N in NG: print('NO') exit() for i in range(100): if N - 3 not in NG: N = N - 3 elif N - 2 not in NG: N = N - 2 elif N - 1 not in NG: N = N - 1 else: print('NO') exit() else: if N <= 0: ...
c82f9835dff57c6efc44c1dcb258c06d67095bcf
tails1434/Atcoder
/ABC/142/D.py
612
3.671875
4
import itertools def divisor(n): ass = [] for i in range(1,int(n**0.5)+1): if n%i == 0: ass.append(i) if i**2 == n: continue ass.append(n//i) return ass def is_prime(n): if n == 1: return False for i in range(2,int(n**0.5)+1): ...
6dc6b3cf448641c024aedcb6b5a5b1b2980f1873
tails1434/Atcoder
/ABC/168/A.py
208
3.640625
4
def main(): N = input() if int(N[-1]) in (2,4,5,7,9): print('hon') elif int(N[-1]) in (0,1,6,8): print('pon') else: print('bon') if __name__ == "__main__": main()
a5775302b163e8eca4f59ad857f79ea08e4acb76
tails1434/Atcoder
/ABC/086/B.py
166
3.765625
4
import math def main(): a, b = input().split() ab = int(a + b) if math.sqrt(ab).is_integer(): print('Yes') else: print('No') main()
9698b6a6492de56911b71047ddd09952c8e674e5
tails1434/Atcoder
/ARC/090/D-1.py
855
3.546875
4
class UnionFind(): def __init__(self, main): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x...
517a7475907e0f9ee2ded1d42e793a6c707ea159
tails1434/Atcoder
/ABC/168/C.py
635
3.796875
4
import math from decimal import Decimal def get_distance(x1, y1, x2, y2): d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) return d def main(): A, B, H, M = map(int, input().split()) deg_H = (360 // 12) * H + 0.5 * M deg_M = (360 // 60) * M x_A = A * Decimal(math.sin(math.radians(deg_H))) ...
a595fcc65f12e9f456904bfd9e88257df6a6e7a2
bojana-rankovic/cnt_no_game
/mojbroj.py
9,607
3.5625
4
from random import random, randint, shuffle, choice import math from copy import deepcopy from math import log import numpy as np from pythonds.basic.stack import Stack def is_number(s): try: float(s) return True except ValueError: return False def postfix_evaluation(s): s = s.spl...
f194e243d44f7f1f78c8964fcb3570d6b813454d
Mohammed-Adnan-MA/Test-Answers
/Answers.py
1,712
3.78125
4
#1: Module: #Reading data function def readingData(name, age, length): name= raw_input("Enter a name to check: ") age= raw_input("Enter the age you want to check: ") length= raw_input("Enter a name to calculate its length: ") return name, age, length #A def checkFirstAndLastLetters(name): if name[0].lower()==nam...
ffe47f85779bb5ce0d95741424eab61b0ddd4212
CGurg/PythonPractice
/Lili2.py
1,881
4.3125
4
def number_length(num): # Set initial lenght value to 0 length = 0 # Divide by 10 (use // instead of / to do integer divission instead of float point division) # This will reduce num by one digit each iteration # Add one to length each iteration while num > 0: num = num // 10 length = length + 1 r...
440fbb059bbaf1c2baaa390da7bd0a0090285c45
Garlinsk/Kata
/k5/main.py
690
4.15625
4
# TASK 9: # Write a program that takes the age in years and returns the age in days.Use 365 days as the length of a year for this challenge as we would like to ignore leap years. Only accept positive numbers. # BDD # Get an input of the users age # Verify that the age is positive # Output their age in days # Pseudoc...
8eec20986bb99eb2b45badada527f064d4328253
anapaulagomes/aprendendo-python
/notebooks/scripts/forca.py
895
3.890625
4
import os print('---- JOGO DA FORCA ----') palavra = 'livro' palavra_digitada = '_' * len(palavra) print('----|') print('|') print('|') print('|') print(palavra_digitada, end = ' ') print('\n\n') chances = 5 # ou len(set(palavra)) for chance in range(chances): print(f'Você tem {chances - chance} chances.\n') ...
61c034612fb3cffc94e2d767c3a1c9ba50062225
Jnguyent/Exercism-Python
/exercises/acronym/acronym.py
251
3.828125
4
def abbreviate(words): word_cleaned = ''.join(x if x.isalpha() or x == '\'' else " " for x in words) word_list = [x for x in word_cleaned.split()] acronym = '' for i in word_list: acronym += i[0].upper() return acronym
fdc24d6d613773e7a12aad7189a4f1ecbfb81214
Jnguyent/Exercism-Python
/exercises/matrix/matrix.py
395
3.53125
4
class Matrix: def __init__(self, matrix_string): # Convert matrix string into a list within a list (a matrix) self.matrix = [[int(x) for x in row.split()] for row in matrix_string.splitlines()] def row(self, index): return self.matrix[index-1] def column(self, index): colum...
77f8cd935d9a91294b140d776aa76460dcc57fbb
nathanstouffer/sudoku
/solver/minpq.py
4,197
4.1875
4
# A class to store a priority queue # --------------------------------- import numpy as np import square class MinPriorityQueue: # CONSTRUCTOR -------------------------------------------------------------- # construct a Sudoku object def __init__(self): self.last = 0 self.keys = np.zero...
73a8501f6d47cc94bec9d749d3e7da45949d841b
ScienceStacks/BaseStack
/python/src/grep_line.py
1,796
3.828125
4
""" Extracts text between marker lines. """ import argparse import fileinput import sys import typing def extract(lines:list[str], start_marker:int, end_marker:int)->list[str]: """ Finds lines that lie between a start and end marker. Raises ------ ValueError: invalid formatting """ out_li...
537c7daeaa3fa00852710fac5a7a92d758340a74
Mohit-mg/questions
/question8.py
876
3.578125
4
def output(string): count=0 for pos,item in enumerate(string): sum=0 for j in range(0,len(string)): try: sum=string[pos]+string[j+pos] # print(j) # print(sum) if sum==0: count+=1 #...
afd01d3ab410112041dd5ff176e187a484a14592
ies-romerovargas-team/ejercicios-python
/triangulares.py
284
3.8125
4
#Ejercicio 01.06 print("Números triangulares desde 1 hasta n") n = int(input("Indique número n: ")) for x in range(1, n + 1): print(str(x) + " - " + str(x * (x + 1) / 2)) acumulado = 0 for x in range(1, n + 1): acumulado = acumulado + x print(str(x) + " - " + str(acumulado))
04e1180bc10f99d535a0d61939b73fbd5369ceb4
zhiyue-archive/pythontest
/src/Fib.py
474
3.53125
4
#!/usr/bin/python #coding:utf8 ''' Created on 2011-1-22 @author: hooxin ''' class Fib: '''a generator''' def __init__(self,max): self.max=max def __iter__(self): self.a=0 self.b=1 return self def __next__(self): fib=self.a if fib > self.max: raise StopIteration self.a,self.b=self.b,self.a+sel...
c5a2626446bad50224d2aa8d0cdf4a1d3f96d4db
zhiyue-archive/pythontest
/src/fraction.py
160
3.625
4
#!/usr/bin/python #coding:utf8 ''' 分数运算 @author ffmmx ''' import fractions x=fractions.Fraction(1,3) x=x*2 y=fractions.Fraction(2,4) z=x+y print z
745d9a88991d3e7f6e62d7ae9d6386ffef932de3
Aleksei-Zaichenko/Data-Structures
/doubly_linked_list/doubly_linked_list.py
5,742
4.28125
4
""" Each ListNode holds a reference to its previous node as well as its next node in the List. """ class ListNode: def __init__(self, value, prev=None, next=None): self.prev = prev self.value = value self.next = next def get_value(self): return self.value def set_next(sel...
33cb42d2241fdf4cee1a46d8b87feb7f6d30b5e2
Dartlc/python_tutorial
/Examples/odd_or_even.py
213
4.40625
4
""" finding odd or even number using is and else """ input_1 = int(input("Enter the input value: ")) if input_1 % 2 == 0: print(f"{input_1} is even number.") else: print(f"{input_1} is odd number.")
7a16d69860e2b36a5e3461bf0d15dd2114553686
Dartlc/python_tutorial
/Examples/overlapping_two_dic.py
167
3.59375
4
d_1 = {"1": 2, "2": "w", "3": "q"} d_2 = {"1": 2, "different": "w", "3": "q"} output = [] for i in d_1: if i in d_2.keys(): output.append(i) print(output)
b6157cb7f9aa8c174842c0b946774ad1dd9267f6
Dartlc/python_tutorial
/Examples/class_example.py
332
3.765625
4
""" class & objects """ class DemoClass: a = 0 b = 0 c = 0 def add(self): self.c = self.a + self.b print(self.c) def odd_even(self): self.c = int(input("Enter the c value")) if self.c % 2 == 0: x = self.c else: x = self.c ...
022db9730b3936c1b0d2a92a7f53033549539e7a
Dartlc/python_tutorial
/Examples/duplicate_values_dict.py
235
3.609375
4
d_1 = {'a': 10, 'b': 20, 'c': 10} d_2 = {'a': 10, 'b': 20, 'c': 30} input_list = list(d_1.values()) for i in d_1.values(): if i in input_list: print("I found the result") break else: print("Not Found")
aa0a75610a67e6dc8163dcc8bfe879a6cc20a678
ShararAwsaf/Algorithms-Course
/Course-Contents/assignments/res/A3-Q12-py/anagram-search-double-sort.py
1,057
4.21875
4
# find number of anagrams in an array given a string def anagram_counter(S, A): c = 0 sorted_S = sorted(S) # create signature for sorted s # sort A using length and break ties using signature ascending A.sort(key=lambda x : (len(x), sorted(x)) ) print(A) print(sorted_S) l, r ...
660e6f3f40c158f1f95d2359599f37a7ce588b1e
sidharth-05/algorithms
/lenoflast.py
355
3.65625
4
class Solution: def lengthOfLastWord(self, s: str) -> int: s.strip() print(len(s)) if s == "" or s == " "*(len(s)): return 0 a = s.split(" ") if a[len(a) - 1] == "": for i in range(a.count("")): a.remove("") return len(a[len...
80d5cb164b975abbd604d3e4ab70ff8f45205066
topherPedersen/Magic8BallTutorial
/magic8ball.py
2,230
3.984375
4
# https://bit.ly/2KZqTo8 import random print("Welcome to Magic 8 Ball") fortune = [] fortune.append("It is certain.") fortune.append("It is decidedly so.") fortune.append("Without a doubt.") fortune.append("Yes, definitely.") fortune.append("You may rely on it.") fortune.append("As I see it, yes.") fortune.append("M...
c6b00f7813a8a45bf2bf323566bb7cc6c6a57917
ashfakshibli/python_everyday
/OOP/magic_operators.py
1,070
4.8125
5
""" Magic methods are special methods which have double underscores at the beginning and end of their names. They are also known as dunders. So far, the only one we have encountered is __init__, but there are several others. They are used to create functionality that can't be represented as a normal method. One co...
7cdd075dc8a43c7b1c7ad05e2f258d6d9cb7a937
ashfakshibli/python_everyday
/Regular Expression/special_characters.py
2,452
4.5625
5
""" There are various special sequences you can use in regular expressions. They are written as a backslash followed by another character. One useful special sequence is a backslash and a number between 1 and 99, e.g., \1 or \17. This matches the expression of the group of that number. """ import re pattern = r"(...
6ca0b68edc89ddeb185e5ee167e29c3f7dc9787c
ashfakshibli/python_everyday
/Regular Expression/intro.py
1,972
4.71875
5
""" Regular expressions in Python can be accessed using the re module, which is part of the standard library. After you've defined a regular expression, the re.match function can be used to determine whether it matches at the beginning of a string. If it does, match returns an object representing the match, if not, i...
d2af9908041d4cb80766cf515754355a6b671fe6
gt6989b/Config
/Python/Calendar/basicCalendar.py
7,847
3.609375
4
#!/usr/bin/python ##----------------------------------------------------------------------------## ## \file basicCalendar.py ## ## \brief Calendar class implementation ## ## ...
54f6e4ea5e5140130114e8c4d92885f5ad761dff
Schlitzohr101/MaxSubArray
/pythonImpl/main.py
4,608
3.875
4
#John Miner from Menu import Menu from Array import Array import re import datetime def main(): M = Menu() M.printMenu() r = input() method = choices(r) while method != 4: method() M.printMenu() r = input() method = choices(r) def choices(c): return {'1' : choi...
06cf09b301746e098d41d1172a8c2e82cfb8b2b3
icetea2001/GYARB-projekt
/weather_test.py
1,063
3.546875
4
#https://samples.openweathermap.org/data/2.5/weather?id=2172797&appid=1e56ffbb3951c72be777701e5622f3a1&units=metric&lang=se import requests from pprint import pprint # API KEY API_key = "1e56ffbb3951c72be777701e5622f3a1" # This stores the url base_url = "http://api.openweathermap.org/data/2.5/weather?" # This will ...
891b81c16d3b8296329dd8ccb790a0f63e73bf4d
ksingla025/eng-standard
/easy_tokenize2.py
1,361
3.5
4
#!/usr/bin/python import sys import string def ambiguated_output(list_of_tokens): l=[] for word in list_of_tokens: # list of tokens is the double list s='^' j='/'.join(word) s=s+j+'$' l+=[s] return l def disambiguated_output(line): x=line[1:-2] # ^ and $ symbols are ommitted tokens="/"...
4f43e62a7f9ac7e74222ac223887dbaf8a7ecb95
ksingla025/eng-standard
/trie_implementation.py
7,188
3.75
4
#!/usr/bin/python #improving shorten abbreviations, short lingo import string import sys import pickle #!/usr/bin/env python b=[] # A container that would hold suggestions class Trie(): def __init__(self): self.root = {} self.val=0 # To store count of each ...
f0af986dc3c558dd2bd10dcb38a910a8504237fc
Tamilarasi2331/Tamilarasi
/set3ind.py
93
3.703125
4
num=int(input()) arr=[] for i in range(num): x=int(input()) arr.append(x) print(arr[i],i)