text stringlengths 0 1.05M | meta dict |
|---|---|
# 05_thermomether_plus_f.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
from Tkinter import * # tkinter provides the graphical user interface (GUI)
import RPi.GPIO as GPIO
import time, math
C = 0.38 # uF - Tweek this value around 0.33 to improve accuracy
R1 = 1000 ... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "05_thermometer_plus_f.py",
"copies": "1",
"size": "5246",
"license": "mit",
"hash": -610329300623059700,
"line_mean": 34.6870748299,
"line_max": 102,
"alpha_frac": 0.6850934045,
"autogenerated": false,
"ratio": 3.272613849033063,
"config_test":... |
# 05_thermomether_plus.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
from Tkinter import * # tkinter provides the graphical user interface (GUI)
import RPi.GPIO as GPIO
import time, math
C = 0.38 # uF - Tweek this value around 0.33 to improve accuracy
R1 = 1000 # ... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "05_thermometer_plus.py",
"copies": "1",
"size": "5201",
"license": "mit",
"hash": -6303971557562073000,
"line_mean": 34.6232876712,
"line_max": 102,
"alpha_frac": 0.6875600846,
"autogenerated": false,
"ratio": 3.2896900695762175,
"config_test":... |
#06_01_hangman_file
import random
f = open('hangman_words.txt')
words = f.read().splitlines()
f.close()
lives_remaining = 14
guessed_letters = ''
def play():
word = pick_a_word()
while True:
guess = get_guess(word)
if process_guess(guess, word):
print('You win! Well Done!')
break
if lives_remaining ... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "06_01_hangman_file.py",
"copies": "1",
"size": "1522",
"license": "mit",
"hash": 9201748876312018000,
"line_mean": 19.8630136986,
"line_max": 50,
"alpha_frac": 0.6833114323,
"autogenerated": false,
"ratio": 2.877126654064272,
"config_test": false,... |
#06_02_hangman_file_try
import random
words_file = 'hangman_words.txt'
try:
f = open(words_file)
words = f.read().splitlines()
f.close()
except IOError:
print("Cannot find file: " + words_file)
exit()
lives_remaining = 14
guessed_letters = ''
def play():
word = pick_a_word()
while True:
guess = get_guess... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "06_02_hangman_file_try.py",
"copies": "1",
"size": "1624",
"license": "mit",
"hash": -3523331003671620000,
"line_mean": 19.8333333333,
"line_max": 50,
"alpha_frac": 0.6828817734,
"autogenerated": false,
"ratio": 2.854130052724077,
"config_test": f... |
# 06/05/2017
'''
1. Slim the enable1 dictionary so that it only contains "not-embedded" words;
This is done through the not_embedded_wordlist function and takes forever (~2h) to run.
2. Create an initial solution using a simple algorithm in the embed_word1 function. Length ~390.
3. Create an initial solution usi... | {
"repo_name": "tlgs/dailyprogrammer",
"path": "Python/hard/h313.py",
"copies": "2",
"size": "4905",
"license": "unlicense",
"hash": -7310825389250606000,
"line_mean": 31.9194630872,
"line_max": 100,
"alpha_frac": 0.5993883792,
"autogenerated": false,
"ratio": 3.6741573033707864,
"config_test": ... |
# caselesssort.py
# A sort function for lists of strings that is case insensitive.
# Copyright Michael Foord
# You are free to modify, use and relicense this code.
# No warranty express or implied for the accuracy, fitness to purpose or otherwise for this code....
# Use at your own risk !!!
# E-mail michael AT foor... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/286204_Case_Insensitive_Sort/recipe-286204.py",
"copies": "1",
"size": "2491",
"license": "mit",
"hash": -4777112680903409000,
"line_mean": 28.6547619048,
"line_max": 100,
"alpha_frac": 0.6403050984,
"autogenerated": false,
"ratio": 3.3845... |
# scraper.py
# A general HTML 'parser' and a specific example that will modify URLs in tags.
# Copyright Michael Foord
# You are free to modify, use and relicense this code.
# No warranty express or implied for the accuracy, fitness to purpose or otherwise for this code....
# Use at your own risk !!!
# E-mail michae... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/286269_HTML_Scraper/recipe-286269.py",
"copies": "1",
"size": "13243",
"license": "mit",
"hash": 5951587557415347000,
"line_mean": 43.8915254237,
"line_max": 206,
"alpha_frac": 0.6249339274,
"autogenerated": false,
"ratio": 4.2067979669631... |
# 06_reactions.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
import RPi.GPIO as GPIO
import time, random
# Configure the Pi to use the BCM (Broadcom) pin names, rather than the pin positions
GPIO.setmode(GPIO.BCM)
# pins used for the LED and switches
red_pin = 18
green_pin ... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "06_reactions.py",
"copies": "1",
"size": "2525",
"license": "mit",
"hash": -2887311400755725000,
"line_mean": 32.2236842105,
"line_max": 85,
"alpha_frac": 0.6463366337,
"autogenerated": false,
"ratio": 3.389261744966443,
"config_test": false,
... |
#07/09/2017 Working on graphics
#07/16/2017 Can save protocol to a specific file path and file name.
import pandas as pd
import os
from graphics import *
from PIL import Image as NewImage
import mods.saveOutput as saveOutput
#Generates one protocol for inserting each marker sequence in mrkrs in the plsmds. restrictio... | {
"repo_name": "sunericd/ISTools",
"path": "GeneTK/mods/plasmid_builder.py",
"copies": "1",
"size": "8825",
"license": "mit",
"hash": -909607771300903000,
"line_mean": 42.0536585366,
"line_max": 148,
"alpha_frac": 0.6397733711,
"autogenerated": false,
"ratio": 3.7330795262267342,
"config_test": ... |
"""-0.75/(1+x**2)-(0.65*x*math.atan(1/x))+0.65
(-4* x**2 - 20*x - 100) + (1 - x)**4
3*x**2+ 12/(x**3) - 5
3*x**4 + x**2 - 2*x + 1
10+x**3-2*x-5*(np.finfo(float).eps)**x
x**2- 10*(np.finfo(float).eps)**(0.1*x)
(10*x**3+3*x**2+5)**2
0.5/math.sqrt(1+x**2)- math.sqrt(1+x**2)*(1-0.5/(1+x**2))+x
(np.finfo(float).eps)**x-x**3... | {
"repo_name": "jresendiz27/EvolutionaryComputing",
"path": "practices/first/evolutionaryStrategies/functions.py",
"copies": "2",
"size": "1490",
"license": "apache-2.0",
"hash": -3856515271743588400,
"line_mean": 33.6744186047,
"line_max": 170,
"alpha_frac": 0.489261745,
"autogenerated": false,
"... |
# 07_light_meter.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
from Tkinter import *
import RPi.GPIO as GPIO
import time, math
# Configure the Pi to use the BCM (Broadcom) pin names, rather than the pin positions
GPIO.setmode(GPIO.BCM)
# This project uses a photoresistor, a... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "07_light_meter.py",
"copies": "1",
"size": "3510",
"license": "mit",
"hash": 6232889419278562000,
"line_mean": 33.7524752475,
"line_max": 102,
"alpha_frac": 0.6948717949,
"autogenerated": false,
"ratio": 3.371757925072046,
"config_test": false,... |
#08_03_rasp_game_one
import pygame
from pygame.locals import *
from sys import exit
import random
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
raspberry_x = random.randint(10, screen_width)
raspberry_y = 0
pygame.init()
screen = pygame.display.set_mode((screen_width, screen_h... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_03_rasp_game_one.py",
"copies": "1",
"size": "1300",
"license": "mit",
"hash": 3960308470716985300,
"line_mean": 23.0740740741,
"line_max": 63,
"alpha_frac": 0.6423076923,
"autogenerated": false,
"ratio": 2.882483370288248,
"config_test": false... |
#08_04_rasp_game_scoring
import pygame
from pygame.locals import *
from sys import exit
import random
score = 0
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
raspberry_x = random.randint(10, screen_width)
raspberry_y = 0
pygame.init()
screen = pygame.display.set_mode((screen_... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_04_rasp_game_scoring.py",
"copies": "1",
"size": "1669",
"license": "mit",
"hash": -3682527572559103000,
"line_mean": 22.5070422535,
"line_max": 63,
"alpha_frac": 0.6315158778,
"autogenerated": false,
"ratio": 2.8676975945017182,
"config_test":... |
#08_06_rasp_game_final
import pygame
from pygame.locals import *
from sys import exit
import random
score = 0
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
class Raspberry:
x = 0
y = 0
dy = 0
def __init__(self):
self.x = random.randint(10, screen_width)... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_06_rasp_game_final.py",
"copies": "1",
"size": "1915",
"license": "mit",
"hash": -6845524353052185000,
"line_mean": 22.0722891566,
"line_max": 80,
"alpha_frac": 0.580156658,
"autogenerated": false,
"ratio": 3.0787781350482315,
"config_test": fa... |
# 082 - Remove Duplicates from Sorted List II
# https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def deleteDupli... | {
"repo_name": "zubie7a/Algorithms",
"path": "LeetCode/02_Medium/lc_082.py",
"copies": "1",
"size": "2370",
"license": "mit",
"hash": -2717259463950642000,
"line_mean": 37.8524590164,
"line_max": 93,
"alpha_frac": 0.5924050633,
"autogenerated": false,
"ratio": 4.505703422053232,
"config_test": f... |
# 083 - Remove Duplicates from Sorted List (Easy)
# https://leetcode.com/problems/remove-duplicates-from-sorted-list/
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def deleteDupl... | {
"repo_name": "zubie7a/Algorithms",
"path": "LeetCode/01_Easy/lc_083.py",
"copies": "1",
"size": "1289",
"license": "mit",
"hash": -8668892554760389000,
"line_mean": 38.0606060606,
"line_max": 90,
"alpha_frac": 0.5841737781,
"autogenerated": false,
"ratio": 4.35472972972973,
"config_test": fals... |
# 08_light_harp.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
import RPi.GPIO as GPIO
import time, math
# Configure the Pi to use the BCM (Broadcom) pin names, rather than the pin positions
GPIO.setmode(GPIO.BCM)
# Pin a charges the capacitor through a fixed 1k resistor and... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "08_light_harp.py",
"copies": "1",
"size": "1918",
"license": "mit",
"hash": 6990756843295913000,
"line_mean": 30.4590163934,
"line_max": 95,
"alpha_frac": 0.7059436913,
"autogenerated": false,
"ratio": 3.273037542662116,
"config_test": false,
... |
# 08_manual_robot_continuous.py
# Use the arrow keys to direct the robot
from rrb3 import *
import sys
import tty
import termios
rr = RRB3(9.0, 6.0) # battery, motor
UP = 0
DOWN = 1
RIGHT = 2
LEFT = 3
print("Use the arrow keys to move the robot")
print("Press CTRL-c to quit the program")
# These functions allow th... | {
"repo_name": "teknoteacher/raspirobot3",
"path": "08_manual_robot_continuous.py",
"copies": "3",
"size": "1691",
"license": "mit",
"hash": -8517094233418003000,
"line_mean": 23.1571428571,
"line_max": 85,
"alpha_frac": 0.5718509758,
"autogenerated": false,
"ratio": 3.4651639344262297,
"config_... |
# 08_manual_robot.py
# Use the arrow keys to direct the robot
from rrb3 import *
import sys
import tty
import termios
rr = RRB3(9.0, 6.0) # battery, motor
UP = 0
DOWN = 1
RIGHT = 2
LEFT = 3
print("Use the arrow keys to move the robot")
print("Press CTRL-c to quit the program")
# These functions allow the program t... | {
"repo_name": "simonmonk/raspberrypi_cookbook_ed2",
"path": "rover.py",
"copies": "4",
"size": "1551",
"license": "mit",
"hash": -3878133912986541000,
"line_mean": 22.1492537313,
"line_max": 73,
"alpha_frac": 0.5738233398,
"autogenerated": false,
"ratio": 3.349892008639309,
"config_test": false... |
#08_
import pygame
from pygame.locals import *
from sys import exit
import random
score = 0
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
class Raspberry:
x = 0
y = 0
dy = 0
def __init__(self):
self.x = random.randint(10, screen_width)
self.y = ... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_raspberry_bounce_5.py",
"copies": "1",
"size": "1898",
"license": "mit",
"hash": -3424469766874564600,
"line_mean": 21.5952380952,
"line_max": 80,
"alpha_frac": 0.5774499473,
"autogenerated": false,
"ratio": 3.0912052117263844,
"config_test": f... |
#08_
import pygame
from pygame.locals import *
from sys import exit
import random
score = 0
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
raspberry_x = random.randint(10, screen_width)
raspberry_y = 0
clock = pygame.time.Clock()
pygame.init()
screen = pygame.display.set_mode... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_raspberry_bounce_3.py",
"copies": "1",
"size": "1688",
"license": "mit",
"hash": -5401274146478605000,
"line_mean": 22.1232876712,
"line_max": 88,
"alpha_frac": 0.6327014218,
"autogenerated": false,
"ratio": 2.865874363327674,
"config_test": fa... |
#08_
import pygame
from pygame.locals import *
from sys import exit
import random
screen_width = 600
screen_height = 400
spoon_x = 300
spoon_y = screen_height - 100
raspberry_x = random.randint(10, screen_width)
raspberry_y = 0
pygame.init()
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.d... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "08_raspberry_bounce_2.py",
"copies": "1",
"size": "1282",
"license": "mit",
"hash": -390138207909545000,
"line_mean": 21.8928571429,
"line_max": 63,
"alpha_frac": 0.6411856474,
"autogenerated": false,
"ratio": 2.893905191873589,
"config_test": fal... |
# 09-01-04
#v1.0.1
#
#
# Prints output to the screen and/or
# logs it to a file - depending on the settings.
#
# Prints output to the screen and/or
# logs it to a file - depending on the settings.
#
# To use this function you need to include verbose (yes if you want to print to screen), 'outputpath' (filename)
# ('' i... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/259176_StandOut__Flexible_Output_Object/recipe-259176.py",
"copies": "1",
"size": "2491",
"license": "mit",
"hash": -6812921665900219000,
"line_mean": 38.5396825397,
"line_max": 112,
"alpha_frac": 0.6403050984,
"autogenerated": false,
"rat... |
# 09/04/2019
import functools
import itertools
import operator
def fit1(X, Y, x, y):
return int(X/x) * int(Y/y)
assert fit1(25, 18, 6, 5) == 12
assert fit1(10, 10, 1, 1) == 100
assert fit1(12, 34, 5, 6) == 10
assert fit1(12345, 678910, 1112, 1314) == 5676
assert fit1(5, 100, 6, 1) == 0
def fit2(X, Y, x, y):
... | {
"repo_name": "tlseabra/dailyprogrammer",
"path": "Python/easy/e377.py",
"copies": "2",
"size": "1442",
"license": "mit",
"hash": 7352715090567525000,
"line_mean": 23.8620689655,
"line_max": 86,
"alpha_frac": 0.5409153953,
"autogenerated": false,
"ratio": 2.3523654159869496,
"config_test": fals... |
"""0.9.0 News and Changes
- Updated Swagger UI 3.x
- uiversion now defaults to 3
- 'hide_top_bar' config option to remove the green top bar
- 'fotter_text' added to customize the footer text (allows html and <script>)
- templates/flasgger/footer.html added and can be replaced to customization
this footer.html is the... | {
"repo_name": "rochacbruno/flasgger",
"path": "examples/changelog_090.py",
"copies": "1",
"size": "3037",
"license": "mit",
"hash": 5998135994631770000,
"line_mean": 32.3736263736,
"line_max": 122,
"alpha_frac": 0.6542640764,
"autogenerated": false,
"ratio": 3.7867830423940148,
"config_test": f... |
# 09_proximity.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
import RPi.GPIO as GPIO
import time
# Configure the Pi to use the BCM (Broadcom) pin names, rather than the pin positions
GPIO.setmode(GPIO.BCM)
# This project uses the Capsense technique modelled on this:
# http:... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "09_proximity.py",
"copies": "1",
"size": "1918",
"license": "mit",
"hash": -521023599936823000,
"line_mean": 27.2205882353,
"line_max": 98,
"alpha_frac": 0.6746611053,
"autogenerated": false,
"ratio": 3.412811387900356,
"config_test": false,
... |
#09_resistance.py
import RPi.GPIO as GPIO
import time, math
C = 0.33 # uF
R1 = 1000 # Ohms
GPIO.setmode(GPIO.BCM)
# Pin a charges the capacitor through a fixed 1k resistor and the thermistor in$
# pin b discharges the capacitor through a fixed 1k resistor
a_pin = 18
b_pin = 23
# empty the capacitor ready to start... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "09_resistance.py",
"copies": "1",
"size": "1365",
"license": "mit",
"hash": -8874098190061959000,
"line_mean": 21.7666666667,
"line_max": 80,
"alpha_frac": 0.6293040293,
"autogenerated": false,
"ratio": 2.9609544468546636,
"config_test": false,
... |
# -*0 coding: cp949 -*-
"""
web crawler
JungWon(postgame.tistory.com)
requirement : python 2.7.x
BeautifulSoup4
Read the target html page and save it.
if a title on the page is updated, return True
"""
import urllib2
from bs4 import BeautifulSoup
import os.path
class WebCrawler:
def __... | {
"repo_name": "JungWon2/web_crawler",
"path": "web_crawler.py",
"copies": "1",
"size": "1468",
"license": "apache-2.0",
"hash": -4436739985696024600,
"line_mean": 21.9375,
"line_max": 68,
"alpha_frac": 0.575613079,
"autogenerated": false,
"ratio": 3.5288461538461537,
"config_test": false,
"ha... |
#0 -*- coding: utf-8 -*-
import json
import re
from uuid import uuid4
from datetime import datetime
from collections import defaultdict
from mongoengine.queryset import Q
from flask import Blueprint, jsonify, render_template, request
from flask_login import current_user, login_required
from flask_babel import gettext... | {
"repo_name": "seasonstar/bibi",
"path": "application/controllers/website/user.py",
"copies": "1",
"size": "7044",
"license": "apache-2.0",
"hash": -8457694951861626000,
"line_mean": 31.7476635514,
"line_max": 95,
"alpha_frac": 0.6454052511,
"autogenerated": false,
"ratio": 3.502248875562219,
"... |
##0. CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.
##1. CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.
##3. CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file
##4. CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
##5. CV_CAP_PROP_... | {
"repo_name": "AntonioQu/pythontest",
"path": "opencv_video.py",
"copies": "1",
"size": "1960",
"license": "apache-2.0",
"hash": 775982421892712200,
"line_mean": 37.2,
"line_max": 126,
"alpha_frac": 0.7071428571,
"autogenerated": false,
"ratio": 2.912332838038633,
"config_test": false,
"has_n... |
# 0 == down, 1 == right, 2 == diag
import filecmp
import sys
sys.setrecursionlimit(5000)
def getMax(s, i, j, match):
a = s[i - 1][j]
b = s[i][j - 1]
c = s[i - 1][j - 1] + match
if (a >= b and a >= c):
return (-1, 0)
elif (c >= a and c >= b):
return (-1, -1)
elif (b >= a and ... | {
"repo_name": "Larkenx/coursework",
"path": "bioinformatics/rosalind-problems/LCS/LCS.py",
"copies": "1",
"size": "3601",
"license": "mit",
"hash": 8117486821208298000,
"line_mean": 46.3815789474,
"line_max": 921,
"alpha_frac": 0.7173007498,
"autogenerated": false,
"ratio": 2.579512893982808,
"... |
0. eight = 8
1. b = eight
2. print(b)
3. if x is 'a' or x is 'b:
return True
else:
return False
4. if x > 10 and x%2 != 0:
return True
5. def param(n):
return(n)
6. def triple_print(n):
x = 0
while x != 3:
print(n)
x += 1
7. def wage():
h = eval(input("Ente... | {
"repo_name": "nsrchemie/code_guild",
"path": "wk2_quiz.py",
"copies": "1",
"size": "3436",
"license": "mit",
"hash": -3813929550033168000,
"line_mean": 35.1684210526,
"line_max": 119,
"alpha_frac": 0.7037252619,
"autogenerated": false,
"ratio": 3.3230174081237913,
"config_test": false,
"has_... |
0 High Card: Highest value card.
1 One Pair: Two cards of the same value.
2 Two Pairs: Two different pairs.
3 Three of a Kind: Three cards of the same value.
4 Straight: All cards are consecutive values.
5 Flush: All cards of the same suit.
6 Full House: Three of a kind and a pair.
7 Four of a Kind: Four cards of the s... | {
"repo_name": "alanbly/ProjectEuler",
"path": "54.py",
"copies": "1",
"size": "2925",
"license": "mit",
"hash": -1277487043613614000,
"line_mean": 24,
"line_max": 75,
"alpha_frac": 0.6437606838,
"autogenerated": false,
"ratio": 2.8179190751445087,
"config_test": false,
"has_no_keywords": fals... |
# 0 - iframe
# 1 - thumbs ( , as split)
# 2 - title
# 3 - tag
# 4 - category
# 5 - pornstar
# 6 - duration
import csv
from pymongo import MongoClient
# mongo connection
client = MongoClient()
# selecting database
db = client.amateurxxx
# collections
categoriesC = db.categories
videosC = db.videos
... | {
"repo_name": "vacu/redtube-import",
"path": "youporn_import.py",
"copies": "1",
"size": "2102",
"license": "mit",
"hash": -8469546705492532000,
"line_mean": 26.2857142857,
"line_max": 97,
"alpha_frac": 0.4388386483,
"autogenerated": false,
"ratio": 3.7317939609236235,
"config_test": false,
"... |
# 0 loop_fix branch
# 1 - Import library
import pygame
from pygame.locals import *
import math
import random
# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
pygame.mixer.init()
# 3 - Load images
player = pygame.image.load("resources/images/dude.png"... | {
"repo_name": "swapagarwal/bunnies-and-badgers",
"path": "Bunnies&Badgers.py",
"copies": "1",
"size": "9564",
"license": "mit",
"hash": -7625053873376202000,
"line_mean": 36.0697674419,
"line_max": 140,
"alpha_frac": 0.5420326223,
"autogenerated": false,
"ratio": 3.3652357494722027,
"config_tes... |
"""0MQ authentication related functions and classes."""
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
import datetime
import glob
import io
import os
import zmq
from zmq.utils.strtypes import bytes, unicode, b, u
_cert_secret_banner = u("""# **** Generated on {0} by... | {
"repo_name": "lancezlin/ml_template_py",
"path": "lib/python2.7/site-packages/zmq/auth/certs.py",
"copies": "24",
"size": "4179",
"license": "mit",
"hash": 5541343095134847000,
"line_mean": 32.1666666667,
"line_max": 104,
"alpha_frac": 0.6018186169,
"autogenerated": false,
"ratio": 3.77506775067... |
"""0MQ Constant names"""
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
# dictionaries of constants new or removed in particular versions
new_in = {
(2,2,0) : [
'RCVTIMEO',
'SNDTIMEO',
],
(3,2,2) : [
# errnos
'EMSGSIZE',
... | {
"repo_name": "sserrot/champion_relationships",
"path": "venv/Lib/site-packages/zmq/utils/constant_names.py",
"copies": "1",
"size": "11394",
"license": "mit",
"hash": -6736603251650287000,
"line_mean": 19.7163636364,
"line_max": 65,
"alpha_frac": 0.5510795155,
"autogenerated": false,
"ratio": 2.... |
"""0MQ Constants."""
# Copyright (c) PyZMQ Developers.
# Distributed under the terms of the Modified BSD License.
from zmq.backend import constants
from zmq.backend import has
from zmq.utils.constant_names import (
base_names,
switched_sockopt_names,
int_sockopt_names,
int64_sockopt_names,
bytes_s... | {
"repo_name": "josephkirk/PipelineTools",
"path": "packages/zmq/sugar/constants.py",
"copies": "1",
"size": "2468",
"license": "bsd-2-clause",
"hash": -7618709390858384000,
"line_mean": 22.5047619048,
"line_max": 78,
"alpha_frac": 0.5891410049,
"autogenerated": false,
"ratio": 3.432545201668985,
... |
"""0MQ Constants."""
# Copyright (c) PyZMQ Developers.
# Distributed under the terms of the Modified BSD License.
from zmq.backend import constants
from zmq.utils.constant_names import (
base_names,
switched_sockopt_names,
int_sockopt_names,
int64_sockopt_names,
bytes_sockopt_names,
fd_sockopt... | {
"repo_name": "swn1/pyzmq",
"path": "zmq/sugar/constants.py",
"copies": "10",
"size": "2355",
"license": "bsd-3-clause",
"hash": 3445862275744525000,
"line_mean": 22.3168316832,
"line_max": 78,
"alpha_frac": 0.5842887473,
"autogenerated": false,
"ratio": 3.437956204379562,
"config_test": false,... |
"""0MQ Error classes and functions."""
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
from errno import EINTR
class ZMQBaseError(Exception):
"""Base exception class for 0MQ errors in Python."""
pass
class ZMQError(ZMQBaseError):
"""Wrap an errno style error.... | {
"repo_name": "dash-dash/pyzmq",
"path": "zmq/error.py",
"copies": "7",
"size": "4898",
"license": "bsd-3-clause",
"hash": 8340425690789371000,
"line_mean": 25.192513369,
"line_max": 97,
"alpha_frac": 0.5902409147,
"autogenerated": false,
"ratio": 4.07826810990841,
"config_test": false,
"has_... |
"""0MQ Error classes and functions."""
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
class ZMQBaseError(Exception):
"""Base exception class for 0MQ errors in Python."""
pass
class ZMQError(ZMQBaseError):
"""Wrap an errno style error.
Parameters
----... | {
"repo_name": "dimagol/trex-core",
"path": "scripts/external_libs/pyzmq-14.5.0/python2/intel/ucs4/64bit/zmq/error.py",
"copies": "21",
"size": "4254",
"license": "apache-2.0",
"hash": -2109089334493122000,
"line_mean": 24.9390243902,
"line_max": 97,
"alpha_frac": 0.5825105783,
"autogenerated": fals... |
"""0MQ polling related functions and classes."""
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
import zmq
from zmq.backend import zmq_poll
from .constants import POLLIN, POLLOUT, POLLERR
#-----------------------------------------------------------------------------
# Po... | {
"repo_name": "sserrot/champion_relationships",
"path": "venv/Lib/site-packages/zmq/sugar/poll.py",
"copies": "1",
"size": "5578",
"license": "mit",
"hash": -8821430977959501000,
"line_mean": 33.4320987654,
"line_max": 104,
"alpha_frac": 0.5537827178,
"autogenerated": false,
"ratio": 4.4624,
"c... |
# [\0] #
# #
# This code is confidential and proprietary, All rights reserved. #
# #
# Tamar Labs 2015. #
# #
# @author: Adam Lev-Libfeld (adam@tamarlabs.... | {
"repo_name": "daTokenizer/quickstorm",
"path": "storm/src/spouts/qspout.py",
"copies": "1",
"size": "1261",
"license": "apache-2.0",
"hash": -1845188087641268700,
"line_mean": 30.525,
"line_max": 93,
"alpha_frac": 0.5678033307,
"autogenerated": false,
"ratio": 3.512534818941504,
"config_test":... |
# 0 = open space, 1=boundary , 2= the robot, 3= finish
def maze_vision():
path= ''
maze=[]
maze.append(list('000000002000000'))
maze.append(list('000000003001100'))
maze.append(list('000000000000000'))
maze.append(list('000000000000000'))
maze.append(list('000000000000000'))
maze.append(list('000... | {
"repo_name": "jpschnel/maze-vision",
"path": "maze_vision.py",
"copies": "1",
"size": "2411",
"license": "apache-2.0",
"hash": -8237789192253436000,
"line_mean": 20.3240740741,
"line_max": 82,
"alpha_frac": 0.5777685608,
"autogenerated": false,
"ratio": 2.2940057088487156,
"config_test": false... |
#0 seznam zvířat
dom_zvirata = ['pes','kočka','kralík','had']
#4 jména zvířat
moji_mazlicci = ['Chula', 'Gordo', 'Bondy', 'Alan', 'Sancho']
vasi_mazlicci = ['Chula', 'Gordo', 'Brok', 'Alfonso', 'Silák']
spolecni_mazlicci = []
jen_moji = []
jen_vasi = []
for jmena_1 in moji_mazlicci:
for jmena_2 in vasi_mazlicci:
... | {
"repo_name": "Zuzanita/PyZuzu",
"path": "DP_07_seznamy/Jmena_mazliku.py",
"copies": "1",
"size": "1217",
"license": "mit",
"hash": -4555907480182074400,
"line_mean": 29.6666666667,
"line_max": 62,
"alpha_frac": 0.6747491639,
"autogenerated": false,
"ratio": 2.0514579759862777,
"config_test": f... |
## 0. struct
import collections
Object = collections.namedtuple('Object', ('balanced', 'height'));
C = Object(True, -1);
print(C.balanced, C.height);
## 1. Class (structure):
class ListNode:
def __init__(self, data=0, next_node=None):
self.data = data;
self.next = next_node;
A = ListNode();
class... | {
"repo_name": "Liuqian0501/elements-of-programming-interview",
"path": "data structure/python/python_data_structure.py",
"copies": "1",
"size": "3569",
"license": "mit",
"hash": 4765714974546848000,
"line_mean": 21.8782051282,
"line_max": 76,
"alpha_frac": 0.5396469599,
"autogenerated": false,
"r... |
0#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 23 14:23:25 2017
@authors: Mikel Zemborain, Houghton Yonge, Fuming Qiu, and Viva R. Horowitz
"""
#--------------------------------Library Imports------------------------------#
from PyQt5 import QtWidgets
from PyQt5.QtCore import QTimer
import sy... | {
"repo_name": "horowitz-lab/photon-counting",
"path": "Photon_Counter_GPIB.py",
"copies": "1",
"size": "14098",
"license": "mit",
"hash": -7452355780520665000,
"line_mean": 36.2962962963,
"line_max": 117,
"alpha_frac": 0.5714285714,
"autogenerated": false,
"ratio": 3.9869909502262444,
"config_t... |
# 0: WBAN
# 1: Date
# 2: Time
# 3: StationType
# 4: SkyCondition
# 5: SkyConditionFlag
# 6: Visibility
# 7: VisibilityFlag
# 8: WeatherType
# 9: WeatherTypeFlag
# 10: DryBulbFarenheit
# 11: DryBulbFarenheitFlag
# 12: DryBulbCelsius
# 13: DryBulbCelsiusFlag
# 14: WetBulbFarenheit
# 15: WetBulbFarenheitFlag
# 1... | {
"repo_name": "datamade/wopr-data",
"path": "code/processors/catch_format_diffs.py",
"copies": "1",
"size": "3480",
"license": "mit",
"hash": 5743411063735500000,
"line_mean": 29,
"line_max": 95,
"alpha_frac": 0.6781609195,
"autogenerated": false,
"ratio": 2.664624808575804,
"config_test": fals... |
"""10,001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
the 6th prime is 13.
What is the 10,001st prime number?
"""
from euler.solutions import solution_5
def find_nth_prime(n):
"""Find the nth prime number by computing prime factorizations.
If an upper bound for t... | {
"repo_name": "rlucioni/project-euler",
"path": "euler/solutions/solution_7.py",
"copies": "1",
"size": "1029",
"license": "mit",
"hash": -3996143416320888000,
"line_mean": 28.4,
"line_max": 79,
"alpha_frac": 0.6258503401,
"autogenerated": false,
"ratio": 3.972972972972973,
"config_test": false... |
# 10001st prime
# Problem 7
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
#
# What is the 10001st prime number?
#
# Using a slightly modified sieve implementation from Problem 5,
# but returning a list instead of set, this is simple to do.
#
# Can guess size of s... | {
"repo_name": "YangLuGitHub/Euler",
"path": "src/scripts/Problem7.py",
"copies": "1",
"size": "1723",
"license": "mit",
"hash": 8402896768148650000,
"line_mean": 28.7068965517,
"line_max": 102,
"alpha_frac": 0.6453859547,
"autogenerated": false,
"ratio": 3.065836298932384,
"config_test": false,... |
# 10001st prime
# Problem 7
#
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
# What is the 10001st prime number?
import itertools
N = 10001
def is_divisible_by_one(x, factors):
for factor in factors:
if x % factor == 0:
return True
... | {
"repo_name": "chjdev/euler",
"path": "python/problem7.py",
"copies": "1",
"size": "1107",
"license": "bsd-2-clause",
"hash": -2022629770251505200,
"line_mean": 24.7441860465,
"line_max": 102,
"alpha_frac": 0.6016260163,
"autogenerated": false,
"ratio": 3.3545454545454545,
"config_test": false,... |
# 1000-digit Fibonacci number
# Problem 25
# The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
# Hence the first 12 terms will be:
#
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 = 5
# F6 = 8
# F7 = 13
# F8 = 21
# F9 = 34
# F10 = 55
# F11 = 89
# F12 = 144
# The 12th... | {
"repo_name": "YangLuGitHub/Euler",
"path": "src/scripts/Problem25.py",
"copies": "1",
"size": "1371",
"license": "mit",
"hash": -3778833256510314000,
"line_mean": 26.34,
"line_max": 114,
"alpha_frac": 0.685442575,
"autogenerated": false,
"ratio": 2.9397849462365593,
"config_test": false,
"ha... |
# 10/05/2021
import random
alice, bob, carol, dave, erin, frank, gina = (0,) * 7
for prize in random.choices((1, 2, 3), k=1000):
alice += prize == 1
for prize in random.choices((1, 2, 3), k=1000):
bob += prize != 1
for prize in random.choices((1, 2, 3), k=1000):
pick = random.randint(1, 3)
show = ... | {
"repo_name": "tlgs/dailyprogrammer",
"path": "Python/easy/e389.py",
"copies": "1",
"size": "1185",
"license": "unlicense",
"hash": 4094641048538243600,
"line_mean": 25.3333333333,
"line_max": 61,
"alpha_frac": 0.5755274262,
"autogenerated": false,
"ratio": 2.5538793103448274,
"config_test": fa... |
# 10.07.2007, c
# last revision: 25.03.2008
from __future__ import absolute_import
from sfepy import data_dir
from sfepy.mechanics.matcoefs import stiffness_from_lame
filename_meshes = ['/meshes/3d/cube_medium_tetra.mesh',
'/meshes/3d/cube_medium_tetra.mesh',
'/meshes/3d/cube_medi... | {
"repo_name": "sfepy/sfepy",
"path": "tests/test_elasticity_small_strain.py",
"copies": "5",
"size": "5744",
"license": "bsd-3-clause",
"hash": -1732080147768210000,
"line_mean": 26.7487922705,
"line_max": 72,
"alpha_frac": 0.4895543175,
"autogenerated": false,
"ratio": 3.23970671178793,
"confi... |
"""1008. Construct Binary Search Tree from Preorder Traversal
https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal
Return the root node of a binary search tree that matches the given preorder
traversal.
(Recall that a binary search tree is a binary tree where for every node, any
descend... | {
"repo_name": "isudox/leetcode-solution",
"path": "python-algorithm/leetcode/construct_binary_search_tree_from_preorder_traversal.py",
"copies": "1",
"size": "2247",
"license": "mit",
"hash": -3512974907669293000,
"line_mean": 29.2837837838,
"line_max": 82,
"alpha_frac": 0.5658188309,
"autogenerate... |
# 100 documents take about 600 MB RAM
from nltk import NaiveBayesClassifier, classify, FreqDist
import FileHandler as FH
import Document as Doc
from TextProcessor import TextProcessor as TP
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import *
class Classifier():
def SK_NB_train(self, trainD... | {
"repo_name": "jahanzebk/python-text-classifier",
"path": "Classifier.py",
"copies": "1",
"size": "7324",
"license": "mit",
"hash": -9069071199593002000,
"line_mean": 34.04784689,
"line_max": 131,
"alpha_frac": 0.5598033861,
"autogenerated": false,
"ratio": 4.068888888888889,
"config_test": tru... |
#100% for part 1 and part 2
#Part 1: Terminology (15 points)
#1 1pt) What is the symbol "=" used for?
#The symbol "=" is used to assign a value.
#1 Correct
#
#2 3pts) Write a technical definition for 'function'
#A function is a sequence of instructions to perform a calculation.
# 3 Correct
#
#3 1pt) What does the ke... | {
"repo_name": "tonsom1592-cmis/tonsom1592-cmis-cs2",
"path": "cs2quiz1.py",
"copies": "1",
"size": "2315",
"license": "cc0-1.0",
"hash": 6763219833586417000,
"line_mean": 28.6794871795,
"line_max": 201,
"alpha_frac": 0.6807775378,
"autogenerated": false,
"ratio": 2.9794079794079793,
"config_tes... |
#### 100% of CREDIT TO ERIK HALLSTORM used for benchmarking
from __future__ import print_function
import matplotlib
import matplotlib.pyplot as plt
import tensorflow as tf
import time
def get_times(maximum_time):
device_times = {
"/gpu:0":[],
"/cpu:0":[]
}
matrix_sizes = range(500,50000,... | {
"repo_name": "swirlingsand/self-driving-car-nanodegree-nd013",
"path": "play/benchmark-test-copy-paste-from-erik-hallstrom.py",
"copies": "1",
"size": "1579",
"license": "mit",
"hash": 1136365113537082100,
"line_mean": 29.9803921569,
"line_max": 89,
"alpha_frac": 0.5820139329,
"autogenerated": fal... |
# 100. Same Tree - LeetCode
# https://leetcode.com/problems/same-tree/description/
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def pre_order_traversal(tn):
res = [tn.val]
if tn.left is None ... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/100_same-tree.py",
"copies": "1",
"size": "1215",
"license": "mit",
"hash": -3079274060154637300,
"line_mean": 21.1090909091,
"line_max": 86,
"alpha_frac": 0.5563786008,
"autogenerated": false,
"ratio": 3.155844155844156,
"config_te... |
__author__ = 'Libao Jin'
__date__ = 'December 13, 2015'
# 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 isSameTree(self, p, q):
"""
:type p: TreeNode
... | {
"repo_name": "imthomasking/LeetCode-Solutions",
"path": "solutions/100_Same_Tree.py",
"copies": "2",
"size": "1318",
"license": "mit",
"hash": 2117289901765007000,
"line_mean": 20.9666666667,
"line_max": 85,
"alpha_frac": 0.4992412747,
"autogenerated": false,
"ratio": 3.2463054187192117,
"conf... |
# 10170,7840;
# http://cmc.music.columbia.edu/chiplotle/manual/chapters/api/hpgl.html
from chiplotle import *
plotter = instantiate_plotters()[0]
#plotter = plottertools.instantiate_virtual_plotter()
import math
paper_width = 10170
paper_height = 7840
image_width = 3000;
image_height = 3800;
border_width = ((paper... | {
"repo_name": "wolftype/pony",
"path": "old/forcetest.py",
"copies": "1",
"size": "1240",
"license": "bsd-2-clause",
"hash": 4750363425905681000,
"line_mean": 20.7543859649,
"line_max": 121,
"alpha_frac": 0.6814516129,
"autogenerated": false,
"ratio": 2.494969818913481,
"config_test": false,
... |
# # 10.1
#
# tens_list = [10, 20, 30, 40]
# funny_strings = ['crunchy frog', 'ram bladder', 'lark vomit']
# some_other = ['spam', 2.0, 5, [10, 20]]
#
# empty_list = []
#
# print(tens_list)
# print(funny_strings)
# print(some_other)
# print(empty_list)
# print()
# print(tens_list[1:])
# print(funny_strings[1])
# print(s... | {
"repo_name": "UWPCE-PythonCert/IntroPython2016",
"path": "students/sheree/session_02/homework/TP2-Ch10-Scratch.py",
"copies": "3",
"size": "2517",
"license": "unlicense",
"hash": 8762222992159565000,
"line_mean": 19.2983870968,
"line_max": 241,
"alpha_frac": 0.5740961462,
"autogenerated": false,
... |
# 101. Symmetric Tree - LeetCode
# https://leetcode.com/problems/symmetric-tree/description/
# Bonus points if you could solve it both recursively and iteratively.
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = ... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/101_symmetric-tree.py",
"copies": "1",
"size": "1273",
"license": "mit",
"hash": 400701219315914400,
"line_mean": 28.6279069767,
"line_max": 87,
"alpha_frac": 0.6017282011,
"autogenerated": false,
"ratio": 3.5068870523415976,
"confi... |
# 101. Symmetric Tree - LeetCode
# https://leetcode.com/problems/symmetric-tree/description/
# iteratively trial
# 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 isSymmetric(... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/101_symmetric-tree_i.py",
"copies": "1",
"size": "1263",
"license": "mit",
"hash": 7761590385831952000,
"line_mean": 25.3333333333,
"line_max": 80,
"alpha_frac": 0.5083135392,
"autogenerated": false,
"ratio": 3.7701492537313435,
"co... |
"""101. Symmetric Tree
https://leetcode.com/problems/symmetric-tree/description/
Given a binary tree, check whether it is a mirror of itself (ie, symmetric
around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
3241423
But the following [1,2,2,null... | {
"repo_name": "isudox/leetcode-solution",
"path": "python-algorithm/leetcode/symmetric_tree.py",
"copies": "1",
"size": "1896",
"license": "mit",
"hash": 905953582459806300,
"line_mean": 23.3896103896,
"line_max": 74,
"alpha_frac": 0.5111821086,
"autogenerated": false,
"ratio": 3.490706319702602,... |
# 10/29/15
# Cindy Mo
# clean data from translated text file
# remove stop words
import sys
from collections import OrderedDict
import csv
import numpy as np
import pandas as pd
import re
import json
import nltk
nltk.download("wordnet")
# data file
description = open("../description_pp/description.csv")
csv_... | {
"repo_name": "rishizsinha/project-beta",
"path": "code/dataclean.py",
"copies": "3",
"size": "3411",
"license": "bsd-3-clause",
"hash": 5796022785475638000,
"line_mean": 29.185840708,
"line_max": 112,
"alpha_frac": 0.6493696863,
"autogenerated": false,
"ratio": 2.984251968503937,
"config_test"... |
# 10/29/15
# Cindy Mo
# clean data from translated text file
# remove stop words
from collections import OrderedDict
import csv
import numpy as np
import pandas as pd
import re
import json
import nltk
# data file
description = open("../description_pp/description.csv")
csv_description = csv.reader(descriptio... | {
"repo_name": "cxmo/project-beta",
"path": "code/dataclean.py",
"copies": "1",
"size": "3376",
"license": "bsd-3-clause",
"hash": 1535760709174704600,
"line_mean": 29.1428571429,
"line_max": 112,
"alpha_frac": 0.6478080569,
"autogenerated": false,
"ratio": 2.9876106194690264,
"config_test": fal... |
"""102. Binary Tree Level Order Traversal
https://leetcode.com/problems/binary-tree-level-order-traversal/
Given a binary tree, return the level order traversal of its nodes' values.
(ie, from left to right, level by level).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15... | {
"repo_name": "isudox/leetcode-solution",
"path": "python-algorithm/leetcode/binary_tree_level_order_traversal.py",
"copies": "1",
"size": "1039",
"license": "mit",
"hash": 7946465741639012000,
"line_mean": 19.8775510204,
"line_max": 75,
"alpha_frac": 0.550342131,
"autogenerated": false,
"ratio":... |
#####10/2 Second Round Interview with Linkedin
__iter__()
next()
/** A reference to a file. */
public class TextFile implements Iterable<String>
{
public TextFile(String fileName) { // please implement this
}
/** Begin reading the file, line by line. The returned Iterator.next() will return a line. */
@Ov... | {
"repo_name": "cyandterry/Python-Study",
"path": "Interviews/Real_Life/Second_Round_Interview_with_Linkedin.py",
"copies": "2",
"size": "2781",
"license": "mit",
"hash": -4338085256662038000,
"line_mean": 17.7972972973,
"line_max": 95,
"alpha_frac": 0.5012585401,
"autogenerated": false,
"ratio": ... |
# 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 200... | {
"repo_name": "jerrydeboer/crs-assignments",
"path": "assignement102.py",
"copies": "1",
"size": "1113",
"license": "cc0-1.0",
"hash": -239392148094853340,
"line_mean": 33.78125,
"line_max": 261,
"alpha_frac": 0.6909254268,
"autogenerated": false,
"ratio": 3.1709401709401708,
"config_test": fal... |
# 1036. Escape a Large Maze
# The difficulty is hard, but should be medium.
class Solution:
def isEscapePossible(
self, blocked: List[List[int]], source: List[int], target: List[int]
) -> bool:
# Calculates the mapping
def calcMapping(z):
z.sort()
mapz = {z[0]: 0... | {
"repo_name": "digiter/Arena",
"path": "1036-escape-a-large-maze.py",
"copies": "1",
"size": "1714",
"license": "mit",
"hash": 255910287769141630,
"line_mean": 30.7407407407,
"line_max": 76,
"alpha_frac": 0.4299883314,
"autogenerated": false,
"ratio": 3.4556451612903225,
"config_test": false,
... |
# 1043. Partition Array for Maximum Sum - LeetCode Contest
# https://leetcode.com/contest/weekly-contest-136/problems/partition-array-for-maximum-sum/
# Runtime: 1784 ms
# Memory Usage: 97.4 MB
from functools import lru_cache
INT_MIN = 0
class Solution:
@lru_cache(maxsize=None)
def subarray_maxsum(self,star... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/1043_partition-array-for-maximum-sum.py",
"copies": "1",
"size": "1240",
"license": "mit",
"hash": 7676276806878836000,
"line_mean": 27.4418604651,
"line_max": 95,
"alpha_frac": 0.5785597381,
"autogenerated": false,
"ratio": 2.7216035... |
__author__ = 'Libao Jin'
__date__ = 'December 13, 2015'
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def add_left_node(self, y):
self.left = y
def add_right_node(self, y):
self.... | {
"repo_name": "jinlibao/LeetCode-Solutions",
"path": "solutions/104_Maximum_Depth_Binary_Tree.py",
"copies": "2",
"size": "1560",
"license": "mit",
"hash": -3180895947209529000,
"line_mean": 24.5737704918,
"line_max": 64,
"alpha_frac": 0.5493589744,
"autogenerated": false,
"ratio": 3.107569721115... |
"""105. Construct Binary Tree from Preorder and Inorder Traversal
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
For example, given
preor... | {
"repo_name": "isudox/leetcode-solution",
"path": "python-algorithm/leetcode/construct_binary_tree_from_preorder_and_inorder_traversal.py",
"copies": "1",
"size": "1114",
"license": "mit",
"hash": 2206194709725937000,
"line_mean": 26.575,
"line_max": 87,
"alpha_frac": 0.6699909338,
"autogenerated":... |
# 107. Binary Tree Level Order Traversal II - LeetCode
# https://leetcode.com/problems/binary-tree-level-order-traversal-ii/description/
# 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... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/107_binary-tree-level-order-traversal-ii.py",
"copies": "1",
"size": "1140",
"license": "mit",
"hash": 4746788746615752000,
"line_mean": 27.525,
"line_max": 81,
"alpha_frac": 0.5096491228,
"autogenerated": false,
"ratio": 3.8255033557... |
''' 10-angle_to_earth.py
=========================
AIM: Similar to 9-plot_flux.py, but shows angle to Earth limb instead of sl flux
INPUT: files: - <orbit_id>_misc/orbits.dat
- <orbit_id>_flux/flux_*.dat
- resources/moon_*.dat, sun_*.dat, orbits_*.dat
variables: see section PARAMETERS (below)
OUTPUT: in <orbit_... | {
"repo_name": "kuntzer/SALSA-public",
"path": "10_angle_to_earth.py",
"copies": "1",
"size": "6383",
"license": "bsd-3-clause",
"hash": -4703785933075812000,
"line_mean": 27.2433628319,
"line_max": 109,
"alpha_frac": 0.6313645621,
"autogenerated": false,
"ratio": 2.5915550142103125,
"config_tes... |
"""10 book samples."""
from store.book.models import Book
b1 = Book('9780439708180', "Harry Potter and the Philosopher's Stone",
"J. K. Rowling", "Scholastic", 1999, 10, 6.79, "paperback", "fantasy", "fantasy")
b2 = Book('9780439064873', "Harry Potter And The Chamber Of Secrets",
"J. K. Rowling",... | {
"repo_name": "tankca/store",
"path": "store/dummy_data/books.py",
"copies": "4",
"size": "5374",
"license": "bsd-3-clause",
"hash": 3547542480651429400,
"line_mean": 80.4242424242,
"line_max": 219,
"alpha_frac": 0.6950130257,
"autogenerated": false,
"ratio": 2.620185275475378,
"config_test": f... |
# 10_email_notifier.py
# From the code for the Electronics Starter Kit for the Raspberry Pi by MonkMakes.com
# Based on Recipe 7.15 in The Raspberry Pi Cookbook by Simon Monk.
import RPi.GPIO as GPIO
import smtplib, time # smtp - Simple Mail Transport Protocol - library for sending email
SMTP_SERVER = 'smt... | {
"repo_name": "simonmonk/pi_starter_kit",
"path": "10_mail.py",
"copies": "1",
"size": "2127",
"license": "mit",
"hash": 4129862322390031400,
"line_mean": 33.3225806452,
"line_max": 99,
"alpha_frac": 0.6779501646,
"autogenerated": false,
"ratio": 3.4141252006420544,
"config_test": false,
"has... |
#"10 Minutes to pandas" tutorial
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
class ObjectCreator:
"""Object creation demo"""
def __init__(self):
self.data = []
def createSeries(self):
s = pd.Series( [1,3,5,np.nan,6,8] );
return s
def createDataFram... | {
"repo_name": "mattmcd/PyAnalysis",
"path": "mda/tutorial/pandastut.py",
"copies": "1",
"size": "1920",
"license": "apache-2.0",
"hash": 9077875458698445000,
"line_mean": 27.6567164179,
"line_max": 80,
"alpha_frac": 0.5625,
"autogenerated": false,
"ratio": 3.699421965317919,
"config_test": fals... |
"""10. Regular Expression Matching
https://leetcode.com/problems/regular-expression-matching/description/
Given an input string (s) and a pattern (p), implement regular expression
matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matchi... | {
"repo_name": "isudox/leetcode-solution",
"path": "python-algorithm/leetcode/regular_expression_matching.py",
"copies": "1",
"size": "1801",
"license": "mit",
"hash": 2136845455099409200,
"line_mean": 18.2903225806,
"line_max": 77,
"alpha_frac": 0.5735785953,
"autogenerated": false,
"ratio": 3.13... |
# 10-regular-expression-matching.py
class Solution(object):
def isMatch_tle(self, s, p):
"""
:type s: str
:type p: str
:rtype: bool
"""
# Correct, but TLE
# Same method ACed in C/C++, I've tried eliminate function call,
# which saved around 1.5s
... | {
"repo_name": "daicang/Leetcode-solutions",
"path": "010-regular-expression-matching.py",
"copies": "1",
"size": "2047",
"license": "mit",
"hash": 6385574247902885000,
"line_mean": 30.4923076923,
"line_max": 74,
"alpha_frac": 0.3805569126,
"autogenerated": false,
"ratio": 3.2338072669826223,
"c... |
# 10_RGB_LED.py
from tkinter import *
import RPi.GPIO as GPIO
import time
# Configure the Pi to use the BCM (Broadcom) pin names, rather than the pin positions
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
# Start Pulse Width Modulation (PWM) on the red, green... | {
"repo_name": "simonmonk/prog_pi_ed2",
"path": "10_RGB_LED.py",
"copies": "1",
"size": "2182",
"license": "mit",
"hash": 8000308267194469000,
"line_mean": 30.1714285714,
"line_max": 85,
"alpha_frac": 0.6539871677,
"autogenerated": false,
"ratio": 3.398753894080997,
"config_test": false,
"has_... |
# 1113, 15 Jan 2018 (NZDT)
# 1305, 9 Jan 2018 (NZDT)
#
# Nevil Brownlee, U Auckland
# imported as wp
'''
Elements not allowed in SVG 1.2:
https://www.ruby-forum.com/topic/144684
http://inkscape.13.x6.nabble.com/SVG-Tiny-td2881845.html
marker
clipPath
style properties come from the CSS, they are allowed ... | {
"repo_name": "nevil-brownlee/check_svg",
"path": "word_properties.py",
"copies": "1",
"size": "11930",
"license": "mit",
"hash": 5419376553509860000,
"line_mean": 44.0188679245,
"line_max": 85,
"alpha_frac": 0.4177703269,
"autogenerated": false,
"ratio": 3.95163961576681,
"config_test": false,... |
# 1.1.13 Write a code fragment to print the transposition
# (rows and columns changed) of a two-dimensional array with
# M rows and N columns
def transpose(matrix):
'''
Transposes a 2-d array of lists
INPUT: 2-d list of any values
RETURNS: Transposed 2-d list of values
'''
num_rows = le... | {
"repo_name": "timgasser/algorithms_4ed",
"path": "ch1_fundamentals/ex1.1.13.py",
"copies": "1",
"size": "1124",
"license": "mit",
"hash": 6568593141977688000,
"line_mean": 25.1395348837,
"line_max": 61,
"alpha_frac": 0.4973309609,
"autogenerated": false,
"ratio": 3.4164133738601823,
"config_te... |
""" 11 150 10 0.01 0.01 0.01
12 50 30 0.1 0.05 0.5
13 100 20 0.01 0.05 0.05
14 400 10 0.005 0.05 0.05
15 100 20 0.01 0.05 0.05
16 100 20 0.01 0.05 0.05
17 100 20 0.01 0.05 0.05
18 100 20 0.01 0.05 0.05
19 100 20 0.01 0.05 0.05
20 100 20 0.01 0.05 0.05
"""
from lib.niching_func import niching_func
from lib.cou... | {
"repo_name": "folivetti/LINKEDOPT",
"path": "SRC/Startup.py",
"copies": "1",
"size": "6468",
"license": "mit",
"hash": 7253949087926167000,
"line_mean": 32,
"line_max": 123,
"alpha_frac": 0.5632343847,
"autogenerated": false,
"ratio": 2.605962933118453,
"config_test": false,
"has_no_keywords... |
# 11.1 Define Apple with four
# instance variables that represent four attributes
# class Apple():
# def __init__(self, color, shape, weight, crunch):
# self.color = color
# self.shape = shape
# self.weight = weight
# self.crunch = crunch
#
# 11.2 Define Circle with method called ar... | {
"repo_name": "Frikeer/LearnPython",
"path": "exc11/exc11.py",
"copies": "1",
"size": "1431",
"license": "unlicense",
"hash": 5325428921563553000,
"line_mean": 25.5,
"line_max": 74,
"alpha_frac": 0.642907058,
"autogenerated": false,
"ratio": 3.282110091743119,
"config_test": false,
"has_no_ke... |
#11/21/2012
#legacy-client application
"""
<Purpose>
Legacy application with built-in software updater
Application does:
- call built-in software updater for updates
- does its regular work (contact google server)
- quit
Built in software updater does the following:
- get manifest from server
- comp... | {
"repo_name": "monzum/tuf-legacy",
"path": "scripts/client/legacy-client.py",
"copies": "1",
"size": "4637",
"license": "mit",
"hash": 5968488940114300000,
"line_mean": 26.9337349398,
"line_max": 96,
"alpha_frac": 0.6560276041,
"autogenerated": false,
"ratio": 3.328786791098349,
"config_test": ... |
# 112. Path Sum - LeetCode
# https://leetcode.com/problems/path-sum/description/
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def has_sum_with_parent( self, root, current_sum, target_sum ):
if root is Non... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/112_path-sum.py",
"copies": "1",
"size": "1269",
"license": "mit",
"hash": 8305903028106875000,
"line_mean": 26.0212765957,
"line_max": 80,
"alpha_frac": 0.5831363278,
"autogenerated": false,
"ratio": 3.141089108910891,
"config_test... |
# 112. Path Sum
# Given a binary tree and a sum,
# determine if the tree has a root-to-leaf path
# such that adding up all the values along the path equals the given sum.
#
# For example:
# Given the below binary tree and sum = 22,
# 5
# / \
# 4 8
# / / \
# ... | {
"repo_name": "gengwg/leetcode",
"path": "112_path_sum.py",
"copies": "1",
"size": "1183",
"license": "apache-2.0",
"hash": -5073569330014601000,
"line_mean": 25.2888888889,
"line_max": 104,
"alpha_frac": 0.5562130178,
"autogenerated": false,
"ratio": 3.3994252873563218,
"config_test": false,
... |
# 113. Path Sum II
#
# Given a binary tree and a sum,
# find all root-to-leaf paths where each path's sum equals the given sum.
#
# For example:
# Given the below binary tree and sum = 22,
# 5
# / \
# 4 8
# / / \
# 11 13 4
# / \ / \
# ... | {
"repo_name": "gengwg/leetcode",
"path": "113_path_sum_ii.py",
"copies": "1",
"size": "1573",
"license": "apache-2.0",
"hash": 4854118787909974000,
"line_mean": 23.2,
"line_max": 74,
"alpha_frac": 0.5301970757,
"autogenerated": false,
"ratio": 3.0662768031189085,
"config_test": false,
"has_no... |
# 1.1.3 Write a program that takes three integer command-line arguments and
# prints equal if all three are equal, and not equal otherwise.
# Needed to get command line arguments
import sys
def main(argv=None):
'''
Function called to run main script including unit tests
INPUT: List of arguments from the... | {
"repo_name": "timgasser/algorithms_4ed",
"path": "ch1_fundamentals/ex1.1.3.py",
"copies": "1",
"size": "2468",
"license": "mit",
"hash": 5104426533229425000,
"line_mean": 23.69,
"line_max": 76,
"alpha_frac": 0.6077795786,
"autogenerated": false,
"ratio": 4.154882154882155,
"config_test": false... |
# 116. Populating Next Right Pointers in Each Node
#
# Given a binary tree
#
# struct TreeLinkNode {
# TreeLinkNode *left;
# TreeLinkNode *right;
# TreeLinkNode *next;
# }
# Populate each next pointer to point to its next right node.
# If there is no next right node, the next pointer should be... | {
"repo_name": "gengwg/leetcode",
"path": "116_populate_next_right_pointers_in_each_node.py",
"copies": "1",
"size": "1722",
"license": "apache-2.0",
"hash": 3474218222078998000,
"line_mean": 25.0909090909,
"line_max": 76,
"alpha_frac": 0.5569105691,
"autogenerated": false,
"ratio": 3.617647058823... |
# 117. Populating Next Right Pointers in Each Node II
#
# Follow up for problem "Populating Next Right Pointers in Each Node".
#
# What if the given tree could be any binary tree? Would your previous solution still work?
#
# Note:
#
# You may only use constant extra space.
# For example,
# Given the following binary tr... | {
"repo_name": "gengwg/leetcode",
"path": "117_populate_next_right_pointers_in_each_node_ii.py",
"copies": "1",
"size": "1316",
"license": "apache-2.0",
"hash": -6016741793466921000,
"line_mean": 25.8571428571,
"line_max": 125,
"alpha_frac": 0.5607902736,
"autogenerated": false,
"ratio": 3.5663956... |
__author__ = 'Libao Jin'
__date__ = 'December 17, 2015'
class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
tri = []
if numRows == 0:
tri = []
else:
tri = [[1]]
n = numRows -... | {
"repo_name": "jinlibao/LeetCode-Solutions",
"path": "solutions/118_Pascals_Triangle.py",
"copies": "2",
"size": "1044",
"license": "mit",
"hash": -4623694493488764000,
"line_mean": 21.6956521739,
"line_max": 47,
"alpha_frac": 0.4444444444,
"autogenerated": false,
"ratio": 3.5753424657534247,
"... |
"""
Copyright 2015 Ericsson AB
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distri... | {
"repo_name": "EricssonResearch/monad",
"path": "LookAhead/fitness.py",
"copies": "2",
"size": "14794",
"license": "apache-2.0",
"hash": -7549709397258059000,
"line_mean": 44.2415902141,
"line_max": 168,
"alpha_frac": 0.6111261322,
"autogenerated": false,
"ratio": 4.4240430622009566,
"config_te... |
''' 11-extract_long_periods.py
===============================================
AIM: Prepare cumulative plots (THIS SCRIPT IS WITHOUT STRAY LIGHT)
INPUT: files: - <orbit_id>_misc/orbits.dat
- <orbit_id>_flux/flux_*.dat
variables: see section PARAMETERS (below)
OUTPUT: in <orbit_id>_misc/ : complicated name files d... | {
"repo_name": "kuntzer/SALSA-public",
"path": "11_extract_long_periods.py",
"copies": "1",
"size": "7874",
"license": "bsd-3-clause",
"hash": -8099464799526264000,
"line_mean": 29.8784313725,
"line_max": 117,
"alpha_frac": 0.6558293117,
"autogenerated": false,
"ratio": 2.9646084337349397,
"conf... |
11import datetime
import hashlib
import time
from google.appengine.ext import db
# Used to normalize to UTC from wherever the app is running
UTC_DELTA = datetime.datetime.utcnow() - datetime.datetime.now()
class Profile(db.Model):
user = db.UserProperty()
username = db.StringProperty()
timezone_offset = ... | {
"repo_name": "progrium/workjournal",
"path": "models.py",
"copies": "1",
"size": "2834",
"license": "bsd-3-clause",
"hash": -5283953797323795000,
"line_mean": 29.8152173913,
"line_max": 99,
"alpha_frac": 0.6139731828,
"autogenerated": false,
"ratio": 3.798927613941019,
"config_test": false,
... |
# 1.1 Life and Death
# Programmed by Rachel J Morris
import pygame, sys, math
from pygame.locals import *
maximumPeople = input( "HOW MANY PEOPLE SHOULD BE IN A CIRCLE? " )
pygame.init()
fpsClock = pygame.time.Clock()
window = pygame.display.set_mode( ( 768, 768 ) )
pygame.display.set_caption( "Life and Death" )
bg... | {
"repo_name": "Rachels-Courses/CS210-Discrete-Structures",
"path": "Resources/Program Illustrations/1.1/1.1 Life and Death/main.py",
"copies": "1",
"size": "2594",
"license": "mit",
"hash": -6946892307444602000,
"line_mean": 28.816091954,
"line_max": 94,
"alpha_frac": 0.5447185813,
"autogenerated":... |
# 1.1 Magic Trick Illustration
# Programmed by Rachel J Morris
import pygame, sys
from pygame.locals import *
pygame.init()
fpsClock = pygame.time.Clock()
window = pygame.display.set_mode( ( 1024, 768 ) )
pygame.display.set_caption( "Magic Trick" )
bgColor = pygame.Color( 140, 225, 255 )
txtColor = pygame.Color( 0, ... | {
"repo_name": "Rachels-Courses/CS210-Discrete-Structures",
"path": "Resources/Program Illustrations/1.1/1.1 Magic Trick/main.py",
"copies": "1",
"size": "3305",
"license": "mit",
"hash": -758687320300613500,
"line_mean": 33.4270833333,
"line_max": 136,
"alpha_frac": 0.5167927383,
"autogenerated": f... |
#1.1
def isunique(s):
letters = []
for letter in s:
if letter in letters:
return False
else:
letters.append(letter)
return True
def isUniqueInPlace(s):
for i in xrange(0,len(s)):
for j in xrange(i+1,len(s)):
if s[j]==s[i]:
return False
return True
#1.2
def checkPermutation(s1,s2):
if sorted(l... | {
"repo_name": "singhjaideep/Stuff",
"path": "stringsnarray.py",
"copies": "1",
"size": "2349",
"license": "mit",
"hash": -5602252068129803000,
"line_mean": 21.1698113208,
"line_max": 120,
"alpha_frac": 0.6083439762,
"autogenerated": false,
"ratio": 2.2223273415326394,
"config_test": false,
"h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.