repo_name
stringclasses
400 values
branch_name
stringclasses
4 values
file_content
stringlengths
16
72.5k
language
stringclasses
1 value
num_lines
int64
1
1.66k
avg_line_length
float64
6
85
max_line_length
int64
9
949
path
stringlengths
5
103
alphanum_fraction
float64
0.29
0.89
alpha_fraction
float64
0.27
0.89
fengd13/tcpreplay_GUI
refs/heads/master
# -*- coding: utf-8 -*- """ Created on Wed Oct 31 10:36:40 2018 @author: fd """ # !/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 23 18:00:59 2018 @author: key1234 """ # -*- coding: utf-8 -*- """ Created on Tue Oct 23 14:24:35 2018 @author: fd """ import sys import time...
Python
405
32.671604
113
/tcpreplay_gui.py
0.519798
0.50819
fengd13/tcpreplay_GUI
refs/heads/master
# -*- coding: utf-8 -*- """ Created on Wed Oct 24 09:50:29 2018 @author: fd """ import json dic = { "真实流量测试": { "dspflow": ["flow.pcap"], "flow": ["flow2.pcap", "3.pcap"], }, "恶意流量测试": { "情况1": ["6.pcap"], "情况2": ...
Python
61
23.245901
45
/makejson.py
0.396753
0.375325
Imenbaa/Validity-index
refs/heads/master
# -*- coding: utf-8 -*- """ Created on Tue Nov 27 20:07:59 2018 @author: Imen """ import numpy as np import pandas as pd from sklearn.cluster import KMeans import matplotlib.pyplot as plt from sklearn.datasets.samples_generator import make_blobs #Create a database of random values of 4 features and a fi...
Python
88
31.852272
112
/validity_index_.py
0.657939
0.621349
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
import os import boto3 from numpy.random import rand def lambda_handler(event, context): body = f'{event["message"]} \n value: {rand()}' client = boto3.client('s3') client.put_object( Bucket=os.environ['BUCKET_NAME'], Key='sfn_first.txt', Body=body, ) return { 'bod...
Python
18
19.722221
51
/step_functions/step_functions/lambda_function/first/lambda_function.py
0.571046
0.563003
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
import pathlib from aws_cdk import core from aws_cdk.aws_iam import PolicyStatement, Effect, ManagedPolicy, ServicePrincipal, Role from aws_cdk.aws_lambda import AssetCode, LayerVersion, Function, Runtime from aws_cdk.aws_s3 import Bucket from aws_cdk.aws_stepfunctions import Task, StateMachine, Parallel from aws_cdk....
Python
203
29.906404
100
/step_functions/step_functions/step_functions_stack.py
0.545904
0.541281
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
def lambda_handler(event, context): if event['parallel_no'] == 1: raise Exception('強制的にエラーとします') return 'only 3rd message.'
Python
5
27.200001
38
/step_functions/step_functions/lambda_function/third/lambda_function.py
0.64539
0.631206
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
def lambda_handler(event, context): if event['parallel_no'] % 2 == 0: raise Exception('偶数です') return { 'message': event['message'], 'const_value': event['const_value'] }
Python
8
24.875
43
/step_functions/step_functions/lambda_function/second/lambda_function.py
0.555556
0.545894
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
import json def lambda_handler(event, context): # { # "resource": "arn:aws:lambda:region:id:function:sfn_error_lambda", # "input": { # "Error": "Exception", # "Cause": "{\"errorMessage\": \"\\u5076\\u6570\\u3067\\u3059\", # \"errorType\": \"Exception\", # ...
Python
21
31.952381
95
/step_functions/step_functions/lambda_function/error/lambda_function.py
0.49422
0.446532
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
#!/usr/bin/env python3 from aws_cdk import core from step_functions.step_functions_stack import StepFunctionsStack app = core.App() # CFnのStack名を第2引数で渡す StepFunctionsStack(app, 'step-functions') app.synth()
Python
13
15.384615
66
/step_functions/app.py
0.774648
0.765258
thinkAmi-sandbox/AWS_CDK-sample
refs/heads/master
AWS_SCIPY_ARN = 'arn:aws:lambda:region:account_id:layer:AWSLambda-Python37-SciPy1x:2'
Python
1
85
85
/step_functions/step_functions/settings.example.py
0.8
0.752941
yywang0514/dsnre
refs/heads/master
import sys import os import time import numpy as np import torch import torch.nn.functional as F import argparse import logging from lib import * from model import * def train(options): if not os.path.exists(options.folder): os.mkdir(options.folder) logger.setLevel(logging.DEBUG) formatter = logging.Formatter(...
Python
275
35.825455
138
/train.py
0.633356
0.621803
yywang0514/dsnre
refs/heads/master
import torch import torch.nn as nn import math class LayerNorm(nn.Module): """Layer Normalization class""" def __init__(self, features, eps=1e-6): super(LayerNorm, self).__init__() self.a_2 = nn.Parameter(torch.ones(features)) self.b_2 = nn.Parameter(torch.zeros(features)) self.eps = eps def forward(self...
Python
311
27.713827
177
/lib/module.py
0.672564
0.666181
yywang0514/dsnre
refs/heads/master
import torch import torch.nn as nn from lib import * class Model(nn.Module): def __init__(self, fine_tune, pre_train_emb, part_point, size_vocab, dim_emb, ...
Python
99
29.747475
192
/model.py
0.567861
0.561288
yywang0514/dsnre
refs/heads/master
from module import * from util import * from data_iterator import *
Python
3
21.666666
27
/lib/__init__.py
0.764706
0.764706
yywang0514/dsnre
refs/heads/master
import sys import codecs class InstanceBag(object): def __init__(self, entities, rel, num, sentences, positions, entitiesPos): self.entities = entities self.rel = rel self.num = num self.sentences = sentences self.positions = positions self.entitiesPos = entitiesPos def bags_decompose(data_bags): bag...
Python
87
27
83
/format.py
0.645996
0.635729
yywang0514/dsnre
refs/heads/master
import sys import re import numpy as np import cPickle as pkl import codecs import logging from data_iterator import * logger = logging.getLogger() extra_token = ["<PAD>", "<UNK>"] def display(msg): print(msg) logger.info(msg) def datafold(filename): f = open(filename, 'r') data = [] while 1: line = f.readl...
Python
169
20.177515
115
/lib/util.py
0.622974
0.604807
yywang0514/dsnre
refs/heads/master
import time import cPickle import numpy as np import torch class InstanceBag(object): def __init__(self, entities, rel, num, sentences, positions, entitiesPos): self.entities = entities self.rel = rel self.num = num self.sentences = sentences self.positions = positions self.entitiesPos = entitiesPos def ...
Python
64
32.4375
116
/lib/data_iterator.py
0.612617
0.607477
porterjamesj/bcbio-nextgen
refs/heads/master
"""Calculate potential effects of variations using external programs. Supported: snpEff: http://sourceforge.net/projects/snpeff/ """ import os import csv import glob from bcbio import utils from bcbio.distributed.transaction import file_transaction from bcbio.pipeline import config_utils, tools from bcbio.provenanc...
Python
140
43.628571
96
/bcbio/variation/effects.py
0.617958
0.615557
porterjamesj/bcbio-nextgen
refs/heads/master
"""Run distributed functions provided a name and json/YAML file with arguments. Enables command line access and alternative interfaces to run specific functionality within bcbio-nextgen. """ import yaml from bcbio.distributed import multitasks def process(args): """Run the function in args.name given arguments i...
Python
25
39
116
/bcbio/distributed/runfn.py
0.691
0.691
porterjamesj/bcbio-nextgen
refs/heads/master
"""Run distributed tasks in parallel using IPython or joblib on multiple cores. """ import functools try: import joblib except ImportError: joblib = False from bcbio.distributed import ipython from bcbio.log import logger, setup_local_logging from bcbio.provenance import diagnostics, system def parallel_runn...
Python
80
37.762501
90
/bcbio/distributed/messaging.py
0.598194
0.597227
porterjamesj/bcbio-nextgen
refs/heads/master
from os import path from bcbio.pipeline import config_utils from bcbio.utils import safe_makedir, file_exists, get_in from bcbio.provenance import do CLEANUP_FILES = ["Aligned.out.sam", "Log.out", "Log.progress.out"] def align(fastq_file, pair_file, ref_file, names, align_dir, data): config = data["config"] ...
Python
54
37.888889
78
/bcbio/ngsalign/star.py
0.651905
0.647143
MagnusPoppe/hidden-markov-models
refs/heads/master
import random import sys actions = ["LEFT", "RIGHT", "UP", "DOWN"] def perform_action(x, y, action): if action == "LEFT" and x != 0: return x-1, y if action == "RIGHT" and x != 3: return x+1, y if action == "UP" and y != 0: return x, y-1 if action == "DOWN" and y != 2: return x, y+1 return x, ...
Python
69
31.536232
114
/policy_iteration.py
0.55615
0.529412
MagnusPoppe/hidden-markov-models
refs/heads/master
import pandas as pd from math import log2 _TRAINING_FILE = "/Users/magnus/Downloads/data/training.csv" _TESTING_FILE = "/Users/magnus/Downloads/data/test.csv" def entropy(V): """ ENTROPY SHOWS HOW MUCH OF THE TOTAL DECSISION SPACE AN ATTRIBUTE TAKES UP """ return - sum(vk * log2(vk) for vk in V if vk > 0) de...
Python
68
38.75
98
/boolean_decision_tree.py
0.61695
0.607698
MagnusPoppe/hidden-markov-models
refs/heads/master
# %% import numpy as np # Transition model for state_t (Answer to to PART A, 1) Xt = np.array([[0.7, 0.3], [0.3, 0.7]]) # Sensor model for state_t (Answer to PART A, 2) O1 = np.array([[0.9, .0], [.0, 0.2]]) O3 = np.array([[0.1, .0], [.0, 0.8]]) init = np.array([0.5, 0.5]) def forward(f, Xt, OT, OF, E, k): t =...
Python
40
28
94
/hmm.py
0.554217
0.512909
MagnusPoppe/hidden-markov-models
refs/heads/master
import copy # Setup: s = "s" states = ["s", "!s"] actions = ["N", "M"] Xt = {"A1": 1.0, "A2": 1.0} R = {"s": 2.0, "!s": 3.0} y = 0.5 def E(c, R): E = c * max(R.values()) return E def max_key(dictionary): return list(Xt.keys())[list(Xt.values()).index(max(Xt.values()))] def value_iteration(states, Xt, y)...
Python
45
22.911112
96
/value_iteration_world.py
0.496283
0.472119
SGuo1995/Mushroom-poisonous-prediction
refs/heads/master
#!/usr/bin/env python # coding: utf-8 # In[433]: import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import preprocessing from sklearn.preprocessing import LabelEncoder import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.preprocessing import Standar...
Python
907
27.802647
308
/Final Project_guo_1449.py
0.667215
0.646739
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0.1 on 2018-03-05 22:15 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('map', '0008_auto_20180305_2211'), ] operations = [ migrations.CreateModel( name='Vote', ...
Python
27
27.925926
114
/spots-api/map/migrations/0009_auto_20180305_2215.py
0.564661
0.524968
greenmato/slackline-spots
refs/heads/master
from django.urls import path from django.conf import settings from django.conf.urls.static import static from map.views import MapView from map.api import SpotsApi, SpotApi, RatingsApi, VotesApi app_name = 'map' urlpatterns = [ path('', MapView.as_view(), name='index'), path('spots/', ...
Python
19
34.052631
80
/spots-api/map/urls.py
0.636637
0.636637
greenmato/slackline-spots
refs/heads/master
from django import forms from django.forms import ModelForm, Textarea from map.models import Spot, Rating, Vote class SpotForm(ModelForm): class Meta: model = Spot fields = ['name', 'description', 'latitude', 'longitude'] widgets = { 'latitude': forms.HiddenInput(), ...
Python
30
24.766666
65
/spots-api/map/forms.py
0.560155
0.560155
greenmato/slackline-spots
refs/heads/master
from django.db import models from django.core.validators import MaxValueValidator, MinValueValidator class Spot(models.Model): name = models.CharField(max_length=50) description = models.CharField(max_length=500) latitude = models.DecimalField(max_digits=10, decimal_places=7) longitude = models.Decim...
Python
64
28.453125
75
/spots-api/map/models.py
0.64191
0.6313
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0.1 on 2018-03-05 21:31 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('map', '0004_ratingtype'), ] operations = [ migrations.AlterField( model_name='spot', name='latitude', fi...
Python
23
23.782608
71
/spots-api/map/migrations/0005_auto_20180305_2131.py
0.573684
0.529825
greenmato/slackline-spots
refs/heads/master
from django.shortcuts import render from django.views import View class MapView(View): def get(self, request): return render(request, 'map/index.html')
Python
6
26.5
48
/spots-api/map/views.py
0.727273
0.727273
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0.1 on 2018-03-05 21:39 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('map', '0006_rating'), ] operations = [ migrations.RenameField( model_name='rating', old_name='rating_type_id', n...
Python
23
20.608696
47
/spots-api/map/migrations/0007_auto_20180305_2139.py
0.527163
0.488934
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0.1 on 2018-03-05 22:11 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('map', '0007_auto_20180305_2139'), ] operations = [ migrations.RenameField( model_name='rating', old_name='rating_typ...
Python
23
21.652174
49
/spots-api/map/migrations/0008_auto_20180305_2211.py
0.547025
0.485605
greenmato/slackline-spots
refs/heads/master
from abc import ABC, ABCMeta, abstractmethod from django.forms.models import model_to_dict from django.http import HttpResponse, JsonResponse from django.shortcuts import get_object_or_404 from django.views import View from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decor...
Python
95
29.56842
91
/spots-api/map/api.py
0.642906
0.634642
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0 on 2017-12-17 18:04 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Spot', fields=[ ('id', models.AutoField(auto_...
Python
24
28.791666
114
/spots-api/map/migrations/0001_initial.py
0.573427
0.541259
greenmato/slackline-spots
refs/heads/master
# Generated by Django 2.0.1 on 2018-03-06 21:19 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('map', '0009_auto_20180305_2215'), ] operations = [ migrations.RenameField( model_name='rating', old_name='rating', ...
Python
18
19.222221
47
/spots-api/map/migrations/0010_auto_20180306_2119.py
0.565934
0.480769
Turing-IA-IHC/Heart-Attack-Detection-In-Images
refs/heads/master
""" Heart attack detection in colour images using convolutional neural networks This code make a neural network to detect infarcts Written by Gabriel Rojas - 2019 Copyright (c) 2019 G0 S.A.S. Licensed under the MIT License (see LICENSE for details) """ from os import scandir import num...
Python
88
31.875
105
/test.py
0.59678
0.583361
Turing-IA-IHC/Heart-Attack-Detection-In-Images
refs/heads/master
""" Heart attack detection in colour images using convolutional neural networks This code make a neural network to detect infarcts Written by Gabriel Rojas - 2019 Copyright (c) 2019 G0 S.A.S. Licensed under the MIT License (see LICENSE for details) """ import os import sys from time imp...
Python
115
30.18261
109
/train.py
0.658471
0.624156
horsinLin/Ajax-Project
refs/heads/master
from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy import pymysql pymysql.install_as_MySQLdb() app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI']="mysql://root:horsin@123@localhost:3306/flask" app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = SQLAlchemy(app) cla...
Python
42
26
84
/day02/练习/02-run.py
0.663725
0.651368
horsinLin/Ajax-Project
refs/heads/master
from flask import Flask, render_template, request app = Flask(__name__) @app.route('/01-getxhr') def getxhr(): return render_template('01-getxhr.html') @app.route('/02-get') def get_views(): return render_template('02-get.html') @app.route('/03-get') def get03_view(): return render_template('03-get.html...
Python
40
20.125
49
/day02/练习/01-run.py
0.648104
0.60545
horsinLin/Ajax-Project
refs/heads/master
from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy import json import pymysql pymysql.install_as_MySQLdb() app = Flask(__name__) app.config["SQLALCHEMY_DATABASE_URI"]="mysql://root:horsin@123@localhost:3306/flask" app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db...
Python
78
24.858974
89
/day03/练习/02-run.py
0.58568
0.579475
horsinLin/Ajax-Project
refs/heads/master
from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy import json import pymysql pymysql.install_as_MySQLdb() app = Flask(__name__) app.config["SQLALCHEMY_DATABASE_URI"]="mysql://root:horsin@123@localhost:3306/flask" app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = SQLAlc...
Python
100
22.32
84
/day03/练习/01-run.py
0.53786
0.526749
horsinLin/Ajax-Project
refs/heads/master
from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy import json import pymysql pymysql.install_as_MySQLdb() app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI']="mysql://root:horsin@123@localhost:3306/flask" app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN']=True db = SQLAlchemy...
Python
121
24.504131
89
/day04/练习/01-run.py
0.596894
0.584924
serhatkg021/parthenia
refs/heads/master
import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BCM) GPIO.setup("1",GPIO.IN) GPIO.setup("2",GPIO.IN) input = GPIO.input("1") input = GPIO.input("2") while True: inputValue = GPIO.input("1") if (inputValue == False): print("1. Görev") os.system('..\\daire\\main...
Python
22
24.818182
65
/Proje/Tuş/main2.py
0.550265
0.534392
serhatkg021/parthenia
refs/heads/master
import keyboard import os while True: if keyboard.is_pressed("1"): print("1. Görev") os.system('..\\daire\\main.py') if keyboard.is_pressed("2"): os.system('..\\dikdörtgen\\main.py') if keyboard.is_pressed("3"): print("3. Görev")
Python
11
24
44
/Proje/Tuş/main.py
0.569343
0.551095
serhatkg021/parthenia
refs/heads/master
import cv2 from daire import circleScan import keyboard import os cameraX = 800 cameraY = 600 cap = cv2.VideoCapture(0) # Cemberin merkezinin ekranın orta noktaya uzaklıgını x ve y cinsinden uzaklıgı while True: if keyboard.is_pressed("2"): print("2. Görev") cap.release() cv2.destroyAllWi...
Python
35
23.685715
80
/Proje/Daire/main.py
0.61066
0.584009
serhatkg021/parthenia
refs/heads/master
import cv2 import numpy as np # minDist = 120 # param1 = 50 # param2 = 30 # minRadius = 5 # maxRadius = 0 def circleScan(frame, camX, camY): gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(gray,(11,11),0) circles = cv2.HoughCircles(blurred, cv2.HOUGH_GRADIENT, 1,120, param1=220,...
Python
28
32.642857
142
/Proje/Daire/daire.py
0.585987
0.504246
serhatkg021/parthenia
refs/heads/master
import cv2 # import numpy as np import keyboard import os cameraX = 800 cameraY = 600 cap = cv2.VideoCapture(0) while(True): if keyboard.is_pressed("1"): print("1. Görev Dikdortgende") cap.release() cv2.destroyAllWindows() os.system('..\\daire\\main.py') # Daha verimli bre...
Python
70
25.942858
78
/Proje/Dikdörtgen/main.py
0.508223
0.448276
LeonardoZanotti/opencv-logic-operations
refs/heads/main
import cv2 as cv import numpy as np import sys from matplotlib import pyplot as plt def main(): square = cv.imread('./img/square.png') ball = cv.imread('./img/ball.png') mask = cv.imread('./img/mask2.png') square_gray = cv.cvtColor(square, cv.COLOR_BGR2GRAY) ball_gray = cv.cvtColor(ball, cv.COLOR_...
Python
122
28.745901
173
/logic-arithmetic.py
0.537063
0.505098
johinsDev/codewars
refs/heads/master
""" Going to zero or to infinity? http://www.codewars.com/kata/55a29405bc7d2efaff00007c/train/python """ import math def going(n): result = 0 for i in range(n): result = 1.0*result/(i+1) + 1 return math.floor(result * (10**6))/(10**6) if __name__ == "__main__": for i in range(10): print i, going(i)
Python
18
16.5
66
/going_to_zero_or_inf.py
0.627389
0.541401
johinsDev/codewars
refs/heads/master
''' A poor miner is trapped in a mine and you have to help him to get out ! Only, the mine is all dark so you have to tell him where to go. In this kata, you will have to implement a method solve(map, miner, exit) that has to return the path the miner must take to reach the exit as an array of moves, such as : ['up',...
Python
41
41.634148
464
/escape_the_mines.py
0.691076
0.671053
johinsDev/codewars
refs/heads/master
""" You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits: http://www.codewars.com/kata/55983863da40caa2c900004e/train/python """ def next_bigger(n): #your code here
Python
10
23.799999
128
/next_bigger.py
0.746032
0.678571
johinsDev/codewars
refs/heads/master
""" Sudoku Solution Validator http://www.codewars.com/kata/529bf0e9bdf7657179000008/train/python """ def validSolution(board): test = range(1,10,1) def tester(alist): return set(test)==set(alist) for i in range(len(board)): tem = board[i] if not tester(tem): return False for i in range(len(board[0]...
Python
53
25.283018
77
/sudoku_solution_val.py
0.41954
0.280891
johinsDev/codewars
refs/heads/master
""" Decimal to any Rational or Irrational Base Converter http://www.codewars.com/kata/5509609d1dbf20a324000714/train/python wiki_page : https://en.wikipedia.org/wiki/Non-integer_representation """ import math from math import pi , log ''' def converter(n, decimals=0, base=pi): """takes n in base 10 and return...
Python
71
23.478872
69
/decimalToRational.py
0.541021
0.49455
johinsDev/codewars
refs/heads/master
''' http://www.codewars.com/kata/53d3173cf4eb7605c10001a8/train/python Write a function that returns all of the sublists of a list or Array. Your function should be pure; it cannot modify its input. Example: power([1,2,3]) # => [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]] ''' def power(s): """Computes...
Python
40
21.625
69
/powerSet.py
0.539648
0.488987
johinsDev/codewars
refs/heads/master
def solution(n): # TODO convert int to roman string result = "" remainder = n if n == 0: return "" for i in range(0,len(roman_number)): time = 1.0*remainder/roman_number[i][0] if str(roman_number[i][0])[0] == '1': if time < 4 and time >=1: temp = remainder % roman_number[i][0] div = remainder / ...
Python
37
31.270269
94
/roman_number.py
0.581727
0.523051
johinsDev/codewars
refs/heads/master
#!/usr/bin/python ''' An Arithmetic Progression is defined as one in which there is a constant difference between the consecutive terms of a given series of numbers. You are provided with consecutive elements of an Arithmetic Progression. There is however one hitch: Exactly one term from the original series is missing ...
Python
23
37.869564
435
/find_missing.py
0.731243
0.697648
johinsDev/codewars
refs/heads/master
""" Square into Squares. Protect trees! http://www.codewars.com/kata/square-into-squares-protect-trees """ import math def decompose(n): # your code def sub_decompose(s,i): if s < 0 : return None if s == 0: return [] for j in xrange(i-1, 0 ,-1): #print s,s - j**2 ,j su...
Python
24
20.708334
63
/square_into_squares.py
0.541267
0.522073
johinsDev/codewars
refs/heads/master
#!/usr/bin/python from collections import defaultdict def sum_for_list(lst): aDict = defaultdict(lambda : 0) def primes(n): d = 2 aN = n n = abs(n) while d*d <= n: aBool = True while (n % d) == 0: #primfac.add(d) # supposing you want multiple factors repeated if aBool: aDict[d] ...
Python
47
14.957447
68
/sum_for_list.py
0.573901
0.537949
johinsDev/codewars
refs/heads/master
""" Create the function prefill that returns an array of n elements that all have the same value v. See if you can do this without using a loop. You have to validate input: v can be anything (primitive or otherwise) if v is ommited, fill the array with undefined if n is 0, return an empty array if n is anything other...
Python
43
24.39535
140
/prefillAnArray.py
0.696249
0.666057
johinsDev/codewars
refs/heads/master
""" Vigenere Autokey Cipher Helper http://www.codewars.com/kata/vigenere-autokey-cipher-helper """ class VigenereAutokeyCipher: def __init__(self, key, alphabet): self.key = key self.alphabet = alphabet def code(self, text, direction): toText = list(text) result = [] newKey = filter(lambda x: (x in s...
Python
57
26.263159
134
/vigenereAutokeyCipher.py
0.692209
0.688989
johinsDev/codewars
refs/heads/master
''' Where my anagrams at? http://www.codewars.com/kata/523a86aa4230ebb5420001e1/train/python Also could construct prime list, assign each character from word to a prime number. multiply them then divid prime number from word in words. ''' def anagrams(word, words): #your code here return filter(lambd...
Python
17
31.411764
99
/where_my_anagrams.py
0.687273
0.656364
johinsDev/codewars
refs/heads/master
def sierpinski(n): result = [] for i in range(0,n+1): if i == 0: result.append('"') else: for j in range(2**(i-1),2**i): result.append(addSpace(j,i,result)) r = result[0] for line in result[1:]: r= r+'\n'+line return r def addSpace(l,n,s...
Python
24
22.416666
49
/Sierpinski's Gasketr.py
0.511586
0.474153
johinsDev/codewars
refs/heads/master
""" Validate Sudoku with size `NxN` http://www.codewars.com/kata/540afbe2dc9f615d5e000425/train/python """
Python
4
26.25
67
/validate_sudoku.py
0.745455
0.609091
johinsDev/codewars
refs/heads/master
""" The Millionth Fibonacci Kata http://www.codewars.com/kata/53d40c1e2f13e331fc000c26/train/python """ import math import sys import time from collections import defaultdict # following not working , took too much time to compute. def fib(n , i): dic = defaultdict(list) def find_dim(k): if k == 0: return...
Python
134
15.798508
72
/millionthFib.py
0.525732
0.482254
bhaktijkoli/python-training
refs/heads/master
# Generate a random number between 1 and 9 (including 1 and 9). # Ask the user to guess the number, then tell them whether they # guessed too low, too high, or exactly right. import random as r a = r.randint(1, 9) def ask_user(): u = int(input("Guess the number?\n")) if a == u: print("Exac...
Python
20
21.1
63
/example25.py
0.562771
0.549784
bhaktijkoli/python-training
refs/heads/master
# Consider that vowels in the alphabet are a, e, i, o, u and y. # Function score_words takes a list of lowercase words as an # argument and returns a score as follows: # The score of a single word is 2 if the word contains an even number # of vowels. Otherwise, the score of this word is 1 . The score for the # who...
Python
35
26.142857
71
/example26.py
0.623601
0.612411
bhaktijkoli/python-training
refs/heads/master
p = 3 n = 1 for i in range(4): for j in range(7): if j >= p and j <= p+n-1: print("X", end=" ") else: print(" ", end=" ") print() p -= 1 n += 2 print("The python string multiplication way") p = 3 n = 1 for i in range(4): print(" " * p, end=...
Python
22
15.772727
45
/example10.py
0.385604
0.354756
bhaktijkoli/python-training
refs/heads/master
import datetime as dt today = dt.datetime.today() for i in range(1, 6): nextday = today + dt.timedelta(days=i) print(nextday)
Python
5
25.799999
42
/example18.py
0.664234
0.649635
bhaktijkoli/python-training
refs/heads/master
# Given the participants' score sheet for your University Sports Day, # you are required to find the runner-up score. You are given n scores. # Store them in a list and find the score of the runner-up. score_str = input("Enter scores\n") score_list = score_str.split(" ") highestScore = 0; rupnnerUp = 0 for sco...
Python
19
28.210526
71
/example23.py
0.678322
0.674825
bhaktijkoli/python-training
refs/heads/master
# To find a factorial of a number # 5! = 5 * 4 * 3 * 2 * 1 # fact(5) = 5 * fact(4) # fact(4) = 4 * fact(3) # fact(3) = 3 * fact(2) # fact(2) = 2 * fact(1) # fact(1) = 1 # fact(5) = 5 * 4 * 3 * 2 * 1 def fact(n): if n == 1: return 1 return n * fact(n-1) n = 5 result = fact(n) print(...
Python
19
15.315789
33
/example13.py
0.449541
0.357798
bhaktijkoli/python-training
refs/heads/master
# GUI Programing # Tkinter import tkinter as tk from tkinter import messagebox ## Welcome Window def show_welcome(): welcome = tk.Tk() welcome.title("Welcome ADMIN") welcome.geometry("200x200") welcome.mainloop() ## Login Window # 1. Intialize Root Window root = tk.Tk() root.title("...
Python
54
24.851852
75
/example21.py
0.664365
0.629834
bhaktijkoli/python-training
refs/heads/master
import datetime as dt today = dt.datetime.today() yesterday = today - dt.timedelta(days=1) tomorrow = today + dt.timedelta(days=1) print("Yesterday", yesterday) print("Today", today) print("Tomorrow", tomorrow)
Python
8
25.5
40
/example17.py
0.715596
0.706422
bhaktijkoli/python-training
refs/heads/master
# Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player # plays (using input), compare them, print out a message of # congratulations to the winner, and ask if the players want to start a # new game) def is_play_valid(play): if play != 'rock' and play != 'paper' and play != 'scissors': r...
Python
45
26.822222
71
/example24.py
0.52973
0.513514
bhaktijkoli/python-training
refs/heads/master
l = [1, 5, 12, 2, 15, 6] i = 0 s = 0 for i in l: s += i print(s) i = 0 s = 0 while i<len(l): s += l[i] i += 1 print(s)
Python
13
9.153846
24
/example2.py
0.370629
0.27972
bhaktijkoli/python-training
refs/heads/master
def add(a, b): return a + b def sub(a, b): return a - b def pow(a,b): return a ** b if __name__ != "__main__": print("Basic Module Imported")
Python
11
13.636364
34
/basic.py
0.482353
0.482353
bhaktijkoli/python-training
refs/heads/master
x = int(input("Enter a number\n")) for i in range(x): print(i ** 2)
Python
3
23
34
/example5.py
0.546667
0.533333
bhaktijkoli/python-training
refs/heads/master
x = 65 for i in range(5): for j in range(i+1): print(chr(x+j), end=" ") print()
Python
6
15.166667
32
/example9.py
0.455446
0.415842
bhaktijkoli/python-training
refs/heads/master
import datetime as dt today = dt.datetime.today() print("Current date and time", dt.datetime.now()) print("Current Time in 12 Hours Format", today.strftime("%I:%M:%S %p")) print("Current year", today.year) print("Month of the year", today.strftime("%B")) print("Week number of the year", today.strftime("%W")) pri...
Python
11
44.81818
71
/example15.py
0.676413
0.672515
bhaktijkoli/python-training
refs/heads/master
x = int(input("Enter the value of X\n")) if x%2 != 0: print("Weird") elif x >= 2 and x <= 5: print("Not Weird") elif x >= 6 and x<= 20: print("Weird") elif x > 20: print("Not Weird")
Python
9
21.111111
40
/example1.py
0.519417
0.475728
bhaktijkoli/python-training
refs/heads/master
samples = (1, 2, 3, 4, 12, 5, 20, 11, 21) e = o = 0 for s in samples: if s % 2 == 0: e += 1 else: o += 1 print("Number of even numbers : %d" % (e)) print("Number of odd numbers : %d" % (o))
Python
10
20.5
42
/example6.py
0.44843
0.367713
bhaktijkoli/python-training
refs/heads/master
# Password generator import random as r lenth = int(input("Enter the length of password\n")) password = "" for i in range(lenth): password += chr(r.randint(33, 123)) print(password)
Python
8
22.375
52
/example27.py
0.678756
0.65285
bhaktijkoli/python-training
refs/heads/master
#Write a python program to find the longest word in a file. f = open("demo.txt", "r") line = f.readline() longestWord = "" while line: words = line.split(" ") lineLongestWord = max(words, key=len) if len(lineLongestWord) > len(longestWord): longestWord = lineLongestWord line = f.readl...
Python
14
24.571428
59
/example19.py
0.648649
0.648649
bhaktijkoli/python-training
refs/heads/master
# 0 1 1 2 3 5 8 def fib(n): a = 0 b = 1 print(a, end=" ") print(b, end=" ") for i in range(2, n): c = a + b print(c, end=" ") a = b b = c n = int(input("Enter the number\n")) fib(n)
Python
14
15.785714
36
/example12.py
0.376518
0.336032
bhaktijkoli/python-training
refs/heads/master
# GUI Calculator Program import tkinter as tk # Intialize window window = tk.Tk() window.title("Calculator") # Application Logic result = tk.StringVar() def add(value): result.set(result.get() + value) def peform(): result.set(eval(result.get())) def clear(): result.set("") # Initialize W...
Python
63
42.111111
112
/example22.py
0.657904
0.60533
bhaktijkoli/python-training
refs/heads/master
#Write a python program to count the numbers of alphabets, digits and spaces in a file. f = open("demo.txt", "r") alphabets = 0 digits = 0 spaces = 0 others = 0 lines = f.readlines() for line in lines: for c in line: if c.isalpha(): alphabets += 1 elif c.isdigit(): ...
Python
24
21.708334
87
/example20.py
0.56261
0.548501
bhaktijkoli/python-training
refs/heads/master
for i in range(5): for j in range(i+1): print(i+1, end=" ") print() print("The python way...") for i in range(5): print(str(str(i+1) + " ") * int(i+1))
Python
9
18.333334
41
/example8.py
0.480663
0.447514
bhaktijkoli/python-training
refs/heads/master
for i in range(5): for j in range(5-i): print("X", end=" ") print() for i in range(5): print("X " * int(5-i))
Python
8
15.5
27
/example7.py
0.449275
0.42029
bhaktijkoli/python-training
refs/heads/master
# GUI Programing # Tkinter import tkinter as tk from tkinter import messagebox # 1. Intialize Root Window root = tk.Tk() root.title("Login Application") root.geometry("200x200") # 2. Application Logic # 3. Intialize widgets # 4. Placement of widgets (pack, grid, place) # 5. Running the main loo...
Python
20
15.1
45
/demo.py
0.691176
0.658824
bhaktijkoli/python-training
refs/heads/master
class Student: def __init__(self, name, roll_no): self.name = name self.roll_no = roll_no self.age = 0 self.marks = 0 def display(self): print("Name", self.name) print("Roll No", self.roll_no) print("Age", self.age) print("Marks", self....
Python
26
19.615385
38
/example14.py
0.530357
0.501786
bhaktijkoli/python-training
refs/heads/master
x = input("Enter a string \n") d = l = 0 for c in x: if c.isalpha(): l += 1 if c.isdigit(): d += 1; print("Letters %d" % (l)) print("Digits %d" % (d))
Python
12
13.833333
30
/example4.py
0.425532
0.409574
bhaktijkoli/python-training
refs/heads/master
def is_leap(y): return y % 4 == 0 y = int(input("Enter a year\n")) if is_leap(y): print("Leap year") else: print("Not a Leap Year")
Python
8
17.125
32
/example16.py
0.543046
0.529801
bhaktijkoli/python-training
refs/heads/master
def checkPrime(x): for i in range(2, x): if x % i == 0: print("Not a prime number") break; else: print("Print number") x = int(input("Enter any number\n")) checkPrime(x)
Python
10
20.9
39
/example11.py
0.493392
0.484582
bhaktijkoli/python-training
refs/heads/master
w = input("Enter a word") r = ""; for a in w: r = a + r print(r)
Python
6
10.666667
25
/example3.py
0.445946
0.445946
pedromeldola/Desafio
refs/heads/master
from django.db import models #criação da classe com os atributos class Jogo(models.Model): idJogo = models.AutoField(primary_key=True) placar = models.IntegerField() placarMin = models.IntegerField() placarMax = models.IntegerField() quebraRecMin = models.IntegerField() quebraRecMax = models.In...
Python
13
28.923077
47
/core/models.py
0.705128
0.705128
pedromeldola/Desafio
refs/heads/master
from django.shortcuts import render,redirect from .models import Jogo from django.views.decorators.csrf import csrf_protect #método para chamar todos os objetos que estão na classe Jogo quando entrar na home page def home_page(request): jogo = Jogo.objects.all() return render (request,'home.html',{'jogo':jogo}...
Python
44
37.886364
137
/core/views.py
0.696669
0.694331
pedromeldola/Desafio
refs/heads/master
# Generated by Django 3.1 on 2020-10-01 01:54 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('core', '0001_initial'), ] operations = [ migrations.RemoveField( model_name='jogo', name='id', ), migr...
Python
27
22.185184
70
/core/migrations/0002_auto_20200930_2254.py
0.533546
0.504792
pedromeldola/Desafio
refs/heads/master
# Generated by Django 3.1.1 on 2020-09-28 18:50 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Jogo', fields=[ ('id', models.AutoField(aut...
Python
26
28.23077
114
/core/migrations/0001_initial.py
0.544737
0.523684
memogarcia/pratai-runtimes
refs/heads/master
import os import sys import logging from time import time class AppFilter(logging.Filter): def filter(self, record): record.function_id = os.environ.get("function_id", 'no_function_id') record.request_id = os.environ.get("request_id", 'no_request_id') return True logger = logging.getLogg...
Python
65
22.415384
109
/runtimes/python27/server.py
0.662073
0.659449