blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
133
path
stringlengths
2
333
src_encoding
stringclasses
30 values
length_bytes
int64
18
5.47M
score
float64
2.52
5.81
int_score
int64
3
5
detected_licenses
listlengths
0
67
license_type
stringclasses
2 values
text
stringlengths
12
5.47M
download_success
bool
1 class
4a765074af38518ff015d714d6d3d360998962c7
Python
bopopescu/Daffo
/Python/Strings/Str_n_Str-Slicing.py
UTF-8
820
4.84375
5
[]
no_license
# Here in This file we are going to see the demo on Strings str = "Hello World !" print(str) # string slicing.... # String slicing is a way of slicing out substring out of a given string # String slicing can be perfromed by two ways: # Using the list access types : Like str[start,end,step_size] print("=========Slic...
true
22386e0572e35416cb6ddf0ec0a3241050fec9d8
Python
secfb/HackingScripts
/ssh-check-username.py
UTF-8
2,383
2.546875
3
[]
no_license
#!/usr/bin/python3 import multiprocessing import threading import time import os import argparse import logging import paramiko import socket import sys import pdb arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-t',dest='hostname', type=str, help='Single target') arg_parser.add_argument('-p',dest='por...
true
a029cbdd39578c3db8e5fc864f4d03e80c9c2120
Python
LukaszHoszowski/Django_ProEstate
/User/tests/test_view_email.py
UTF-8
4,513
2.765625
3
[ "MIT" ]
permissive
import pytest from User.user_helper_functions import create_email_subject_neighbour, create_email_subject_failure, \ create_email_message_neighbour, create_email_message_failure def test_email_create_neighbour_subject(): first_name = 'John' last_name = 'Smith' username = 'John1908' subject = cre...
true
d9a3bf99fc8e9243628b72f0a9e90a023599de89
Python
adslyw/python-100-days
/day-2/d2_1.py
UTF-8
30
2.796875
3
[]
no_license
a = 123 b = 321 print(a + b)
true
7f9b2a7c91872b8922e45faf42fbef30387fcab0
Python
Juanesgil4/demo-de-clase-2018-01
/ejemplofor.py
UTF-8
87
2.96875
3
[ "MIT" ]
permissive
# Este es un ejemplo de un for for n in range(10): print(n) # Comentario
true
b340d3157a591c104c037692346102dbf693b2f2
Python
Wrench56/Chat
/curses/scroll_class.py
UTF-8
620
2.828125
3
[ "MIT" ]
permissive
#!/usr/bin/env python2 import curses import time import curses_util mypad_contents = [] def main(scr): # Create curses screen scr.keypad(True) curses.noecho() scr.refresh() scroll = curses_util.AdvancedScrollpad(scr, 1000, 100) scroll.refresh() scroll.load_file('C:\\Exes\\valorant_helper.py') scroll...
true
6438b049d8f29d01c606c6ba712e707ae89f5c7b
Python
preethibollineni33/Tasks
/preethi_B/preethi_b.py
UTF-8
2,668
3.5625
4
[]
no_license
#purpose of the script ################################################################################################################### #This script has been designed to read from a text file that byte count and #Write to output count on greater than 5000 records and sum of records which is greater than 5000. #####...
true
8ab6ef8bf21e67008f21a8cddb2fdafc1c445219
Python
YuiLiou/git-demo
/stockprediction/chi-square/news-time-yahoo.py
UTF-8
2,887
2.796875
3
[]
no_license
import pymysql.cursors import datetime import csv connection = pymysql.connect(host='localhost', user='root', password='12qwaszx', db='news-set', charset='utf8mb4', ...
true
9b1470c92ca8ad3cfe9860f41b468b47c96c62a0
Python
BarrieWang/CAU_Project
/classify/classify.py
UTF-8
2,942
2.6875
3
[]
no_license
""" author: 汪宝瑞 create time: 2020-03-09 update time: 2020-03-14 """ # -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function import pkg_resources import torch from torch.utils.data import TensorDataset, DataLoader from pytorch_pretrained_ber...
true
5023d5fdd26012b8a78d14de1d87d0a6d70dbe27
Python
Rafalini/N-queens-puzzle
/Genetic/geneticAlgo.py
UTF-8
11,304
3.125
3
[]
no_license
import random import copy import numpy as np import progressbar import os random.seed(0) class Queen: def __init__(self, x, y): self.x=x self.y=y def __eq__(self, another): if not isinstance(another, Queen): return NotImplemented return self.x == another.x and self...
true
625a8ffa9312e1ff1c112279984b8dda5b0f963b
Python
bigbillfighter/Python-Tutorial
/Part2/alien_invasion/scoreboard.py
UTF-8
2,640
3.34375
3
[]
no_license
import pygame.font from pygame.sprite import Group from ship import Ship class Scoreboard(): '''class to display the score''' def __init__(self, ai_settings, screen, stats): '''initialize the attributes associated with displaying scores''' self.screen = screen self.screen_rect = self.s...
true
8b7c879358e930c82e54895a2041f3cf10ef3607
Python
eroncastro/learning_algorithms
/combinatorial/powerset.py
UTF-8
208
3.171875
3
[]
no_license
def powerset(alist): if not any(alist): return [[]] new_set = [] for elem in powerset(alist[1:]): new_set.append(elem) new_set.append([alist[0]] + elem) return new_set
true
f7fd0848e9c1ad0f5a38526595c7e2a9af0e2be1
Python
Foo-Maker/Miniprogramme-in-Python
/Aufgaben/13 - Wahlprogramm/Wahlprogramm.py
UTF-8
2,034
3.59375
4
[]
no_license
#!/bin/python3 kandidaten = {} result = {} def open_liste(): return open("Kandidaten.txt", "r") def create_dict(): counter = 0 kandidaten[counter] = '>> ENDE <<' foo = open_liste() for i in foo: i = i.strip() counter = counter + 1 kandidaten[counter] = i result[i]...
true
75cd2e84ee4b461a26ac2c74c871575314ad80e0
Python
jokamjohn/tst
/server/auth/auth_handler.py
UTF-8
1,074
2.59375
3
[]
no_license
import time from typing import Dict import jwt from decouple import config from server.models.user import UserSchema users = [] JWT_SECRET = config("JWT_SECRET") JWT_ALGORITHM = config("JWT_ALGORITHM") def token_response(token: str): return { "token": token } def sign_jwt(user_id: str) -> Dict[s...
true
995a57e945657ee1e686e3791d817b06fad50dad
Python
galhoresh/traffic
/galtg.py
UTF-8
2,907
2.890625
3
[]
no_license
import argparse import os import random from time import sleep import sys import pdb import numpy import requests from threading import Thread lamda = 0 finish = 25 args = 0 fp = "" def generate_requests(args): global lamda, finish, ip, check_file current_interval = 0 while current_interval < finish: #if...
true
707c9a5337e5622a27bd87e70f4999871b40285c
Python
janertl/sequence-jacobian
/src/sequence_jacobian/utilities/interpolate.py
UTF-8
6,714
3.625
4
[ "MIT" ]
permissive
"""Efficient linear interpolation exploiting monotonicity. Interpolates increasing query points xq against increasing data points x. - interpolate_y: (x, xq, y) -> yq get interpolated values of yq at xq - interpolate_coord: (x, xq) -> (xqi, xqpi) get representation xqi, xqpi of xq interpo...
true
f7588fb508582999a0be58db3de96e6bc3993ed4
Python
lavanyasp1997/Python50
/50_Days/Matrix_multiplication.py
UTF-8
1,946
3.03125
3
[]
no_license
if __name__=='__main__': with open('./../Files/in2.txt') as f1: with open('./../Files/in1.txt') as f: a = f.readlines() b = f1.readlines() matrixa = [] matrixb = [] for line in a: var = line.split(",") #print(var) ...
true
e217eddeb50673cea630b4a9d95a78ed386041f1
Python
kittom/Mind-Control-Car
/UI/Main.py
UTF-8
1,027
2.75
3
[]
no_license
import tkinter as tk from UI.pages.VideoFrame import VideoFrame from UI.pages.GraphFrame import GraphFrame class MainPage(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.bind("<Escape>", lambda e: self.quit()) self.title("BLI") self.geometry...
true
a25801e3d10277a745fc5a75f3155f6003ff8a53
Python
timiomoya/Coursera-Python-Work
/Exploring the HyperText Transport Protocol/simi.py
UTF-8
237
3.765625
4
[]
no_license
month =8 days_in_month =[ 31,28,31,30,31,30,31,31,30,31,30,31] print =(sorted(days_in_month)) n=4 if n % 2 == 0: print(" the number" + str(n) + "is even.") else: print(" the number" + str(n) + "is odd.") print(n)
true
818256bce7c8e6f9a32a37cbadc054c97ed03496
Python
cybertraining-dsc/hid-sp18-409
/project-code/crime_finder_swagger/data/base_auth.py
UTF-8
1,091
2.671875
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/env python3 import flask import yaml credentials="config/credentials.yml" try: from decorator import decorator except ImportError: import sys import logging logging.error('Missing dependency. Please run `pip install decorator`') sys.exit(1) try: config = yaml.load(open(credent...
true
69ddd29264a98d9057bd186b789ad4c13a35366e
Python
edunham/toys
/ics/myics.py
UTF-8
3,925
3.234375
3
[ "MIT" ]
permissive
#! /usr/bin/env python3 from ics import Calendar, Event from random import randrange, choice from datetime import timedelta, datetime import click import calendar from dateutil import parser class Pronoun: def __init__(self, they="they", them="them", their="their", theyre = "they're"): self.they = they self...
true
0052d066bf705551f663a01938d7bf68ba27eec5
Python
ewhart1/compBioFinal_meerkat
/meerkatSim.py.save.1
UTF-8
5,166
2.75
3
[]
no_license
#!/usr/bin/env python # Charis, Eric, Zara Final Project # Simulation to plot variation in different phenotypes amongst a meerkat population import numpy as np import numpy.random as nr import matplotlib.pyplot as plt #class individual: # # def __init__(self, smallLight, normalLight, smallDark, normalDark, numOff): ...
true
c76013278e8dc3de9995722e04394b1c1317094e
Python
tboex/News-Classifier
/menu.py
UTF-8
2,362
3.140625
3
[]
no_license
import dataCleaning as dc import collections import numpy as np import newsImport as ni # TODO #Add first menu into menu.py def menu_Predict(clf, idDict): exit = ["0", "exit"] options1 = ["1","phrase","enter a phrase", "enter"] c = True while c == True: print("\nEnter a phrase to be predicted...
true
50cf9f13b1461397f8ebe3dcaf3009249dc306eb
Python
CamillaEsme/toastystats
/AO3/getNum.py
UTF-8
1,126
2.546875
3
[ "MIT" ]
permissive
from bs4 import BeautifulSoup import urllib3 import re import sys #def getNum(url): if len(sys.argv) < 2: sys.exit('Usage: %s AO3_search_url [-verbose]' % sys.argv[0]) verbose = False if len(sys.argv) > 2: arg = sys.argv[2] if arg == "-verbose" or arg == "-v": verbose = True url = sys.argv[1] h...
true
01184a3de8e4d954ef63330258b07d58370099e6
Python
johndpope/deep_lerning
/assignment_1/convnet_tf.py
UTF-8
7,373
3.40625
3
[]
no_license
""" This module implements a convolutional neural network. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf class ConvNet(object): """ This class implements a convolutional neural network in TensorFlow. It incorporates a cer...
true
e5b4671deda22d216ddc880a7d3ac210bfe4771d
Python
LedruRollin/gazu-publisher
/kitsupublisher/software_link/blender/launch_kitsu.py
UTF-8
7,341
2.546875
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """ Run the gazu viewer, a Qt app in Blender. This code reuses this snippet : https://gitlab.com/snippets/1881226 Using a timed modal operator to keep the Qt GUI alive and communicate via `queue.Queue`. """ import queue import sys import os import bpy kitsupublisher_folder = "" kitsu_host = o...
true
9716b9cfc334a10e46aa602263a4714d7af6263c
Python
k24dizzle/meow
/nba/templatetags/nba_teams.py
UTF-8
3,073
2.625
3
[]
no_license
from django import template register = template.Library() #$ def (value, arg): # var|foo:"bar" var is the variable/value, bar is the arg @register.filter(name='streakBoo') def streakBoo(value): if (value[0] == 'W'): return True else: return False @register.filter(name='win') def win(value, ...
true
66e3c0e265c26877ad22b4db0cfad015cdca649a
Python
mithem/calculus
/cli.py
UTF-8
8,795
2.78125
3
[]
no_license
from typing import List, Union from functions import (Function, Constant, Linear, Polynomial, Sin, Cos, Tan, e_function, natural_log, FunctionSum, FunctionProduct, ChainedFunction) import run import argparse class FunctionType: d = { 0: Constant, 1: Li...
true
282cbbfe308a13efdf9ded5f2935c64b0667f357
Python
chloechsu/nanoparticle
/src/fc.py
UTF-8
1,607
2.6875
3
[ "MIT" ]
permissive
import torch import torch.nn as nn import torch.optim as optim class OneLayerFC(nn.Module): "A fully-connected network." def __init__(self, n_logits): super(OneLayerFC, self).__init__() self.classifier = nn.Sequential( nn.Dropout(), nn.Linear(400*4, 512), n...
true
9862b94d66214a526d7ed701efea98918e22facb
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_136/585.py
UTF-8
452
2.9375
3
[]
no_license
import math for n in xrange(int(raw_input())): C, F, X = map(float,raw_input().split(" ")) N = max(0, int((F*X - 2*C)/(F*C) - 1)) total = sum(float(C/(2 + i*F)) for i in xrange(N)) truetotal1 = total + X/(2 + N*F) truetotal2 = total + C/(2 + N*F) + X/(2 + N*F + F) truetot...
true
3a393349a65557d840e4a1010f00e101465bb2af
Python
rajlath/rkl_codes
/CodeForces/EC_27_D_Relatively_Prime_Graph.py
UTF-8
547
3.578125
4
[]
no_license
''' D. Relatively Prime Graph Examples input 5 6 output Possible 2 5 3 2 5 1 3 4 4 1 5 4 input 6 12 output Impossible ''' from math import gcd from math import gcd n, m = map(int, input().split()) a = [] if m < n-1: print("Impossible") exit() for i in range(1, n): for j in range(i+1, n+1): if g...
true
9f75d3ecfd265d34fd42009b1bb6e2c6ef5214cc
Python
jupiterorbita/python_stack
/python_fundamentals/OOP-test.py
UTF-8
659
3.8125
4
[]
no_license
# http://learn.codingdojo.com/m/72/5471/35326 # class User: # name="Anna" # anna = User() # print("anna's name:", anna.name) # User.name = "Bob" # print("anna's name after change:", anna.name) # bob = User() # print("bob's name:", bob.name) class User: def __ini...
true
f13111f5e5c7315ff23ba664c60e528e839fbb55
Python
121910313014/LAB-PROGRAMS
/L6-SEARCHING_NODES.py
UTF-8
1,336
4.6875
5
[]
no_license
#Search for a given item in a linked list. #class for creating a node class Node: #method for adding data into the newly created node def __init__(self,data): self.data=data self.next=None #class for creating a LinkedList and for performing operations class LinkedList: ...
true
f39ef9ee9ce4bbcb38a3d7b9dfac1a67f259285c
Python
DreadPirateRoberts44/PythonProjects
/hexAndDec.py
UTF-8
2,388
4.21875
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri Jun 5 18:46:58 2020 @author: Mike Yamokoski """ #This program converts decimal to hexidecimal and vice versa def decToHex(num): hexVal = "" #loop until the quotient is zero while num / 16 > 0: #get the hex digit for the current pl...
true
ab545303c43ecbe49fbab3684627c6ae95268503
Python
lanl/ExactPack
/exactpack/solvers/radshocks/__init__.py
UTF-8
8,980
2.71875
3
[ "BSD-3-Clause" ]
permissive
r""" Semi-analytic, nonrelativistic, equilibrium-diffusion radiative-shock solutions were originally presented by Sen and Guess in 1957 [Guess1957]_, but they neglected the radiation energy density and the radiation pressure. The nonequilibrium-diffusion solutions were originally presented by Heaslet and Baldwin in 19...
true
b606e1971886f44318eb283824e98d9e36334d1f
Python
larifeliciana/Mineracao-de-Texto-2018.2
/Lista 8/L8Q1.py
UTF-8
3,141
2.859375
3
[]
no_license
from sklearn import feature_extraction from nltk import tokenize import json import pycorenlp def soma_dic(dic1, dic2): x = list(dic1.values()) y = list(dic2.values()) dic3 = {} for i in range(len(x)): dic3.update({i:x[i]+y[i]}) return dic3 def feature1(data): tfidf = f...
true
bba204be2fe947a11f7ba0a651cabeedc6591c18
Python
JavaRod/SP_Python220B_2019
/students/stellie/lesson08/assignment/inventory.py
UTF-8
1,280
3.71875
4
[]
no_license
# Stella Kim # Assignment 8: Functional Techniques """ Create program to create and update a CSV file. Additionally, create functionality to load individual customers rentals. """ import csv from functools import partial def add_furniture(invoice_file, customer_name, item_code, item_description, ...
true
2383f1f90fb97d62eec911b272cf4c6d4470a9f4
Python
weihancool/dissertation-irl
/Dissertation Codebase/irl-modified/plot.py
UTF-8
1,012
2.953125
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 12 13:01:53 2019 @author: paras """ import matplotlib.pyplot as plt def plot(ground_reward,reward,grid_size): ground_reward=getGriundReward(ground_reward) plt.subplot(1, 2, 1) plt.pcolor(ground_reward.reshape((grid_size, grid_size)), lin...
true
1ca4d29bb6fcb66c3d417749798494937b0ede54
Python
shills112000/Simon-Python
/LOGFILE_PULL_SCRIPT.py
UTF-8
968
2.828125
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri Mar 16 10:08:31 2018 @author: SHills """ #!/usr/bin/env python import sys, os env_name=[] env_jboss=[] file = open ('ENVS',"r") for line in file: fields=line.split(",") env_name.append(fields[0]) env_jboss.append(fields[1]) print ("Please choose the...
true
481807ecb65cfa8aa1fffefd068c32246c8fae15
Python
jhonatang1988/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/10-Adam.py
UTF-8
765
3.15625
3
[]
no_license
#!/usr/bin/env python3 """creates the training operation for a neural network in tensorflow using the Adam optimization algorithm """ import tensorflow as tf def create_Adam_op(loss, alpha, beta1, beta2, epsilon): """ creates the training operation for a neural network in tensorflow using the Adam optimi...
true
697785eec239a5b809797a4b3ae0260990036a6b
Python
caok168/opencv_demo
/pixed_matic/demo3.py
UTF-8
602
2.953125
3
[]
no_license
# 算法优化 # 1 灰度 最重要 2 基础 3 实时性 # 定点-》浮点 +- */ >> # r*0.299+g*0.587+b*0.114 import cv2 import numpy as np img = cv2.imread('../imgs/4.jpg', 1) imgInfo = img.shape height = imgInfo[0] width = imgInfo[1] # RGB R=G=B = gray (R+G+B)/3 dst = np.zeros((height, width, 3), np.uint8) for i in range(0, height): for j in range(...
true
d57cdaf587ae2c05ed962f9fc181ca984f8addac
Python
dtbinh/v-rep-robotics
/src/bug/DistBug.py
UTF-8
3,943
2.5625
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'ar1' from BugBase import * class DistBug(BugBase): def __init__(self, target_name='target', bot_name='Bot', wheel_speed=1.0): BugBase.__init__(self, target_name, bot_name, wheel_speed) self.min_dist_to_target = None self.about = ...
true
ccf4e2b05e8aa2c842bb4a8ef20a310c39a840c3
Python
OpenCIAg/py-robot
/src/test/python/unit/context/test_context.py
UTF-8
1,160
2.90625
3
[ "Apache-2.0" ]
permissive
from aiounittest import AsyncTestCase from urllib.parse import urlparse from robot.api import Context from robot.context.core import ContextImpl class ResolveUrlContextImplTest(AsyncTestCase): context: Context = None @classmethod def setUpClass(cls): cls.context = ContextImpl(url=urlparse('http:/...
true
eea59d1e0a335796eddcd0271862126801639417
Python
zycliao/my_leetcode
/27.py
UTF-8
1,621
3.671875
4
[]
no_license
from typing import List class Solution: def removeElement(self, nums: List[int], val: int) -> int: # 如果发现val,把它和nums里最后一个非val元素交换 # (逻辑有点太复杂 i = 0 cnt = 0 n = len(nums) - 1 if len(nums) == 0: return 0 while i < n - cnt: # nums[n-cnt]...
true
73efc8add0c2c0646848273ccb40fd9e7a6c7c2a
Python
Schwib225/automate-the-boring-stuff
/Collatz.py
UTF-8
460
4.15625
4
[]
no_license
#! python3 # The Collatz Sequence try: x = int(input('Please enter a number: ')) while x != 0: if x % 2 == 0: x = x // 2 print(x) if x == 1: print('Sequence complete') break else: continue ...
true
e0fc09b4fde37023cf0f42d7670d01829e760089
Python
raki-1203/Boostcamp_2st_Hot6
/Algorithm/BYEOLYI/3077.py
UTF-8
508
3.390625
3
[]
no_license
# 3077번 임진왜란 실버 3 from sys import stdin n = int(stdin.readline()) correct_answer = list(stdin.readline().split()) student_answer = list(stdin.readline().split()) # 학생 점수, 총점 a, b = 0, n * (n - 1) // 2 for i in range(n): for j in range(i + 1, n): student1 = student_answer.index(correct_answer[i]) student2...
true
fcc4f4a26f3a0302d7563e379c0bb884cd22ad84
Python
marcoacc90/cnn-stair-detection
/TrainingFusionModel.py
UTF-8
7,688
2.546875
3
[]
no_license
import tensorflow as tf import Models as M import os import numpy as np import random import sys AUTOTUNE = tf.data.experimental.AUTOTUNE # HELP DISPLAY if len( sys.argv ) == 2: if sys.argv[ 1 ] == '--help': print('\n Mobilenet fusion training\n') print(' This command: python3 TrainingModel.py --h...
true
04f2cb6a0956ef5d762f318271c2e5f34cfbc67d
Python
Magnus-droid/FysikkLab
/Økt2.py
UTF-8
229
2.765625
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt FILENAME = "" data = np.transpose(np.genfromtxt(FILENAME)) plt.grid() plt.plot(data[0], data[1], 'bo-') plt.xlabel('time (s)') plt.ylabel('position (m)') plt.show()
true
f46f70790260a45876f7b9c264d1f6c944afdcc0
Python
vprotsenko/python-
/homework/lesson3/3.py
UTF-8
459
3.453125
3
[]
no_license
def check_prefix(number, mask): if mask in number: return True def check_len(number,number_len): if len(number) == number_len: return True def find_number(numbers, prefix, number_len): number_len=number_len+1 for number in numbers: if check_prefix(number, prefix) and check_le...
true
ebe991fded754eb89e059c6be7d27ec94a48dd7e
Python
divyanshusahu/ctf-junk
/CTFs/Hacker.org/coding/3280/solve.py
UTF-8
253
2.640625
3
[]
no_license
with open("rfc3280.txt", "rb") as f : data = f.read().replace("\n","") t = data.split(" ") k = {} for i in t : k[i] = k.get(i,0) + 1 val = sorted(k.values(), reverse=True) for i in k : if len(i) == 9 or len(i) == 10 : print i, k[i]
true
b99e27fd48dff62a833c72bc575a71293ec10b93
Python
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2_neat/16_0_2_djab909_pancakes.py
UTF-8
800
3.5625
4
[]
no_license
#Python Pancakes Problem #Code Jam Round 1 #Inputs: T, S (string of +/- pancakes) def findFlipPosition(pancakes): lastPosition = -1 idx = 0 for p in pancakes: if p == False: lastPosition = idx idx += 1 return lastPosition def flipPancakes(S): #Build array pancakes = [] for c in S: if c == '+': ...
true
5bf48f414d49776dbbee8465ab63a9ff59a37ae4
Python
blakearnold/comfortZone
/recommender/User.py
UTF-8
759
3.328125
3
[]
no_license
#user #has a dictionary to hold the number of times the user has visited each place #has a user to identify itself #has a set of places to know the user has gone. #NEEDS TO BE CHANGED SO DICTIONARIES ARE USEFUL class User: def __init__(self, user, place): self.places = set([place]) self.user ...
true
9fe805c5c9c533afb64128affa531cb8c61d04fa
Python
arsho/leetcode
/solutions/804_Unique_Morse_Code_Words/solution_arsho.py
UTF-8
834
3.375
3
[]
no_license
class Solution(object): def get_morse_message(self, original_message): morse_codes = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] morse_message = "" for c in original_message:...
true
4ffc6a5572c7265499c23091f84ec2c6e4c16136
Python
SimplyyShubh/Iris-flower-classification
/Model/GaussianNB.py
UTF-8
867
2.828125
3
[]
no_license
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.naive_bayes import GaussianNB import pickle import warnings warnings.filterwarnings("ignore") iris=pd.read_csv("iris.csv") X = iris['Sepal.Length'].values.reshape(-1,1) Y = iris['Sepal.Width'].values.reshape(-1,1)...
true
a764ad4709130c0fac210bcd65aa0d61b744e1e4
Python
HypeDis/leet-code-practice
/medium/018-4sum.py
UTF-8
2,275
3.796875
4
[]
no_license
""" Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate quadruplets. Example: Given array nums = [1, 0, ...
true
bb49bfad172aa6a2aa3111a781f04f10af38851e
Python
ntcho/Sunrin2017
/Software/Web Programming/Project06/file_io_2.py
UTF-8
177
3.234375
3
[ "MIT" ]
permissive
fhand = open('input2.txt', 'w') question = "There is a bomb, what you are gonna say? : " write = raw_input(question) fhand.write(str(question) + str(write) + " ") fhand.close()
true
151986e81e77322d5f84f832effa65efb2685725
Python
akashhebbar/Workspace
/Pyhton/methodoverid.py
UTF-8
138
2.90625
3
[]
no_license
class a: def show(self): print("hello") class b(a): def show(self): print("this is b") obj= b() obj.show()
true
4f736ee5969578986e1d00af5f88ffca0679c3d1
Python
jossrodes/PYTHONFORDUMMIES
/034_lower_to_upper_case.py
UTF-8
37
2.515625
3
[]
no_license
zed = "lowercase string" zed.upper()
true
136c58d9c5477187e522668ce81e712564889e80
Python
Chenlei-Fu/Interview-Preperation
/Lc_solution_in_python/0645.py
UTF-8
952
3.484375
3
[]
no_license
def findErrorNums(nums): """ method 1: in-line changes time: O(n) space: O(1) """ n = len(nums) res = [] # find dups for i in range(n): idx = abs(nums[i]) - 1 if nums[idx] >= 0: nums[idx] *= -1 else: # nums[idx] < 0 -> the idx dup...
true
ce2b8581e43932f033eed2a3b9c68538be23b4b7
Python
kaushalag29/LaN-ChaT
/Lanchat.py
UTF-8
3,408
2.65625
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 from tkinter import * from socket import AF_INET, socket, SOCK_STREAM from threading import Thread class Lanchat: def __init__(self,root): self.root = root self.root.protocol("WM_DELETE_WINDOW", self.on_closing) self.BUFSIZ = 1024 self.client_socket = socket(A...
true
4a0954db38bf6a5c27c33b8fed7f86f12044de4c
Python
nikitha567nikki/Python-and-Deep-Learning
/ICP_5/titanic_icp.py
UTF-8
872
3.046875
3
[]
no_license
import pandas as pd from sklearn.svm import SVC, LinearSVC from sklearn.neighbors import KNeighborsClassifier import seaborn as sns import matplotlib.pyplot as plt sns.set(style="white", color_codes=True) train_data = pd.read_csv('train_preprocessed.csv') test_data = pd.read_csv('test_preprocessed.csv') x_train = trai...
true
69a1af2e7d5fde0f0f8324a11379c5f846c16035
Python
NoamKu/goal-recognition-2d
/main.py
UTF-8
2,660
2.828125
3
[]
no_license
import argparse from arg_parser import parse_subccmd def parse_arguments(): """ Arguemts parser. Returns: Command line arguments """ ap = argparse.ArgumentParser() subparsers = ap.add_subparsers(dest='subcmd') # Update SVG options update_parser = subparsers.add_parser('update...
true
539af03d84a86a0be77d28f58d9e1b187a4ba0c9
Python
pranjalikawale/ProblemStatementsInPython
/Functional/FlipCoin.py
UTF-8
439
3.53125
4
[]
no_license
import random head=0 tail=0 flipCoinCounter=int(input("Enter the number of time coin flip")) coinFlipped=flipCoinCounter while coinFlipped>0: if random.random()<0.5 : tail+=1 else: head+=1 coinFlipped-=1 headPercentage=(head/flipCoinCounter)*100 tailPercentage=(tail/flipCoinCounter)*100...
true
9b5b6e8803dbe8999173d558988e6c03e3cfd76c
Python
nudtchengqing/langchangetrack
/langchangetrack/tsconstruction/distributional/scripts/learn_map.py
UTF-8
16,031
2.546875
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/python # -*- coding: utf-8 -*- """Benchmark for the quality of the joint space""" from argparse import ArgumentParser import logging import sys from io import open import os from os import path from time import time from glob import glob from collections import defaultdict from copy import deepcopy from ra...
true
2a837410373928a6f21643096eae99a2e93d3ec2
Python
ana-djurovic/GameOfLife
/test.py
UTF-8
3,301
2.703125
3
[]
no_license
import copy import unittest from logicalgrid import LogicalGrid class LogicalGridTest(unittest.TestCase): def test_no_living_neighbourg(self): self.assertEqual(logicalgrid_t.count_neighbours(1, 1), 0) def test_one_living_neighbourg(self): self.assertEqual(logicalgrid_t.count_neighbours(2, 4...
true
bb98a166f3ccde286208fa4ea42c5311b5cce123
Python
sonyccd/computer-vision-homework
/tests/test_homework1.py
UTF-8
617
2.796875
3
[ "MIT" ]
permissive
from homework.homework1 import * import numpy as np binary_test_image = np.array([ [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [...
true
30d2718faccbad021248c82b411c1537deccacac
Python
fancystuff4/pythonProjects
/basicProject-11.py
UTF-8
929
3.5
4
[]
no_license
# PRODUCT PRICE DISCOUNT def get_price(product, quantity): subtotal = price_diction[product] * quantity return subtotal buying_diction={"biscuits":2 , "chicken":3, "fruits":5} price_diction={"biscuits":3 , "chicken":15.5, "fruits":10} bill_price=0 membership = 'golden' for key ,value in buying_diction...
true
7f8e0f88401f97a2a4a92639e460a57e40294ff9
Python
1971chevycamaro/goin-up-the-country
/data/experimental/control.py
UTF-8
850
2.734375
3
[]
no_license
import pigpio, threading import time as tm from pygame import * def timer(str): if str == "start": global start start = tm.time() elif str == "stop": return tm.time() - start def throttle(ms): if ms in range(1000,2000): #pigpio.pi().set_servo_pulsewidth(18,ms) print(ms) def loo...
true
0c638960814ebaba4d67f0295ef7ea8c048d8ee8
Python
reed-mcdaniel-716/NetNinjaDjangoTutorial
/djangonautic/articles/models.py
UTF-8
1,378
3.0625
3
[]
no_license
from django.db import models # for snippet function import re, string # importing User model for author from django.contrib.auth.models import User # Create your models here. # extends the Django models.Model class class Article(models.Model): # see documentation for all of the different field types supported ...
true
27a9e9da82d6aea1ea6addbc85b95bf1efdba527
Python
crhntr/IAA-Code
/Problems/3.12/Solution-1/quicksort.py
UTF-8
1,172
3.71875
4
[]
no_license
# Introduction to the Analysis of Algorithms (3rd ed) # Michael Soltys ## Problem 3.11 - Quicksort ## Ryan McIntyre ## 6/10/2017 ## python 3.5.2 from copy import copy #takes an list of objects with defined <= def quicksort(input_list): if len(input_list) <= 1: return input_list else: A = copy...
true
efcc5f732ed3571af8aa6f04a38e2b2a64fe832e
Python
elenaryan/QuoridorPy
/quoridor.py
UTF-8
1,206
3.859375
4
[ "MIT" ]
permissive
import sys from QuorBoard import GameBoard ''' Quoridor driver. Takes as input a file of (HOPEFULLY) valid quoridor moves splices them into moves and then updates the game board. At present we're working pulling the moves into something the updateFunction will understand and be able to check...
true
5d4895e3b92a7d47a2c1eace9bebe4aa8d7026fa
Python
grondinjc/RecepeBook
/src/server/app/utils/downloaderUtils.py
UTF-8
388
2.609375
3
[]
no_license
#!/usr/bin/env python from pdb import set_trace as dbg import urllib2 import json class SyncDownloader(object): def get_data_from_url(self, url): response = urllib2.urlopen(url) data = response.read() def download_from_url(self, url, file_name): data = self.get_data_from_url(url) ...
true
fab1ade30d39f984c77c1b2454714828aa3df253
Python
ertgl/natch
/natch/abstract/hasher.py
UTF-8
293
2.890625
3
[ "MIT" ]
permissive
import abc class Hasher(abc.ABC): __metaclass__ = abc.ABCMeta def __init__(self, *args, **kwargs): pass @abc.abstractmethod def hash(self, obj): raise NotImplementedError( f'{self.__class__.__name__}.hash method is not implemented.', )
true
048dca28bdc09247576b1f9734cb75d98cfbfbc5
Python
stealthbyte/Knowledge
/more_linux/protostar-bin/Opcoad.py
UTF-8
11,567
3.796875
4
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
import random def convert_opcode(opcode, filler): return convert_opcode_string(opcode, filler) def convert_opcode_string(opcode, filler): ''' PURPOSE - Convert a string of opcode numbers to little endian values INPUT opcode - String of opcode numbers (e.g., copied from object code)...
true
4d3552154016d487bb40e7f76a2d0585cad60b02
Python
sanwaralkmali/Py-InfoMan-project
/InsertDialog.py
UTF-8
5,898
2.625
3
[]
no_license
from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtGui import * import sqlite3 class InsertDialog(QDialog): def __init__(self, *args, **kwargs): super(InsertDialog, self).__init__(*args, **kwargs) self.QBtn = QPushButton() self.QBtn.setText("Register") self.set...
true
6593f7bb2dc4d02d901f804f7e8c704386e656af
Python
lipegomes/tutorial-como-instalar-mysql-no-docker-linux
/src/create_tables.py
UTF-8
1,549
2.9375
3
[ "MIT" ]
permissive
from getpass import getpass from mysql.connector import connect, Error try: # Estabelece conexão com o MySQL with connect( host="localhost", user=input("Digite o username: "), password=getpass("Digite o password: "), database="TUTORIAL_MYSQL", ) as connection: # Cria...
true
6009d5c19d7d11bb847371c721d3f13e0fdefd49
Python
lihararora/snippets
/python/general/prime.py
UTF-8
378
3.921875
4
[]
no_license
#!/usr/bin/python ''' @author: Rahil Arora @contact: rahil@jhu.edu ''' def is_prime(num): for j in range(2,num): if (num % j) == 0: return False return True if __name__ == "__main__": low = int(input("Enter the lower bound: ")) high = int(input("Enter the upper bound: ")) for ...
true
b9ef065dbec0ed7a062bc53a051fa406063b2270
Python
Sarojm1991/PCEP
/3.1.1.4 LAB Questions and answers/lab.py
UTF-8
65
3.453125
3
[]
no_license
n = int(input("Enter a number:")) output = n >= 100 print(output)
true
188b77c69c82255c38650c5039c980b3d069d280
Python
ivanrodriguez-lpsr/class-samples
/Challenge.py
UTF-8
407
3.734375
4
[]
no_license
Challenge 1) fave = 12 print("pick a number that I am thinking of?") number = input() Number = int(number) if Number == fave: print("Wow, you guessed it! You must be a genius" ) if Number > fave: print("Sorry, you lose. :( Try again: next time, guess a lower number") if Number < fave: pri...
true
749a8d38d92612ae559feeb422b034c106a6e1f5
Python
hibit-at/typical90
/18.py
UTF-8
592
2.953125
3
[]
no_license
import numpy as np t = int(input()) l, x, y = map(int, input().split()) q = int(input()) for i in range(q): e = int(input()) if(e % t == 0): print(0) continue rad = 3/2*np.pi - e/t*2*np.pi pos = np.array([0, l/2*np.cos(rad), l/2+l/2*np.sin(rad)]) takahashi = np.array([x, y, 0]) ...
true
1032e8c0d055d8292bc5048116638e47368d17dc
Python
saminathansami/sama
/minele.py
UTF-8
68
2.53125
3
[]
no_license
sam=int(input()) ram=list(map(int,input().split())) print(min(ram))
true
3679f0fdab093cb87d706001c70e6e8bd8484131
Python
roilait/Machine-Learning
/ANN/cnnAlgo.py
UTF-8
2,651
2.9375
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri Jan 20 21:35:30 2017 @author: moussa """ import tensorflow as tf # IMPORT CLASSES class ConvNet(object): # PREPARING THE CONVOLUTION LAYER INPUTS @staticmethod def in_out_channels(in_channels, out_channels,filters): # shape = [[F,F,in_chls,out_chls], [F1,...
true
bf9159ecdae24eb1c5918e9e1d7395f757bc3247
Python
aoeuidht/homework
/algorithms/ch4/4.2.24.py
UTF-8
320
2.796875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- import graph class HamiltonianPath: def __init__(self, dg): self.dg = dg self.order = graph.DepthFirstOredr(self.dg) def chk(self): return all(lambda pair: self.dg.has_edge(*pair), zip(self.order[:-1], self.order[1:]))
true
9062c796d9a242a4b5562d88fdf19ffd14d76df3
Python
felixiao/DiceRollin
/main.py
UTF-8
4,178
2.59375
3
[]
no_license
import wsgiref.handlers from random import randint import webapp2 from google.appengine.ext.webapp import template import json calcRes='' resultPrb=[] maxVal=0 class MainPage(webapp2.RequestHandler): def get(self): self.response.write(template.render('index.html',{})) def post(self): global calcRes # calcRes=...
true
f863f43ba7700988472127ec7cbf35b51e4774b8
Python
MaxPoon/EEE-Club-Python-Workshop
/syntax/exercise/sudoku.py
UTF-8
1,356
3.546875
4
[]
no_license
import random from copy import deepcopy import itertools def generate_board(): board = None while board is None: board = attempt_board() return board def attempt_board(): numbers = list(range(1, 10)) n = 9 board = [[None for _ in range(n)] for _ in range(n)] # write your code here def print_board(board...
true
a66c424126781d3a4dbf9d579051964bf5b2c95e
Python
joestalker1/leetcode
/src/main/scala/contest/57/DescribeThePainting.py
UTF-8
734
3.203125
3
[]
no_license
from collections import defaultdict class Solution: def splitPainting(self, segments): #sum offset sums = defaultdict(int) # point where segment is starting/ending end = defaultdict(int) for s,e,c in segments: sums[s] += c sums[e] -= c end...
true
f3ec8c5ce3f8ab073eb2ec30cf7ab658783b12a8
Python
codelxm123/LeetcodeProject
/page2Problem/p31/p31_1.py
UTF-8
1,023
2.703125
3
[]
no_license
class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ if len(nums)==0: return 0 n=len(nums) k=0 tail=n-1 while (tail>0 and nums[tail...
true
c02338db51a2795faecc8bfdcb8dcd8e43341d29
Python
henryZe/code
/leetcode/competition/test_256/minSessions.py
UTF-8
696
2.96875
3
[]
no_license
from typing import List class Solution: def minSessions(self, tasks: List[int], sessionTime: int) -> int: n = len(tasks) dic = [0] * (1 << n) for i in range(1 << n): for j in range(n): if i & (1 << j): dic[i] += tasks[j] f = [n] * (1...
true
d55f6295d7edc8bb71c5141c46162e0059e04a40
Python
tlechien/PythonCrash
/Chapter 10/10.7.py
UTF-8
534
4.25
4
[]
no_license
""" 10-7. Addition Calculator: Wrap your code from Exercise 10-6 in a while loop so the user can continue entering numbers even if they make a mistake and enter text instead of a number. """ if __name__ == '__main__': val = True total = 0 while val: val = input("Please enter an integer: ") ...
true
ffdab8c242824a80de49563a6e65fde28ee82602
Python
hrishikeshtak/Coding_Practises_Solutions
/leetcode/LeetCode-150/Bit-Manipulation/190-Reverse-Bits.py
UTF-8
583
3.484375
3
[]
no_license
""" 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. Input: n = 00000010100101000001111010011100 Output: 964176192 (00111001011110000010100101000000) Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its bin...
true
ff32ffe8f67fe6826ccaa24fe4fd893e22f1e8d5
Python
rennergade/project-euler
/euler14.py
UTF-8
379
2.78125
3
[]
no_license
#!/usr/bin/python longchain = {} longest = 0 longnum = 0 for i in range(1,1000001): num = i chain = [num] while num != 1: if num % 2 == 0: num = num/2 else: num = (3*num) + 1 chain.append(num) longchain[i] = len(chain) if longchain[i] > longest: longest = longchain[i] longnum...
true
6a3f67f49071b32fea280269e8bf8ac1c39eba5f
Python
wyaadarsh/LeetCode-Solutions
/Python3/1049-Last-Stone-Weight-II/soln.py
UTF-8
229
2.59375
3
[ "MIT" ]
permissive
class Solution(object): def lastStoneWeightII(self, stones): dp = {0} for stone in stones: dp = {stone + item for item in dp} | {stone - item for item in dp} return min(abs(x) for x in dp)
true
7583f74d4e7bb767072d213a4cf2b5d79cd80804
Python
suryaambrose/code_bits
/decompose_number_on_base.py
UTF-8
1,690
3.90625
4
[ "MIT" ]
permissive
# Standard library import unittest def decompose_number_on_base(number, base): """ Returns a number's decomposition on a defined base :param number: The number to decompose :param base: list representing the base. It must be sorted and each element must be a multiple of its predecessor. First element must be 1...
true
e1dc8557ec3df34376d85cd2f52a5e639027da9b
Python
rganeyev/Sozluk
/SozlukValidator/FileValidator.py
UTF-8
843
3.609375
4
[]
no_license
import codecs __author__ = 'Rustam Ganeyev' def removeCopies(list): n = len(list) result = [] lastWord = '' for word in list: if word != lastWord: result.append(word) else: print(word + "\n") lastWord = word return result def main(): letters ...
true
66b13455af16bb495455ae5907ab8498df22e55a
Python
TJCSec/ctf-problems
/backpack/static/4cd90ed6e1b1f718fde13bfc17e2059bccf3d33988fadfb80a1ee90df8f6184b5f9a126b929a267e1366297aa2aed336363599530cf31702de6db0c92ed110b2-backpack.py
UTF-8
2,206
3.390625
3
[]
no_license
#!/usr/bin/env python3 # Tribute to HSCTF 2014's 20XX import random, sys # Adapted from Wikibooks, because I'm lazy :P def is_probable_prime(n, k = 100): """use Rabin-Miller algorithm to return True (n is probably prime) or False (n is definitely composite)""" if n < 6: # assuming n >= 0 in all cases...
true
11f0aa8f5e5f95ca2c1725f9c7ec9555e0cef3d3
Python
tehilaazar/BiblicalGraphDictionary
/shoresh_vectorCOPY.py
UTF-8
7,594
3.125
3
[]
no_license
#from shoresh_neo import Shoresh from sys import exit from typing import List, Dict, Set import math import csv import pickle from numpy import dot from numpy.linalg import norm from os import path from datetime import datetime def dot_product(vector_x, vector_y): dot = 0.0 for e_x, e_y in zip(vec...
true
8313dcbb803f40d64690516af82908272cd133e8
Python
twofortyone/bs-thesis
/python/fix_nomenclatures.py
UTF-8
1,493
2.90625
3
[]
no_license
#!/usr/bin/python import os def scan_dir(d): """Scans directory `d` for tex files and returns paths""" files = os.listdir(d) all_files = [] for f in files: if os.path.isdir(d+f): # Is a directory, rescan... all_files += scan_dir(d+f+'/') elif len(f) > 4 and f[-4:] == '.tex': all_files.append(d+f) re...
true
6344af7b8afd98a9adafec4a8a854c0e06343f58
Python
akshay-0505/Python-Learning
/polymorphism.py
UTF-8
431
2.8125
3
[]
no_license
# Duck typing #if there is bird walking like a duck quaking like a duck the it is Duck class Pycharm: def execute(self): print("Compiled") print("Running") class MyEditor: def execute(self): print("Spell ckeck") print("Compiling") print("Running") class Laptop: ...
true
851583671fdcf7788fe38bb44fb7f1fbec6f5fb5
Python
alexandraback/datacollection
/solutions_2449486_0/Python/llanuvas/b.py
UTF-8
2,429
2.75
3
[]
no_license
from __future__ import division import sys #import psyco #psyco.full() range = xrange debug = False def main(): global infile global out_file global debug in_filename = sys.argv[1] out_filename = sys.argv[2] if len(sys.argv)>=4: debug = True in_file = open(in_filename, 'r') out_file...
true
f53b8917bb6e50e6fcebcf9d523fe3ae83926e6d
Python
VictorSalajan/my_repo
/basic_algorithms/bisection_search_cube_root.py
UTF-8
544
3.6875
4
[]
no_license
cube = float(input("Enter the number whose cube root you want to find: ")) epsilon = float(input('How close do you want to be to the answer? (e.g.,: 0.01)\n')) num_guesses = 0 low = 0 high = abs(cube) guess = (high + low)/2.0 while abs(guess**3 - abs(cube)) >= epsilon and guess <= abs(cube): if guess**3 < abs(cub...
true