blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
6b7ae6f708712d63cfcca346db87c0ee8301e500 | rmcarthur/acme_labs | /Lab5v1.py | 4,343 | 3.78125 | 4 | import numpy as np
from scipy import linalg as la
from matplotlib import pyplot as plt
def Plot(old, new):
"""
Takes in two data sets, and plots them in the same window. Currently, it is
auto-adjusting the axes, which produces funky results in a lab that is
focused on showing changes in the data se... |
be7a201d4fabf44cbf20058d08e438be51239740 | rmcarthur/acme_labs | /Lab1v2.py | 4,548 | 3.53125 | 4 | import sys
import csv
import math
import cmath
import random
from collections import namedtuple
from collections import deque
import itertools
import timeit
import numpy as np
###### Problem 2 #####
# Prints out an argument from the sys.argv
# a = sys.argv
# print a[1]
###### Problem 3 ######
# open test.csv as re... |
6717f235d36d6564d10d6f85981ad7af7ac249b8 | pmcote/SigSys-Sound-Sheet | /note_filter_test.py | 1,559 | 3.703125 | 4 | ## Found code from: http://stackoverflow.com/questions/18625085/how-to-plot-a-wav-file
import matplotlib.pyplot as plt
import numpy as np
import wave
import sys
def filterNote(noteFreq, omega, transform):
filterRange = 10
minFreq = noteFreq - filterRange
maxFreq = noteFreq + filterRange
filteredSignal = []
for in... |
54c9d5401e05c5e41821a118ef55c9c856515a1d | Moeen-Farshbaf/assignment1-_- | /calc.py | 1,251 | 4.0625 | 4 | from math import factorial
while True:
import math
actions = ['sin','cos','sqroot','cot','tan','factorial','sum','sub','divide','multiply','expo']
ind = 1
for action in actions:
print(ind, '. ',action)
ind = ind + 1
op=int(input("Please enter the number of ac... |
172bca8ed49127e5baa1a23dd7795a19c3c7d984 | willl4/mathproject | /functionAnalysisProgram.py | 2,532 | 4.15625 | 4 | """
function = input('Enter a function: ')
func = function.split('x^')
for temp in func:
print(temp)
"""
if __name__ == '__main__':
data = {}
data['coefficients'] = ''
data['derivative'] = ''
function = int(input('Choose highest power in function: '))
power = function
while function >= 0:
co... |
e3ad47b7e7c1c22f92d0c83bff321d74a7434777 | jonathanr510/cssi-labs | /python/labs/functions-cardio/myfunctions.py | 477 | 3.703125 | 4 | print("Welcome to the calculator")
def count_spaces(s):
return s.count(" ")
def count_vowels(s):
numA = s.count("a")
numE = s.count("e")
numI = s.count("i")
numO = s.count("o")
numU = s.count("u")
numY = s.count("y")
sumVowels = numA + numE + numO + numI... |
aa6e05583edbf32e90b8be378890be407d8f567e | VandyAstroML/2018_08_02_Fall_Bridge_Computational_Bootcamp_repo | /data/day_04/scripts/histogram_pdf.py | 2,677 | 3.5 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# Victor Calderon
# Created : 2018-08-06
# Last Modified: 2018-08-06
# Vanderbilt University
from __future__ import absolute_import, division, print_function
__author__ = ['Victor Calderon']
__copyright__ = ["Copyright 2018 Victor Calderon, Fitting a line"]
__e... |
6d9a1b724a16d0f70235ec4c617cb1d08aec5956 | mcapoor/Astronautical-Engineering | /Orbital Mechanics/Hohmann Transfer/in_plane.py | 946 | 3.734375 | 4 | import functions
import math as m
def in_plane():
planet = input("Which body are we starting from? ")
if (planet == 'e'):
planet = 'earth'
mu = functions.get_mu(planet)
radii1 = functions.get_altitude1(planet)
altitude1 = radii1[0]
r1 = radii1[1]
radii2 = functions.get_altitude2(... |
61670071dbafae76a0862379f7866dac9a711fbe | LaurenH123/PG_LH | /Mad Lib 2.py | 733 | 4.09375 | 4 | import time
print ("Write a person!")
person1 = input ()
print ("Write a person!")
person1 = input ()
"Do you want to make " + person1 "'s " + " famous " + food1 + "recipe?"
"It is absolutly " + adjective1 "."
"First you have to preheat the " + noun "to " + amount of degrees in F + "."
"Once you do that y... |
ac7f46d4152e7ce20d5a85fae32db1443c8a7240 | haripriya1905/python | /Nterm.py | 158 | 3.65625 | 4 | def Nth_of_AP(a, d, N) :
return (a + (N - 1) * d)
a = 2
d = 1
N = 5
print( "The ", N ,"th term of the series is : ",
Nth_of_AP(a, d, N))
|
d7b9dd5015ba394f9e6077b20fa1e5e7447de60b | rsp-esl/microbit_micropython_examples | /microbit_bin_str_display.py | 1,373 | 3.546875 | 4 | from microbit import *
def bin_str(n):
fp = "{0:0" + str(n) + "b}"
return [fp.format(i) for i in range(2**n) ]
state = 0
index = 0
nlist = [2,3,4] # a list of selectable values of n
i = 0
n = nlist[i]
while True:
display.show( str(n) )
if state == 0: # idle/input state
if button_a.was_pr... |
29a0a463a4c399a0477ceaeedb17fe5c60531549 | KKKirino/Coding-Every-Day | /2020/ai-course-exercise/ex2-astar-eight-figure-puzzle.py | 4,809 | 3.609375 | 4 | from __future__ import annotations
from itertools import permutations
import math
from typing import Callable, Mapping, List, Tuple
from queue import PriorityQueue
class EFPuzzleState():
"""State definition for Eight Figure Puzzle."""
def __init__(self, state: str, g: int, h: int, parent: str) -> None:
"""Def... |
70d16245dc0076d08423ac074eac60466c56a0f2 | Hanqing1996/blog | /python学习/test.py | 346 | 3.515625 | 4 | list=[20,20,30,40,40]
# s=set(list)
#
# List2=[]
# for item in s:
# List2.append(item)
# List2.sort()
#
# List2.reverse()
# dic={}
# dic[9]=1
#
# print(dic[9])
#
list.remove(list[0])
# for item in list:
# dic[item]+=1
#
# print(dic)
list.remove(list[0])
list.remove(list[0])
# for item in list:
# prin... |
4c37fff168732af3e47240dd74218d3749413c70 | ravila4/EchoTags | /Tests/multi_open.py | 1,049 | 3.703125 | 4 | #!/usr/bin/python3
# project :EchoTags
# title :multi_open
# description :Learning to open and process multiple files
# author :ravila
# date :1/5/15
# version :
# usage :python3 multi_open.py *.mp3 mp3
# notes :
# python_version :3.4
# ============... |
a795c12fd10957505361d6d7aa4924794db1ffe6 | karthikdodo/python | /course/python/lab-1/second.py | 547 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 13 18:09:41 2019
@author: karthikchowdary
"""
def Con(tuple, dictonary):
for a, b in tuple:
dictonary.setdefault(a, []).append(b)
return dictonary
tuple1 = ('John', ('Physics', 80))
tuple2 = ('Daniel', ('Science', 90))
tuple3 = ('J... |
c2cc94920e3255c13dd13a3f05f880fa467011ab | MillerSilva/Numerical-Algorithms | /algebra_numerica/vv_propios/aceleracion_aitken.py | 1,565 | 3.59375 | 4 | """
Implementa la aceleracion de Aitken, utilizando iteradores
r: sucesion a aplicar la aceleracion de Aitken (r es un iterador)
s: sucesion obtenida de la aplicacion de la aceleracion de Aitken a r
NOTA:
El algoritmo se detiene cuando s se estanca (es decir para un n los valores de s(k) son casi iguales a s(n), ... |
b61d74c6efd2d81d9f039840182bd32abb0a41ce | kieronjmckenna/BIT-Year1 | /modules.py | 41,462 | 3.84375 | 4 | import csv
import matplotlib.pyplot as plt
# Anything that interacts with the CSV/Data Files is located in this file (modules.py)
# For reference during development to keep track of csv structures
# Customer_Fieldnames = ['Name', 'Number', 'Gender']
# Flower_Fieldnames = ['Flower', 'Price', 'Description']
# Transact... |
3d11b370e716a920ff3beee912fc366b29daa632 | rogalski/adventofcode-2018 | /day01.py | 562 | 3.671875 | 4 | import typing
import itertools
def final_freq(s: str) -> int:
return sum([int(digit) for digit in s.split()])
def first_reached_twice(s: str) -> int:
accum = 0
encountered = {0}
digits = itertools.cycle(map(int, s.split()))
for digit in digits:
accum += digit
if accum in encounte... |
186f341a446fa4ef55c7bed0aa4f8dad8c7579fb | davidtscott/CMEECoursework | /Week7/Code/regexs.py | 5,121 | 4.8125 | 5 | #!/usr/bin/env python3
# Date: Nov 2018
"""
Example uses of regex in python.
"""
__appname__ = '[examples of regex in python]'
__author__ = 'David Scott (david.scott18@imperial.ac.uk)'
__version__ = '0.0.1'
__license__ = "License for this code/program"
##packages
import re
# always include r infront of regex
... |
92fc4e3107ecedca5a04673bd9b62e2c03a336e7 | davidtscott/CMEECoursework | /Week2/Code/tuple.py | 1,329 | 4.53125 | 5 | #!/usr/bin/env python3
# Date: October 2018
"""
Extracts tuples from within a tuple and outputs as seperate lines
"""
__appname__ = '[tuple.py]'
__author__ = 'David Scott (david.scott18@imperial.ac.uk)'
__version__ = '0.0.1'
__license__ = "License for this code/program"
birds = ( ('Passerculus sandwichensis','Sav... |
92d945df3671e6dd1347567dbdd92c88f00313b3 | davidtscott/CMEECoursework | /Week7/Code/using_os.py | 1,859 | 3.734375 | 4 | #!/usr/bin/env python3
# Date: Nov 2018
"""
Use the subprocess.os module to get list of files and directories
in ubuntu home directory.
"""
__appname__ = '[using_os.py]'
__author__ = 'David Scott (david.scott18@imperial.ac.uk)'
__version__ = '0.0.1'
__license__ = "License for this code/program"
# Hint: look in s... |
a821936068a821e04302eb654088c3eebcbe9a41 | AntonPershin/SBERKURS | /db.py | 1,977 | 3.640625 | 4 | import pandas as pd
import sqlite3
import time
from datetime import date
#method insert data credit
def insert_data_credit(x):
# Insert data to credit table
cursor.execute("""
INSERT INTO credit (id, summ)
VALUES ({}, {})
""".format(x['Deal ID'],x... |
0895a66a4aedbff1ab670b2873ca66007f2ee195 | LouisLARDER/data-types | /main.py | 1,344 | 4.0625 | 4 | '''
text type(String)
'''
''''
s = 'this is a string'
print(s)
print(type(s))
'''
#==============================================
'''
numeric type(integer, float, complex)
'''
''''
x = 0.123456789084758
print(type(x))
print(x)
'''
'''
sequence type (list, tuple, range)
'''
'''
#list
x = [10, 2.5, 'hello']
print(x... |
9cfb00a6ab4fa7aaee53e2963ac523e157b3727d | aniketsutar174/Encrypt_Decrypt_program | /EncryptDecrypt.py | 396 | 3.5 | 4 | import random
from string import ascii_lowercase
msg = input('enter string:')
alph =''
for i in ascii_lowercase:
alph+=i
print(alph)
key = random.randint(1,10)
encrypt=''
decrypt=''
for i in msg:
pos = alph.find(i)
newpos=(pos+5)%26
encrypt+=alph[newpos]
print(encrypt)
for i in encrypt:
pos2 = alph... |
10389b374e4e03ecbf0ba9eea788dcd3bf8e3a04 | dhannyell/Metodos-Numericos | /metodo_secante.py | 1,163 | 3.921875 | 4 | def secante(f, x0, x1, epsilon, iterMax=50):
"""Executa o método da Secante para achar o zero de f
a partir das aproximações x0 e x1, e da tolerância
epsilon.
Retorna uma tupla (houveErro, raiz), onde houveErro é booleano.
"""
k = 0
## Teste se x0 e x1 já são raízes
if(abs(f(... |
6b710ad6dbb90960abb6a6864e459c648f3c1860 | Dezt/ArduinoImageConverter | /ConvertToBinary.py | 2,191 | 3.703125 | 4 | #converts a .png into a hardcoded array that the SSD1306 monochrome monitor can load and use
#this uses a Python image library called Pillow to work.
#if Pillow is not installed run the following in the Windows console:
# python3 -m pip install --upgrade pip
# python3 -m pip install --upgrade Pillow
#for m... |
60e7799e535db43b3b7919397f8cdc67c969542e | balasurya11/AlgorithmicToolbox-Coursera | /Week3/largest_number.py | 979 | 3.859375 | 4 | def isBetter(a, b):
#Function to check either the sequence 'ab' or 'ba' is better. If a is better, returns True else False
a, b = str(a), str(b)
n1 = int(a+b)
n2 = int(b+a)
if n2 > n1:
return True
return False
def largest_number(a):
#Empty list to store the answer... |
f62f7277f185380d9279b33e65a62e7437d5730a | balasurya11/AlgorithmicToolbox-Coursera | /Week3/differential_summands.py | 564 | 3.5 | 4 | #To find the maximum number of students who can be awarded with the given prize pool, so that no two children recieves the same prize
def optimal_summands(n):
if n==1:
return [1]
dist = []
for i in range(1, n):
#Stopping at n/2 because we get repeating numbers after that... |
b86c0881273ddd16a0fc7aafffcfe89b050c89eb | phoenixrosa/py_practice | /icakes/icake_q4.py | 4,157 | 4.09375 | 4 | """
Your company built an in-house calendar tool called HiCal. You want to add a feature to see the times in a day when
everyone is available.
To do this, you'll need to know when any team is having a meeting. In HiCal, a meeting is stored as a tuple of
integers (start_time, end_time). These integers represent the num... |
2896c121dcadb0c83deb906644c32d3dbc6ae1ea | charuj/leetcode | /1_twosum.py | 837 | 3.828125 | 4 | # Given an array of integers, return indices of the two numbers such that they add up to a specific target.
# there is exactly one solution
nums= [2, 11, 11,7, 15]
target= 9
class Sol2(object):
def twosum(self, nums, target):
'''
:param nums: list(int)
:param target: int
:return:... |
8d5a67b0cac1471fad48477358ba2da9f82746b6 | Arvind0202/BMI-Index | /BMICal5.py | 1,768 | 3.921875 | 4 | ''' BMI Calculator
Create a function to get the input
Create a function to calculate BMI
Create one more function for checking user category
Create a function to read the CSV file and return the matched player'''
#Gopalan college of engineering fdp
#attending fdp in qxf2
import csv
weight=height=1
def read_value():
... |
6848dc42ecc6a6696cdd33a24f9facb56f43ff86 | fdosani/dfs-tree | /dfstree.py | 1,782 | 3.921875 | 4 | """
DFS algorithim of a basic Tree structure
"""
class Tree(object):
"""Basic Tree object to hold the data and a list representing the
children
"""
def __init__(self, data, children=[]):
self.data = data
self.children = children
@staticmethod
def dfsearcher(tree, node):
... |
eec10a7e16ccc9ea50316ce94f110b66b1c73c4c | guruvishnu2/mass_certificate_mailer | /mail.py | 2,286 | 3.640625 | 4 | # Python code to illustrate Sending mail with attachments
# from your Gmail account
# Python program to explain cv2.putText() method
# importing cv2
import cv2
import csv, smtplib, ssl
import cv2
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText... |
61fba4dfd9df81f930802cb0490aa2a19e3faefd | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex023-SeparaNumero.py | 232 | 3.59375 | 4 | n = input('Digite um número? ')
print('Unidade: ', n[3])
print('Dezena: ', n[2])
print('Centena: ', n[1])
print('Milhar: ', n[0])
'''
unidade = n // 1 % 10
dezena = n // 10 % 10
centena = n // 100 % 10
milhar = n // 1000 % 10
''' |
3079d5006ef5d2a589ed3582c978d839a125c0f9 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex065-MediaMaiorMenorWhile.py | 592 | 3.8125 | 4 | x = 'S'
contmedia = 0
soma = 0
maior = 0
menor = 0
condicao = 1
while x == 'S':
n = int(input('Digite um número: '))
soma += n
contmedia += 1
x = str(input('Digite S para continuar: ')).strip().upper()
if condicao == 1:
maior += n
menor += n
condicao += 1
if n > maior:
... |
5e7ee217600e39076abe6285b43f416721ba2d96 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex061-ProgressaoAritimetica2.py | 186 | 3.890625 | 4 | primeiro = int(input('Digite o primeiro termo da PA: '))
razao = int(input('Digite a razão: '))
x = 10
pa = primeiro
while x != 0:
print(f'{pa} ', end='')
pa += razao
x -=1 |
8a414485ec32620609ac35f2b5b81e0600535a46 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex041-Natacao.py | 758 | 3.984375 | 4 | #from datetime import date
#date.today().year
nome = str(input('Qual o seu nome? ')).strip()
ano = int(input('Em que ano você nasceu? '))
idade = 2020 - ano
if idade <= 9:
print('Olá {}. Você tem {} anos. E sua categoria é: MIRIM'.format(nome, abs(idade)))
elif (idade > 9) and (idade <= 14):
print('Olá {}. V... |
c649823122c3dd43a05f5c22d66828c6b9d5902f | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex075-ColocarValorEmTupla.py | 1,095 | 3.9375 | 4 | tupla = (int(input('Digite um número: ')),
int(input('Digite um número: ')),
int(input('Digite um número: ')),
int(input('Digite um número: ')))
'''print('='*35)
a = int(input('Digite o primeiro valor: '))
b = int(input('Digite o segundo valor: '))
c = int(input('Digite o terceiro valor: ')... |
0d57f66af61b3b31e49988326d4a41aee7fe83d9 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex099-FuncaoMaior.py | 396 | 3.859375 | 4 | from time import sleep
def maior(*num):
print('Analisando os valores....')
sleep(1)
if len(num) == 0:
print(f'Não foram informados nenhum valor...')
else:
print(f'Os Valores são: {num}')
print(f'Foram informados {len(num)} números, cujo maior é {max(n... |
abb0fc95037362f290ce82537cd56d0720c5fde0 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Aula18-Listas2.py | 908 | 4.0625 | 4 | # Lista composta
pessoas = [['José', '22'], ['Maria', '55']]
print(pessoas[1])
print(pessoas[0][0])
teste = []
print(teste)
teste.append('Gustavo')
teste.append(40)
#teste.append([variavel1, variavel2, etc])
#teste[indice].append() # Adiciona no indice
print(teste)
galera = list()
galera.append(teste[:]) # Também ig... |
2ee1ecec1a2b53884a259649b6f59281ffd118cc | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Aula17-Listas1.py | 1,541 | 4.34375 | 4 | lista = [1,2,3]
# lista vazia : lista = [] ou lista = list()
print(lista)
i = 1
lista2 = []
while i <= len(lista):
lista2.append(lista.index(i))
lista2.append(lista[i])
i+=1
print(lista2)
# lista.append('append') # Adiciona no final da lista
# # print(lista)
# #
# # lista.insert(1,'insert') # Adiciona ... |
9b2293b2043b5ca71f9dcb721ebdf71269373149 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex006-DoproTriploRaiz.py | 171 | 4.03125 | 4 | x = int(input('Digite um número: '))
d = x*2
t = x*3
raiz = x**(1/2)
print('O valor foi {}\nSeu Dobro é {}\nSeu Triplo é {}\nE sua raiz é {:.0f}'.format(x,d,t,raiz)) |
c88471e4498d8ee9343434e29b1a58d1e1732715 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex025-FindSilva.py | 237 | 4.1875 | 4 | nome = str(input("Qual o Seu nome? "))
teste = nome.find('Silva')
if teste != -1:
print('Você tem Silva no nome!')
else:
print('Você não tem Silva no nome!')
#print('Você tem Silva no nome? '.format('SILVA' in nome.upper)) |
c48cf10e1834ca25f5bdda7c70dad8d70a755e7d | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex007-MédiaAluno.py | 196 | 3.96875 | 4 | x = int(input("Digite a primeira nota: "))
y = int(input('Digite a segunda nota:'))
media = (x+y)/2
print('A primeira nota foi: {} \nA segunda nota foi: {} \nE a média é {}'.format(x,y,media)) |
c0805c4e18b533390f105e1d200ea321eb4f6bb0 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex90-DicionarioAlunos.py | 339 | 3.640625 | 4 | dicionario = {}
nome = str(input('Qual o nome do aluno? ')).strip()
media = float(input('Qual a média do aluno? '))
if media >= 7:
situacao = 'APROVADO'
else:
situacao = 'REPROVADO'
dicionario['Nome'] = nome
dicionario['Media'] = media
dicionario['Situação'] = situacao
for k, i in dicionario.items():
prin... |
6855e12034cc03fd78dc162c4822c8cc0939d40e | bigrewal/Linear-Regression | /multivariate/main.py | 755 | 3.5625 | 4 | import numpy as np
from multivariate.loadData import load
from multivariate.normalise import normalise
from multivariate.gradientDescent import gradientDescent
from multivariate.prediction import predict
import matplotlib.pyplot as plt
#Load data
X,y = load("data.txt")
m,n = X.shape
#Normalise Data
X_norm,mu,sd = nor... |
50bf1cdb290c1bde19020f160c4f5cb0f9a43848 | SaikumarReddySandannagari/Linked-List-2 | /reorder list.py | 551 | 3.640625 | 4 | class Solution:
def reorderList(self, head: ListNode) -> None:
if not head:
return
slow=fast=head
while fast and fast.next:
slow=slow.next
fast=fast.next.next
prev=None
curr=slow
while curr:
curr.next, prev, curr = prev,... |
04f15cef08b778e5802ad2fa0ee8360d8e63498a | JASON-NANN/Python | /Sport.py | 1,450 | 3.84375 | 4 | #体育竞技分析
from random import random
def printintro():
print("这个程序模拟两个选手A和B的某种竞技比赛")
print("程序运行需要A和B的能力值(以0到1间的小数来表示")
def getinputs():
a=eval(input("请输入选手A的能力值(0—1):"))
b=eval(input("请输入选手B的能力值(0—1):"))
n=eval(input("模拟比赛场次:"))
return a,b,n
def printsummary(winsA,winsB):
n=winsA+winsB
pri... |
231b480162af4968ba009e9478dc76ed464e2ad5 | L-M-V-A/CIS4030-Problems | /gen.py | 113 | 3.625 | 4 | def mystery(x):
for i in range(x):
yield(i**2)
for i in mystery(5):
print(i, end=" ")
print("")
|
4b6d6b4aaf92c269184c3e8d871ae81e646bbb9c | jvrcavalcanti/Algorithms | /machine_learning/activates.py | 370 | 3.546875 | 4 | import numpy as np
def sigmoid(x):
return 1.0 / (1.0 + np.exp(-x))
''' Não estoura '''
# if inx>=0:
# return 1.0/(1+exp(-inx))
# else:
# return exp(inx)/(1+exp(inx))
def sigmoid_derivative(x):
return sigmoid(x) * (1.0 - sigmoid(x))
def relu(x):
return np.maximum(0, x)
... |
bdedfb83e968a40105ef1072b7b46a3767ce1646 | jvrcavalcanti/Algorithms | /data_structure/binary_tree.py | 2,227 | 4 | 4 | class Node(object):
def __init__(self, state):
self.state = state
self.left = None
self.right = None
def search(self, state):
if state == self.state:
return self.state
if state > self.state and self.left is not None:
return self.left.sear... |
230f598c565f7def939a8684fa69a9cb2bf57ba8 | giuliasteck/MC102 | /lab14/lab14.py | 3,857 | 3.859375 | 4 | """
Nome: Giulia Steck
RA: 173458
Descrição: esse programa tem como objetivo checar a ação de 4 empresas
a partir da entrada d dias (cada empresa tem um valor de sua ação em cada
um dos dias) e checar qual a combinação de compra/venda de ações gerará o
lucro máximo. Como saída temos as empresas das quais se comprou a ... |
c4614ec872097cfdba1eb3bd96f9f92560a774f0 | appletime81/RNN_enthalpy_predict | /load_data.py | 817 | 3.546875 | 4 | import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
def load_data(file_name, column_name):
# load csv
df = pd.read_csv(file_name)
df = df[column_name]
# convert to numpy format
data = np.array(df)
# split train data and test data
train_data = data[:int(l... |
07aa616efc4b4b8dfe4ec5490fb64564eea15675 | tikhomirovd/2sem_Python3 | /Calculate/Main.py | 10,488 | 3.859375 | 4 | # Данная программа выполняет сложение и вычитание
# В троично-симметричной системе счисления
# Тихомиров Дмитрий, ИУ7-25
# text0, text1 - Вспомогательный текст
# x_entry, y_entry - размер окошек для данных
# x_vidget, y_vidget - размер окошек виджета
# width, height - ширина и высота меню
# color - цвет фо... |
60a49ed876d055a8f1cef1b497abbd956ac81daa | NathanKe/AdventPython | /2021/02_answer.py | 1,261 | 3.71875 | 4 | instructions = open('02_input').read().splitlines()
class Submarine:
def __init__(self):
self.x = 0
self.d = 0
def parse_instruction(self, instr):
instr_type, val_str = instr.split(" ")
val = int(val_str)
if instr_type == "forward":
self.x += val
el... |
bb101160ea8ef7ffe25bcccf3c73d3642e94fc6c | NathanKe/AdventPython | /Wordle/wordle_interactive.py | 6,381 | 3.640625 | 4 | # https://www.devangthakkar.com/wordle_archive/
from collections import Counter
data_word_list = open('word_list.txt').read().splitlines()
answer_list = open('answer_list.txt').read().splitlines()
possible_results = open('possible_results.txt').read().splitlines()
# 0 wrong, 1 right letter wrong place, 2 right lett... |
66ac66d12fab61d7c3b9a5edce110bb526ee22d1 | andjo16/course-help | /DM562/Python Exercises/asg1-vecmat/vec.py | 4,482 | 4.0625 | 4 |
def getitem(v, k):
"""
Return the value of entry k in vector v.
Entries start from zero
>>> v = Vec([1,2,3,4])
>>> v[2]
3
>>> v[0]
1
"""
assert k in range(v.size)
return v.store[k]
def setitem(v, k, val):
"""
Set the element of v with index k to be val.
The fu... |
d748e06e808f869fd6c20698f952b52fb9067e1e | andjo16/course-help | /Games/guessANumber.py | 274 | 4.0625 | 4 | import random
name = input("Hello! What is your name? ")
val = input(name+"! Guess a number between 1 and 100 ")
num = random.randint(1,101)
if val == num:
print("Congratulations, you guessed the number!")
else:
print("You guessed wrong. The number was "+str(num))
|
6145dbad2b18f0683ae5654aff3b19320e4911e9 | Gu1nness/AsmInterpreter | /interpreter/interpreter/number.py | 2,949 | 3.703125 | 4 | # -*- coding:utf8 -*-
"""
Defines a number, with all the computations associated to it.
"""
class Number():
""" A number.
"""
types = {
"f" : "8bits",
"e" : "32bits",
"r" : "64bits",
"l" : "64bits",
"q" : "64bits",
}
order = ('f', 'e', 'r', 'l', 'q')
def... |
04af90c6264a72ea3f45950fe06182fd77ebbcad | ouujj/Bi-Section-Methods | /Bi-Section-Methods.py | 1,991 | 3.546875 | 4 | import math
import matplotlib.pyplot as plt
fucntion = input("Enter Fucntion (single value by x): ")
a=float(input("Enter a horizon:"))
a0 = int(a)
b=float(input("Enter b horizon:"))
b0 = int(b)
e=float(input("Enter tolerance:"))
n=int((b-a)/e)
xk, xk1 = 0,0
pxk=[]
diction = fucntion.count('x')
pr... |
873879f49529cc6abfb81cb3258aa8fb431b1ca5 | Sahana-Chandrashekar/infytq | /prg23.py | 493 | 4.25 | 4 | '''
Write a python function to find out whether a number is divisible by the sum of its digits. If so return True,else return False.
Sample Input Expected Output
42 True
66 False
'''
#PF-Prac-23
def divisible_by_sum(number):
temp = number
s = 0
while number != 0:
re... |
35c1de6e0a495223a052ab256bd6b755f0447747 | Sahana-Chandrashekar/infytq | /prg32.py | 435 | 4 | 4 | '''
Given an integer n, write a python function to return true,if it is possible to
representit as a sum of the squares of two different integers,else return false.
'''
#PF-Prac-32
def check_squares(number):
i = 1
while i*i <= number:
j=1
while j*j <= number:
if i*i+j*j==number:
... |
a8ed268c7e6de12a75fb3076f726d3f0b4c2b11e | zuznar649764/Czysty-kod-w-Pythonie | /Zadanie2.py | 2,888 | 3.984375 | 4 | import math
class circle:
def radius(self):
while 1:
try:
r = float(input("Podaj promień koła: "))
#sprawdzenie czy koło o podanym promieniu może istnieć (czy jest liczbą wiekszą od 0)
while r < 0:
print("Coś poszło ni... |
6fb1a52795237664e4f5084130a818eede275fe6 | bbansalaman0/ML | /Python Learning/ass/as 5.2.py | 419 | 3.9375 | 4 | n=0
largest=-1
smallest=None
while True:
n=input('enter in input:')
if n=='done':
break
try:
num=int(n)
except: print('Invalid input')
if num>largest:
largest=num
elif smallest is None:
smallest=num
elif num<smallest:
smallest=... |
ed752e6abb8c54d3a509c07458e5d6a5dd87172a | bbansalaman0/ML | /Python Learning/tuple].py | 341 | 3.96875 | 4 | str=input("Enter some elements: ").split(',')
lst=[int(i) for i in str]
tpl=tuple(lst)
print(tpl)
x=sorted(tpl)
print(x)
y=sorted(tpl,reverse=True)
print(y)
ele=int(input('enter a number to search: '))
try:
pos=tpl.index(ele)
print('found at position: ',pos+1)
except ValueError:
print('Not foun... |
6be4984cce746d1523b112bd7b84130cbcc20810 | bbansalaman0/ML | /Python Learning/accept_two_integers_numbers.py | 822 | 3.90625 | 4 | x=int(input("enter x value="))
y=int(input("enter y value="))
print("1. u have entered:", x,y,x+y,x*y, sep="__")
print("""""sum of", x ,"and", y, "is", x+y,
"product of ", x, "and", y, "is", x*y""")
print("""""sum of", {} ,"and", {}, "is", {},
"product of ", {}, "and", {}, "is", {:5.3f}""".format(x,y,x+y,x,y,x*y)... |
b29b10dde4c8b9f6378938b4ceb566f9264b1309 | bbansalaman0/ML | /Python Learning/nested loop.py | 1,847 | 3.703125 | 4 | print('exp=1')
for i in range(3):
for j in range(4):
print('i=',i,'\t','j=',j,'\n')
print()
print()
print("exp=2")
for i in range(1,11):
for j in range(1,i+1):
print("* ",end=" ")
print()
print()
print()
print("exp=2.2")
for i in range(1,11):
print("* "*(i))
... |
9f20fa1d1cf88242278f2f911649beb8d70a1111 | bbansalaman0/ML | /Python Learning/enter 3 numbers_strings.py | 256 | 3.71875 | 4 | x,y,z=[int(i) for i in input('enter three numbers=').split( )]
print('sum=\t',x+y+z,'\nproduct=',x*y*z )
str=[i for i in input('enter three names:').split(',')]
print("you have entered:",str,sep="_")
for h in str:
print(h)
print(-str)
|
b0ace3c477afcb7b4d6d216f5f65f9a3054ead77 | bbansalaman0/ML | /Python Learning/tower of hanoi.py | 316 | 3.796875 | 4 | def towers(n,a,c,b):
if n==1:
print('move disk {} from pole {} to pole {}'.format(n,a,c))
else:
towers(n-1,a,b,c)
print('move disk {} from pole {} to pole {}'.format(n,a,c))
towers(n-1,b,c,a)
n=int(input('enter no. of disks= '))
towers(n,'A','C','B')
|
da161b67cd5597ebde03769033bf57c141711dbb | bbansalaman0/ML | /Python Learning/ass/as 2.3.py | 126 | 3.859375 | 4 | hours=input('enter total hours : ')
rate=input('enter rate: ')
total_pay=float(hours)*float(rate)
print('Pay:',total_pay)
|
98c4bda3609b9f8a03a5b49dd859547b71fe71aa | xiaoloinzi/worksplace | /GR1/u2/py.py | 204 | 3.59375 | 4 | # encoding=utf-8
# 要过滤
n = int(raw_input('input a num:'))
m = int(raw_input('input a num:'))
def DaLv(n,m):
#方法一
# 需要过滤
str1 = n + m
return str1#过滤1
print DaLv(n,m) |
a062d3aec03d7f54b4922d1058cc6faed8573fe2 | xiaoloinzi/worksplace | /GR1/GR_practice/chapter_1/chapter_1_02.py | 377 | 3.609375 | 4 | # encoding=utf-8
# 2. 输入a,b,c,d4个整数,计算a+b-c*d的结果
def funCsum():
a = int(raw_input('plese input the number-a:'))
b = int(raw_input('plese input the number-b:'))
c = int(raw_input('plese input the number-c:'))
d = int(raw_input('plese input the number-d:'))
sum = a + b - c * d
return 'a + b - c * ... |
d4e64d0a7d47641d476eb19490063e31f343365e | xiaoloinzi/worksplace | /GR1/formal_Class/Section_4/Section_4_01.py | 8,504 | 3.921875 | 4 | # encoding=utf-8
# 习题,对于如下列表,返回第2个元素到第4个元素,不少于两种方法:
#
list2 = [1, 2, 3, 4, 5, 6, 7 ]
# print list2[2:5]
print list2[-5:-2]
print 'new list:',list2[1:4]
for i in xrange(len(list2)):
if i >=2 and i<=4:
print list2[i],
print
# 列出你们所知道的列表运算符
list1 = [1,2,3,4]
print list1 + list2#组合
print list1 * 2#重复
print 3... |
ab049e9c3ef3aeba3146f3e2ee2072b9e9422353 | xiaoloinzi/worksplace | /GR1/meiriyilian/day_0818.py | 2,704 | 4.1875 | 4 | # encoding=utf-8
# 【python每日一练】实现一个购物车功能,商品属性只需要包括名称,数量,价格,
# 要求实现添加一个商品,删除一个商品,最终打印订单详情和总价格
'''
1、写一个购物车的类,属性有商品名称,数量,价格,然后实现添加商品,删除商品、打印订单详情的方法
2、定义一个字典的数据结构进行存储数据,要判断输入的商品是否存在,存在则提示并不保存
'''
dict1 = {}
class Shopping(object):
def __init__(self,product_name= None,price= None,quantity= None):
self.product_... |
53c8da4be6ebbe88f7bcdaf9e03f8dd3642bff08 | xiaoloinzi/worksplace | /GR1/formal_Class/Section_4/Section_4_02.py | 1,711 | 3.671875 | 4 | # encoding=utf-8
tup1 = ()
print type(tup1)
tup2 = (123)
tup3 = (123,)#一个元组的一定要加逗号
tup4 = ('abc')
print type(tup2),tup2
print type(tup3),tup3,len(tup3)
print type(tup4),len(tup4)
# 对于如下的元组:
tup1 = ('physics', 'chemistry', 1997, [198,987,27], 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )
# 1、访问元组tup1中的数据
# 2、对tup1进行切片操作
# 3、把元... |
59af042e6c4f2334cd7db48814585e2c295d28da | xiaoloinzi/worksplace | /GR1/practice/chapter_07_01/test.py | 420 | 3.609375 | 4 | # encoding=utf-8
__all__=['bar','baz','add']
waz = 5
bar = 10
print u'这是test模块'
def print_func(par):
newStr = 'Hello :',par
return newStr
def add(x,y,*args):
sum = x+y
if len(args)>0:
for i in args:
sum += i
return sum
def sub(x,y,*args):
result = x-y
if len(args)>0:
... |
ab3b6228e1adaa32360705075c2a7c22450311f1 | xiaoloinzi/worksplace | /GR1/Preview/p2.py | 2,846 | 3.546875 | 4 | # encoding=utf-8
list = [12,'ldfd',2.3]
print list
shoplist = ['apple','mongo','carrot','banana']
print 'I have',len(shoplist),'item to buy'
print type(shoplist)
for item in shoplist:
print item
shoplist.append('rice')
print u'新购物清单',shoplist
shoplist.sort()#sort方法只能先排序,再输出。
print u'排序后的购物清单',shoplist
#打印字符串,整... |
4fe1fa70cb79b60ca4331162a586ed2dd098afb6 | xiaoloinzi/worksplace | /GR1/formal_Class/Section_7/Section_07_02.py | 6,902 | 3.75 | 4 | # encoding=utf-8
import os,sys
# 习题:写一个函数,嵌套捕获异常,捕获open文件的IO异常,
# 以及在操作文件过程中的异常(通过raise 抛出异常)。
# 分别构建两种异常(打开文件的IOError 和 raise 的异常),
# 并且讲出程序是在哪里捕获的。
def func(fileName):
try:
with open(fileName) as fp:
print 'enter with area.'
raise Exception('bad input')
except IOError as e:
... |
d587a81212fc74b2a14d6dd539c0a9363ed734a5 | xiaoloinzi/worksplace | /GR1/GR_practice/chapter_2/chapter_2_all.py | 11,900 | 3.703125 | 4 | # #!/usr/bin/env python
# # -*- coding: utf-8 -*-
# # @Time : 2017/3/30 9:58
# # @Author : Lin
# # @Site :
# # @File : chapter_2_all.py
# # @Software: PyCharm
#
#
# # 1.使用尽可能多的方法实现list去重
#
# import itertools
#
# list1 = [1,7,3,8,3,2,5,6,1,2,3,4]
# list2 = ['a','b','c','d','d','a','b','f']
# list3 = []
# list4... |
3f157b80b89c29f388774af8eb6d1297314d6e75 | xiaoloinzi/worksplace | /GR1/formal_Class/Section_10/Section_10_02.py | 7,532 | 4.25 | 4 | # encoding=utf-8
# 1、方法的重载
# func(int a,int b)
# func()
# func(int a,int b,int c)
# func(a1,b1)
# func(a1,b1,c1)
#
# 2、方法的重写
# class A(B):
# 子类方法重写和父类的方法没有关系,而是一个重新的方法
class Parent(object):
def myMethod(self):
print 'class Parent'
def printName(self):
print 'my name is lily'
class Child(Par... |
69f74d8519556213fb5d839c61c72a4d72893da2 | xiaoloinzi/worksplace | /GR1/GR_practice/chapter_4/Section_4_02_all.py | 9,191 | 3.90625 | 4 | # encoding=utf-8
# 11、返回列表中第二大元素
list1 = [2,1,4,6,3,8,34,911,34,19,20,20]
def printDiEr(list):
lista = []
for i in list:
if i not in lista:
lista.append(i)
lista.sort()
return lista[-2]
print printDiEr(list1)
# 老师的方法:排序--取倒数第二个元素
list1 = [1,2,34,23,45]
list2 = list(set(list1))
list... |
8f9f94473bc4037a976da6f4081611a16673dbb9 | xiaoloinzi/worksplace | /GR1/practice/Section_002/Section_002_01.py | 1,753 | 3.765625 | 4 | # # encoding=utf-8
# import time
# def printme(str):
# '''
# 打印传入的字符串到标准显示设备上
# :param str: 传入的字符串
# :return:none
# '''
# print time.time(),':',str
# return
#
# print printme(u'周末快乐')
#
# #无参参数
# def SayHello():
# '''
#
# :return:none
# '''
# print 'Hello World!'# block belon... |
2f1e3b9fc5019f74ed80c0bb7beb04e8f28d0f43 | 2105-may24-devops/andrew-project0 | /main.py | 2,635 | 3.859375 | 4 | import admin
import student
#Function checks if the user is in the student database
def check_user(user,password):
if user in admin.student_dict:
if password == admin.student_dict[user].strip("\n"):
name = user.replace("_"," ")
with open("log.txt",'a') as log:
log.wr... |
4580b9c453e034b9c8a967ae2922a64f057ae6c4 | Ppichamol/Test | /Digit Error.py | 1,420 | 3.734375 | 4 | print ('Input your number:')
x = input()
x = str(x)
def findMax (a):
if (a[0] != '9'):
max = a[0]
for j in a:
if j == max:
a = a.replace(j, '9')
return (a)
else:
for i in range(len(a)):
if (a[i] == '9'):
pass
... |
b50b520f6a197f97a25de92707428f5f7556909e | dalvsmerk/nn_hw | /practice2/softmax.py | 4,522 | 3.640625 | 4 | import numpy as np
from random import shuffle
from past.builtins import xrange
def softmax_loss_naive(W, X, y, reg):
"""
Softmax (cross-entropy) loss function, naive implementation (with loops)
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A numpy... |
88ab6d0234b210119fda15fe508a7fc65d0b94ab | Brijesh739837/Mtechmmm | /arrayinput.py | 242 | 4.125 | 4 | from array import *
arr=array('i',[]) # creates an empty array
length = int(input("enter the no of students"))
for i in range(length):
n = int(input("enter the marks of students"))
arr.append(n)
for maria in arr:
print(maria) |
e3a8438363673559e8374f41e5040f77ad39e0a5 | Brijesh739837/Mtechmmm | /arraynumpy.py | 316 | 3.59375 | 4 | from numpy import *
import time
arr = array([1,2,3,4,5])
print(arr)
for e in arr:
# time.sleep(2)
print(e)
print(arr.dtype)
arr1 =array([1,2,3,4,5.5])
print(arr1.dtype)
print(arr1)
arr2 = array([1,2,3,4,5],float)
print(arr2.dtype)
print(arr2)
arr3 =array([1,2,3,4,5.5],int)
print(arr3.dtype)
print(arr3)
|
8b744ce1431081f48d0e6cdddd414d8a6ec1604a | Brijesh739837/Mtechmmm | /numpyoperation.py | 1,016 | 4.15625 | 4 | from numpy import *
import time
arr = array([1,2,3,4,5])
arr = arr+10
print(arr)
arr =arr *5
print(arr)
arr1 = array([1,2,3,4,5])
arr2 = array([1, 2, 3, 4, 5])
arr3 = arr1 + arr2
print(arr3)
print(concatenate([arr1,arr2]))
''' copy an array to another arrray'''
''' aliasing '''
arr4 = arr1
print(arr4)
print(id(... |
5d583b299b290b36c7c6f0ade1dd2bb012ceaacf | Brijesh739837/Mtechmmm | /pattern.py | 251 | 3.921875 | 4 |
for i in range(4):
for j in range(4):
print("*",end='')
print('')
for i in range(4):
for j in range(4):
print(i,end='')
print('')
for i in range(4):
for j in range(4):
print(j, end='')
print('')
|
940c2f06be34dad6d306f1ca73f664f0d496bbc0 | Brijesh739837/Mtechmmm | /stringmaniexp.py | 797 | 4.28125 | 4 | '''x= input("enter your name")
name= x
a= len(name)
print(a)
print(name.capitalize())
print(name.lower())
print(name.upper())
print(name.swapcase())
print(name.title())
print(name.isdigit())
print(name.isalpha())
print(name.islower())
print(name.isupper())
print(name.isalnum())
str = input("enter a string")
print(str)
... |
c4a84446444dfe9611f73492dcd09524141bfc68 | Brijesh739837/Mtechmmm | /tkinter1.py | 548 | 3.71875 | 4 | from tkinter import *
root =Tk()
#frame=Frame(root)
TheLabel= Label(root,text="Enter User Name")
TheLabel.pack()
button1=Button(root,text="Login",bg="red",fg="yellow",padx="10")
button2=Button(root,text="Register",padx=20)
button5=Button(root,text="Registerfdsfsdf")
button3=Button(root,text="Cancel")
button1.pack(side... |
35b0fa3bcc88ee115807a2a5e7468adf636d9293 | chwn/PythonPractice | /TwoSum.py | 1,036 | 3.65625 | 4 | class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
'''
#Brute Force 暴力破解
lenth = len(nums)
for i in range(0,lenth ):
for j in range(i + 1,lenth ):
... |
10ccd99e077842dee81c863031c45b55452b6081 | reberetta/TechStartPro | /dbPreparer.py | 1,812 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
DB Preparer file
Olist challenge - Work for us
@author: reberetta
"""
import csv
"""
Function: create_tables
Parameters: DB cursor and connection
Return: void
This function creates the DB tables according to
db_diagram file of reference
"""
def create_tables(cursor, conn):
... |
56dfa6e4d1b0ef316cac9de3ad21287f69d0e854 | omostic21/personal-dev-repo | /guesser_game.py | 1,433 | 4.1875 | 4 | #I wrote this code just to play around and test my skils
#Author: Omolola O. Okesanjo
#Creation date: December 10, 2019
print("Welcome to the Number Guessing game!!")
x = input('Press 1 to play, press 2 for instructions, press 3 to exit')
x = int(x)
if x == 2:
print("The computer will pick a number within the... |
b2e22da5d7ad8459f7720406697640a13feb9f1f | mfa1980/python-012021 | /Lekce 5/Ukoly/priklad22.py | 1,298 | 3.5 | 4 | """
Hra o trůny
Stáhni si soubor character-deaths.csv, který obsahuje informace o smrti některých postav z prvních pěti
knih románové série Píseň ohně a ledu (A Song of Fire and Ice).
"""
#import wget
#wget.download("https://raw.githubusercontent.com/pesikj/python-012021/master/zadani/5/character-deaths.csv")
#1 Načti... |
24a0066c1f6d87c37cf15b81eb59f28c199997f8 | cgarey2014/school_python_projects | /garey3/program3_3.py | 1,175 | 4.21875 | 4 | # Chris Garey #2417512
# This is original work by me, there are no other collaborators.
# Begin Prog
# Set the initial answer counter to zero
# Ask the first question, count one point if correct and no points if wrong.
# Ask the second question, count one point if correct and no points if wrong.
# Ask the third questio... |
716e40bc650e28184eb0db5b599facd29b1249f7 | cxmhfut/PythonBasic | /eg_yield.py | 179 | 3.84375 | 4 | def create_generator():
mylist = range(3)
for i in mylist:
yield i * i
my_generator = create_generator()
print(my_generator)
for i in my_generator:
print(i)
|
be95e53e03661f89267b7e66369e2fa90e53cf2a | lspaulucio/CN-20192 | /TC2/pso.py | 3,115 | 3.640625 | 4 | # -*- coding: utf-8 -*-
# Aluno: Leonardo Santos Paulucio
# Data: 17/09/19
# Natural Computing - 2019/2
# Computacional Exercise 1
# PSO implementation
# Based on James D. McCaffrey implementation available on:
# https://jamesmccaffrey.wordpress.com/2015/06/09/particle-swarm-optimization-using-python/
import sys
imp... |
cf8a54663217521be44c3edf65c386872197c32b | sprksh/quest | /graph/floyd_warshall.py | 827 | 3.546875 | 4 | """
[
0,1,2,3
0, [0,1,*,*],
1, [1,0,0,0],
2, [1,0,0,0],
3, [1,0,0,0],
]
Algo:
initially prepare a adjacency matrix only with connected ones, keepeng rest as inf
for k in range(n):
A(k)[i,j] = min(A(k-1)[i,j], A(k-1)[i,k]+A(k-1)[k,j])
"""
# n^3 solution for leetcode 834
from typing import ... |
4c604ba99bcc50c27591d66e1f8d7c1d8fc313ed | sprksh/quest | /binary_search/find_in_rotated.py | 677 | 3.578125 | 4 | from .find_min import find_min
def find_in_rotated(arr, target):
offset = find_min(arr)
print(offset)
lo = 0
hi = len(arr) - 1
def get_offsetted(val): return val + offset - len(arr) if (val + offset) >= len(arr) else val + offset
while lo <= hi:
mid = lo + (hi-lo)//2
mid_o ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.