blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
5f279aeaaf943b0bb1f11c28958b7353a2932bde | MJ702/pythonprogamming | /pyton/lis.py | 474 | 3.828125 | 4 | name = ['raj', 'krana', 'yes']
l = []
print([person for person in name])
for person in name:
l.append(person + ' mental. ')
print(l)
print([person + ' mental.' for person in name])
l = []
movies_and_rating = {
'Marri':9 ,
'Marri_2': 9.1,
'Don': 3,
'Don_2': 6
}
for movie in movies_and_rating:
... |
92d1b1f39ade64e097bd9c35d7cfa7e0fd738183 | MJ702/pythonprogamming | /50_coding_pratices/Binary_addistion.py | 454 | 3.796875 | 4 | def addBinary(a, b):
carry = 0
result = []
i, j = len(a) - 1, len(b) - 1
while i >= 0 or j >= 0 or carry:
total = carry
if i >= 0:
total += int(a[i])
i -= 1
if j >= 0:
total += int(b[j])
j -= 1
result.append(str(total % ... |
1eead2fad6af0fd559e3c78850e0d21c3e131923 | MJ702/pythonprogamming | /pyton/file method/read_file.py | 184 | 3.53125 | 4 | file = open('demo.txt', 'r')
# readline function is used read a olny one line
print(file.readline())
# readlins function is used to read whole text of file
print(file.readlines())
|
c2def18e00ab287298031e6e1e0eea3d08fc69d1 | MJ702/pythonprogamming | /pyton/function/function.py | 755 | 4.3125 | 4 | # passing a function in other function
"""
def fun_1(name):
return f"Hello{name}"
def fun_2(name):
return f"{name} , How you doing?"
def fun_3(fun_4):
return fun_4(" I am insane progammar")
print(fun_3(fun_1))
print(fun_3(fun_2))
"""
# Inner function
"""
def fun():
print("You in function:")
... |
f9321932e8d25d8abb357f1d82aa82ad4b743a83 | MJ702/pythonprogamming | /pyton/function/mep-reduce_function.py | 897 | 3.515625 | 4 | def new(a):
return a * a
x = list(map(new, [1, 2, 3, 4, 5]))
print(x)
def new(a, b):
return a * b
x = list(map(new, [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]))
print(x)
# filter
def new(i):
if i >= 3:
return i
number_list = [1, 2, 3, 4, 5]
x = list(filter(new, number_list))
print(x)
x = list(filt... |
14da7b3d3dad88b67a9f2cd57323d259e59abd0d | MJ702/pythonprogamming | /pyton/email.py | 279 | 3.78125 | 4 | import re
vowels = 'aAeEIiOoUu'
text = "India is my country. kasodiyameet000@gmail.com .some rendoom text kasodiyamit1234@gmail.com"
vowels_1 = [ x for x in text if x in vowels.lower]
print(vowels_1)
patten = re.compile("[a-zA-Z0-9\.\-\_]+@+[a-zA-Z0-9]+\.[a-zA-Z]+")
result = patten.findall(text)
print(result)
|
32a4c72e59f8c8c751a4b9fb68eafcfbc982ff73 | MarianellaGL/Python-Basics | /.ipynb_checkpoints/Calculadorav2-checkpoint.py | 385 | 3.875 | 4 | import re
print("Hi Calcule")
print("Type 'quit' to exit\n")
previous=0
run = True
def performMath():
"defino la variable y despues la aplico en el ciclo while"
equation = input("Enter equation:")
if equation == 'quit':
run = False
print("yo... |
f78ef8856efa5346f167c702166a59ed596a4d8e | Weikoi/Demos_of_Python | /others/memory_stack.py | 89 | 3.71875 | 4 | a = [[1] * 3] * 3
b = [1] * 3
print(a)
print(b)
a[0][0] = 10
b[0] = 10
print(a)
print(b)
|
b0b3f4be1890ceff0c59f0c6f5023249128460a0 | annesuzuki/editPDF | /combinePDF.py | 523 | 3.578125 | 4 | #! python3
import PyPDF2, sys
# Combine any number of pdf files into one pdf
if len(sys.argv) < 2:
exit()
writer = PyPDF2.PdfFileWriter()
# Read through all pdf files and combine
for pdf in sys.argv[1:]:
try: # Skip any invalid file
reader = PyPDF2.PdfFileReader(pdf)
for pageNum in range(reader.nu... |
2b159712e4c1ec41eaca3fc441f397001b4cd7f5 | AryamaanParida/Artificial-Intelligence-Programs- | /bfsdfs.py | 913 | 4.03125 | 4 | graph = {
'A' : ['B','C'],
'B' : ['D'],
'C' : ['E','F'],
'D' : [],
'E' : [],
'F' : []
}
visited_bfs = [] # List to keep track of visited nodes.
queue = [] #Initialize a queue
def bfs(visited, graph, node):
visited.append(node)
queue.append(node)
while queue:
s = queue.pop(0... |
298d3c8110af29c2e4e05f998fa568760942d4ef | sourabh101/practice | /dynamicprogramming/longestCommonSubsequence.py | 553 | 3.9375 | 4 | def longest_subsequence(str1, str2):
n = len(str1) + 1
m = len(str2) + 1
matrix = [[0 for x in range(m)] for y in range(n)]
for j in range(1, m):
for i in range (1, n):
if str1[i - 1] == str2[j - 1]:
matrix[i][j] = matrix[i - 1][j - 1] + 1
else:
... |
4697aec9d9d948fb4945c7398afeaced9b8a7289 | sourabh101/practice | /BinarySearchTree.py | 3,404 | 3.6875 | 4 | import random
import sys
class Node:
def __init__(self, value=None):
self.value = value
self.left_child = None
self.right_child = None
class BST:
def __init__(self):
self.root = None
def insert(self, value):
if self.root is None:
self.root = Node(valu... |
d8f1c134ceb6c24c0d5bd3b6cc3a0f587abf54ed | nickatnight/slytherin | /menu.py | 1,552 | 3.859375 | 4 | import pygame
class Menu:
"""
Game Menus and screens for the snake game
Attributes:
display: the dimensions of the playing screen
pallet: the parent window that will display the game
"""
def __init__(self, display, pallet):
self.display = display
self.pallet = pal... |
0d24301aa0a2bc0fa1432138ac8df5babb181d18 | lokaiv/pythonbasicclass | /csvReader.py | 261 | 3.609375 | 4 | student_list = []
with open('students_list.csv', 'rt') as file:
file.readline()
while True:
line = file.readline()
if not line:
break
student = line.split(',')
student_list.append(student)
print(student_list) |
d2acd56c4f3a63e2aae0184dc630131dfdd18f90 | freeOcen/algori | /algoriDiagram/charpter5/hashtable.py | 189 | 3.59375 | 4 | import math
book = dict()
book["apple"] = 0.64
book["milk"] = 1.49
book["avocado"] = 1.43
#打印整个散列表
print(book)
#查询apple的价格
print(book["apple"])
print(math.sqrt(8)) |
04f42fb352c8ca0ee7b3b8034a23b4f48e6552e1 | doa-elizabeth-roys/CP1404_practicals | /prac_4/quick_picks.py | 609 | 4.15625 | 4 | import random
NUMBERS_PER_LINE = 6
MIN = 1
MAX = 45
number_of_line = int(input( "How many quick picks ?"))
while number_of_line < 0:
print("Enter numbers greater than 0")
number_of_line = int ( input ( "How many quick picks ?" ) )
for i in range(number_of_line):
quick_pick =[]
for j in range(NUMBERS_PER... |
36df6c04cb627f9d67f8b7e5a6a138dc16266d28 | doa-elizabeth-roys/CP1404_practicals | /prac_06/guitars.py | 892 | 3.765625 | 4 | from prac_06.guitar import Guitar
def main():
"""Get details of Guitar from user and print it."""
guitars = []
print("My guitars!")
name = input("Name : ")
while name != "":
year = input("Year : ")
cost = input("Cost :$ ")
print("{} ({}) : ${} added".format(name, year, cost))
... |
a593141204d17dd0a642db349adef7c7d13f716c | doa-elizabeth-roys/CP1404_practicals | /prac_08/taxi_simulator.py | 1,878 | 3.875 | 4 | from prac_08.silver_service_taxi import SilverServiceTaxi
from prac_08.taxi import Taxi
MENU = "q)uit, c)hoose taxi, d)rive"
def main():
taxi = None
total_cost = 0
current_bill = 0
taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)]
print("Let's dr... |
2fd466850e4d6d3369ea5c147cf9f51d734c0fec | whdesigns/Python3 | /1-basics/2-guis/1-classes-and-objects/Grid-Intro/Toolbar/bot.py | 1,391 | 4.28125 | 4 | from tkinter import *
# | CREATING DROP DOWN MENUS |
def doNothing():
print("ok ok I won't...")
root = Tk()
menu = Menu(root)
root.config(menu=menu) #States that we're setting up a menu and its equal the variable declared above.
subMenu = Menu(root)
menu.add_cascade(label="File", menu=subMenu) # This is the na... |
2ca903c12f828b5f2674ebc6c16ce0e84aca3978 | whdesigns/Python3 | /1-basics/5-functions/1-greeting/bot.py | 273 | 3.96875 | 4 | def greet_user(): # Declaring a function called greet_user.
print("Please enter your name")
name = str(input()) # Asking the user to enter their name.
print("Hello", name)
greet_user()
greet_user()
greet_user() # This is duplicated to print the question 3 times.
|
ee27e6bdc5e47396be4fc6232051f7120821cd90 | whdesigns/Python3 | /1-basics/2-guis/1-classes-and-objects/Frames_Widgets/bot.py | 971 | 4.40625 | 4 | from tkinter import *
root = Tk()
# | HOW TO MAKE FRAMES |
topFrame = Frame(root) # A frame is an invisable layout (like rectangles in illustrator), where you can place selected widgets
topFrame.pack() # topFrame goes on the top, but does not need to be called, because by default it will be at the top anyway, due... |
2f2d3811edfb3241e09821264c11836d27880309 | whdesigns/Python3 | /1-basics/2-guis/1-classes-and-objects/Grid-Intro/BindingFunctions-to-Widgets/bot.py | 385 | 4.3125 | 4 | from tkinter import *
# | BINDING FUNCTIONS TO WIDGETS |
root = Tk()
def print_name(): # Declaring a function called print_name
print("Hello my name is Will") # Printing some text related to that function
button_1 = Button(root, text="Print my name", command=print_name) # Use COMMAND to bind the function to a wi... |
6274f58e2d8e31a07434312cdb8beef13271ff44 | whdesigns/Python3 | /1-basics/3-decision/mock-exam/bot.py | 1,139 | 4.5625 | 5 | print("Please enter a whole number:")
user_number = int(input())
# I created a variable called user_number, which is equal to an integer, meaning it'll only accept whole numbers. I then used parentheses to include the input function, so the user will be able to enter a whole number of their choice. I then placed the qu... |
7d0529ad4e3d71b016f516ef06baff81ac2ae853 | whdesigns/Python3 | /1-basics/2-guis/1-classes-and-objects/GUI-Practice/bot_pack.py | 2,081 | 3.796875 | 4 | from tkinter import *
class Gui(Tk):
# Initialise the Gui object
# Self = the function belongs to this name
# Pass = placeholder. Does nothing
def __init__(self):
super().__init__()
# Set window attributes
self.title("Newsletter")
self.configure(bg="white",
... |
237475f757eb57262725ba841013157010363911 | maread99/pyroids | /pyroids/labels.py | 31,828 | 4.125 | 4 | #! /usr/bin/env python
"""Classes that create and maintain text to be displayed in the game window.
CLASSES
WindowLabels() Base class to create a window display comprising labels
StartLabels(WindowLabels) Introduction window.
NextLevelLabel(WindowLabels) Next Level label.
LevelLabel(WindowLabels) Current Level l... |
8ffae10a9eb8f5318b04c21da0f31d49bdabd847 | rachelwhaley/epa-rcra-violations | /archive/Esther_Edith/prev_assignments/pipeline.py | 10,014 | 3.59375 | 4 | '''
Esther Edith Spurlock (12196692)
CAPP 30254
Assignment 2: Machine Learning Pipeline
'''
#Imports
import pandas as pd
from sklearn.cross_validation import train_test_split
import os.path
import numpy as np
import sklearn.tree as tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accu... |
f282dd52d40396e2e594bf15b1572a6f00b54ce0 | sonalibishwas/python-programming | /Math/isprime.py | 292 | 3.859375 | 4 | import math
class Solution:
# @param A : integer
# @return an integer
def isPrime(self, A):
if A == 1 or A == 0:
return 0
for i in range(2, int(math.sqrt(A))+1):
if A%i == 0:
return 0
return 1
if __name__ == "__main__":
obj = Solution()
A = 7
print (obj.isPrime(A))
|
97f1b71fd1be4107292b390c15ef2bdb29b9ddd1 | sonalibishwas/python-programming | /Arrays/mergeIntervals.py | 817 | 3.78125 | 4 | # Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
# @param A, a list of Intervals
# @return a list of Interval
def merge(self, A):
import pdb
pdb.set_trace()
A = sorted(A)
s = A[0][0]
e = A[0][1]
result ... |
886c48b1521b824929bbbae59d96c5883114afce | sonalibishwas/python-programming | /Arrays/sieve.py | 433 | 3.6875 | 4 | import math
class Solution:
# @param A : integer
# @return a list of integers
def sieve(self, A):
primes = range(0,A+1)
primes[1]=0
for i in range(2,int(math.sqrt(A))+1):
if not primes[i] == 0:
j = 2
import pdb
pdb.set_trace()
while i * j <= A:
primes[i*j]=0
j+=1
result = [x for x ... |
c0400e23def64658263915930bed613f869e48f9 | sonalibishwas/python-programming | /GeeksForGeeks/minimum_distance_between_words.py | 1,362 | 4.09375 | 4 |
class FindMininumDistance:
def find_minimum_distance(self, hash_map, word1, word2):
if word1 not in hash_map.keys() or word2 not in hash_map.keys():
return -1
word1_indices = hash_map[word1]
word2_indices = hash_map[word2]
i = 0
j = 0
min_distance = floa... |
ee96d30c6060d61a500d0c114e387389917e02dd | takumi152/atcoder | /arc131a.py | 264 | 3.71875 | 4 | def main():
a = int(input())
b = int(input())
if b % 2 == 0:
print(str(b // 2) + '0' + str(a))
elif b > 1:
print(str(b // 2) + '5' + str(a))
else:
print('5' + str(a))
if __name__ == '__main__':
main()
|
797bc304aa7abb69dd2ae3fcb993104a02d7a247 | takumi152/atcoder | /abc169d.py | 961 | 3.734375 | 4 |
def prime_factorization(number):
n = number
i = 2
factor = {}
while i * i <= n:
while n % i == 0:
if i in factor:
factor[i] += 1
else:
factor.update({i : 1})
n //= i
i += 1
if n > 1 or not factor:
... |
7038a5757c810bf1b75fa53a59e1404358dd14f8 | takumi152/atcoder | /abc231b.py | 499 | 3.5 | 4 | def main():
n = int(input())
s = [None for _ in range(n)]
for i in range(n):
s[i] = input()
vote_count = dict()
for x in s:
if x not in vote_count:
vote_count[x] = 1
else:
vote_count[x] += 1
best_name = None
best_vote = 0
f... |
1eb8d566f439713e12781a8ca84346c5800ecbe4 | takumi152/atcoder | /yahoo2019a.py | 276 | 3.515625 | 4 |
def main():
buf = input()
buflist = buf.split()
N = int(buflist[0])
K = int(buflist[1])
count = 0
for i in range(0, N, 2):
count += 1
if count >= K:
print("YES")
else:
print("NO")
if __name__ == '__main__':
main()
|
6799b80e34fee74242166fa35bf5c55225c753bb | takumi152/atcoder | /past201912/past201912a.py | 239 | 3.609375 | 4 |
def main():
buf = input()
s = buf
for i in range(3):
if s[i] not in {'0','1','2','3','4','5','6','7','8','9'}:
print('error')
return
print(int(s) * 2)
if __name__ == '__main__':
main()
|
1aa9ad62ffbd08b2518942561868d14f851a72b9 | takumi152/atcoder | /diverta2019d.py | 322 | 3.59375 | 4 |
def main():
buf = input()
N = int(buf)
# N / m = i % i
# m * i + i = N
total = 0
i = 1
while i * i < N:
if N % i == 0:
div = N // i - 1
if N // div == N % div:
total += div
i += 1
print(total)
if __name__ == '__main__':
main(... |
122f825e7a4ac022882c62746cd9cbb8dd229742 | takumi152/atcoder | /abc204a.py | 302 | 3.625 | 4 | def main():
x, y = map(int, input().split())
if x == y:
print(x)
else:
s = {x, y}
if 0 not in s:
print(0)
elif 1 not in s:
print(1)
elif 2 not in s:
print(2)
if __name__ == '__main__':
main()
|
c4e766dd3176ea5a2e650fcd3d6437c6c36654ce | takumi152/atcoder | /abc114c.py | 1,032 | 3.6875 | 4 |
def main():
buf = input()
N = int(buf)
table = []
for i in range(1, 10):
create_table("", 0, i, table)
count = 0
for i in table:
if i <= N:
count += 1
else:
break
print(count)
def create_table(num, current_digit, maximum_digit,... |
7f7b4ffa0b78027f934f37510f8ee5e5b276de52 | Dhasaplo/folder1 | /beg42.py | 109 | 3.734375 | 4 | x=(input())
y=(input())
if len(x) > len(y):
print(x)
elif len(y)>len(x):
print(y)
else:
print(x)
|
3c96559c94de9c4405c976e1b7874a45f27ced49 | Dhasaplo/folder1 | /015.py | 86 | 3.546875 | 4 | a=int(input())
b=int(input())
c=a+1
for x in range (c,b,1):
if x%2==0:
print(x)
|
4f8c4f9b6806e09124c40b2aa3af4ffe23e9b3d6 | bulldra/nlp100 | /src/nlp_00/nlp_004.py | 658 | 3.5 | 4 | #!/usr/bin/env python3
__version__ = "0.1.0"
"""
04. 元素記号
“Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might
Also Sign Peace Security Clause. Arthur King Can.”
という文を単語に分解し,1, 5, 6, 7, 8, 9, 15, 16, 19番目
の単語は先頭の1文字,それ以外の単語は先頭の2文字を取り出し,
取り出した文字列から単語の位置(先頭から何番目の単語か)への連想配列
(辞書型もしくはマップ型)を作成せよ.
"""
d... |
3e072dd85cc70592a5c7c31ca358289d398e0780 | bulldra/nlp100 | /src/nlp_00/nlp_003.py | 428 | 3.515625 | 4 | #!/usr/bin/env python3
__version__ = "0.1.0"
import re
"""
03. 円周率
“Now I need a drink, alcoholic of course, after the heavy
lectures involving quantum mechanics.”
という文を単語に分解し,各単語の(アルファベットの)文字数を
先頭から出現順に並べたリストを作成せよ..
"""
def execute(arg):
return [len(s) for s in re.sub(r"[^a-zA-Z\s]", "", arg).split(" ")]
|
cafa956e42f52956c035c50857226f78539166bb | HattoryChan/PythonProject | /Napoleon IT ML test/Ant Alghorithm.py | 4,965 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Редактор Spyder
Это временный скриптовый файл.
"""
import random as rn
import numpy as np
import sys
from numpy.random import choice as np_choice
class AntColony(object):
def __init__(self, distances, n_ants, n_best, n_iterations, decay, alpha=1, beta=1):
"""
Args:
... |
6e42031a389da84eb06d36bbc8053ebc9866af75 | gwhite256/prg105 | /10.1 practice.py | 1,230 | 3.9375 | 4 | class Personal:
def __init__(self, name_in, address_in, age_in, phone_in):
self.__name = name_in
self.__address = address_in
self.__age = age_in
self.__phone = phone_in
def set_name(self, name_in):
self.__name = name_in
def set_address(self, address_in):... |
cd18fcf308e446282cc7f6414274a03f0272bc13 | gwhite256/prg105 | /10.2 practice/question.py | 1,242 | 3.703125 | 4 |
class Question:
def __init__(self, q, a1, a2, a3, a4, correct):
self.__question = q
self.__answer1 = a1
self.__answer2 = a2
self.__answer3 = a3
self.__answer4 = a4
self.__correct_answer = correct
def set_question(self, q):
self.__question = ... |
25199f19b0bf952e33b8347a5bb7240c335f0e5b | gwhite256/prg105 | /3.1practice.py | 1,017 | 4.1875 | 4 | # This program determines if a student is applicable for financial aid
# Declare the boolean value
financial_aid_status = True
# Get the data from the user
student_status = input("Are you a new or returning student? Enter R or N: ")
if student_status != 'R' or student_status != 'N':
financial_aid_status =... |
e2f365ead836e7e2244a69ba3146c7472d6c3afc | willmcgugan/inthing | /inthing/event.py | 2,085 | 3.953125 | 4 | """
Event Class
===========
"""
from __future__ import print_function
from __future__ import unicode_literals
class Event(object):
"""Contains the details of a new event.
This class provides a more finely grained way of creating events. To use,
construct an Event instance and add it to a stream with :... |
31adc6a09af3b47f661c70965fdfbc9f2b873334 | AmaJC/WhereInTheWorld | /GeoSkillPy/quizquestion.py | 1,435 | 3.796875 | 4 | import csv
class QuizQuestion:
"""Represents a quiz question."""
def __init__(self, question, answer):
"""Create a new quiz question with its answer. """
self.question = question
self.answer = answer
def get_question(self):
"""Getter method for the question text."""
return self.question
def get_answer... |
9a8a2cc62bae21f0642e845a116a45c642d9bc0a | Stevenzzz1996/MLLCV | /Leetcode/链表/82. 删除排序链表中的重复元素 II.py | 1,186 | 3.578125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/8 17:24
# 不保留重复的!
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
dummy = ListNode(-1)
dummy.next = head
slow = dummy
fast = dummy.next
while fast:
if fast.next a... |
7d6e7182ecd13e92b6b82d0edefa666bb0102d06 | Stevenzzz1996/MLLCV | /Leetcode/二叉树/面试题 04.05. 合法二叉搜索树.py | 1,519 | 4.0625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/7 9:26
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# 递归
class Solutio:
def isValidBST(self, root:TreeNode) -> bool:
node... |
30e072bf37811f87037cb35e992b59dee70598f0 | Stevenzzz1996/MLLCV | /Leetcode/基本语法集粹/cnotinue+break.py | 323 | 3.78125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/29 20:09
# nums=[1,1,1,1,1,1,1]
# k=0
# while k<len(nums):
# if nums[k] == nums[k - 1]:
# k += 1
# continue
# print(k)
#
# i=0
# while k<len(nums):
# if nums[i] == nums[i - 1]:
# k += 1
# break
# print(... |
8913e7c0fc3094d36b0d4fd7fd06edd87f048ba9 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题38. 字符串的排列.py | 583 | 4 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/31 22:27
def permutation(s):
if not s: return
s = list(sorted(s))
res = []
def helper(s, tmp):
if not s: res.append(''.join(tmp)) # 等到为空时,将其一起拼接!
for i, char in enumerate(s):
if i > 0 and s[i] ==... |
7fa3fb5ff80f20b1448e6b30fe79aa20d2a4f800 | Stevenzzz1996/MLLCV | /Leetcode/双指针/413. 等差数列划分.py | 955 | 3.828125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/27 20:51
# 创建两个指针first和last,first初始为0,last初始为2,判断两指针位置之间是否为等差数列,
# 是就last往后移一位,否就fisrt = last -1,每增加一位数,等差数列增加量为last - first -1,遍历一遍就行了
class Solution:
def numberOfArithmeticSlices( A) :
if len(A) < 3:
return 0
... |
9f70959b114112e909640ad0a1858c10c4f01a31 | Stevenzzz1996/MLLCV | /Leetcode/宽度搜索/岛屿数量.py | 1,750 | 3.796875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/29 15:35
#遍历 grid 当发现 1 辐射出去,找到所有 1
#力扣
def numsIlands(grid):
if not grid: return 0
m, n = len(grid), len(grid[0])
directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
land = 0
def isValid(x, y): # 判断给定坐标是否有效
return 0 ... |
fb7678854e84b584980cd44077e45ece3e26176b | Stevenzzz1996/MLLCV | /Leetcode/二叉树/104. 二叉树的最大深度.py | 1,151 | 3.640625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/7 15:09
class Solution:
def maxDepth(self, root: TreeNode) -> int:
if not root: return 0
return max(self.maxDepth(root.left), self.maxDepth(root.right))+1
# return max(self.maxDepth(root.left)+1,self.maxDepth(roo... |
6d91108d29b98d524de6c3990dde73cb5e5cacab | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题57 - II. 和为s的连续正数序列.py | 605 | 3.9375 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/2 17:50
# 双指针
def findContinueSequence(target):
i = j = 1 # j往前走,i用于从前面截断
cur_sum = 0
res = []
while j < target: # j小于target的都有可能
# 内循环操作
cur_sum += j # 依次加
j += 1
while cur_sum > target: ... |
c4a7ce7662f4d00ed9c09c1820575fe2da8ff36e | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题31. 栈的压入、弹出序列.py | 557 | 3.828125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/31 17:24
# 重点是模拟入栈出栈,定义一个stack模拟入栈和出栈,如果stack[-1] == poped的第一个元素,就开始出栈直到空!
def validateStackSequences(pushed, poped):
j = 0
stack = []
for i in pushed:
stack.append(i)
while stack and j < len(poped) and stack[-1] ... |
af02c34c3becca2aad10d1d3127b21cfd6434bdf | Stevenzzz1996/MLLCV | /Leetcode/十大排序算法/希尔排序.py | 1,626 | 3.625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/28 17:35
# (减小增量排序)
# 希尔排序,也称递减增量排序算法,是插入排序的一种更高效的改进版本。但希尔排序是非稳定排序算法。
# 希尔排序的基本思想是:先将整个待排序的记录序列分割成为若干子序列分别进行直接插入排序,
# 待整个序列中的记录"基本有序"时,再对全体记录进行依次直接插入排序。
def shell_sort(s):
n = len(s) #列表长度
gap = n // 2 ... |
32c82f5994717c90cc94b14f9c22b23dc3c3e2f8 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题58 - II. 左旋转字符串.py | 179 | 3.84375 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/2 19:20
class Solution:
def reverseLeftWords(self, s: str, n: int):
return s[n:] + s[:n] |
c3e1519f071ba5bd4d7c1bc3bc788dd1a51b19fb | Stevenzzz1996/MLLCV | /Leetcode/链表/876. 链表的中间结点.py | 540 | 3.78125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/8 21:22
# [1,2,3,4,5,6]
# 输出:此列表中的结点 4 (序列化形式:[4,5,6])
# 由于该列表有两个中间结点,值分别为 3 和 4,我们返回第二个结点。面试题 02.04. 分割链表
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
if not head: return 0
slow, fast = head, head
... |
aff9ff0ae83009fc4f4addd595b1799b2f6cdb60 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题11. 旋转数组的最小数字.py | 610 | 4 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/30 16:14
def minArray(arr):
l, r = 0, len(arr)-1
while l < r:
mid = (l + r) // 2
if arr[mid] > arr[r]:
# 说明最小的一定在右边,旋转的少3,4,5,1,2
l = mid+1
elif arr[mid]< r:
# mid有可能是最小值,移... |
4586b09c450dee767212967f45ec6a9a5ba96729 | Stevenzzz1996/MLLCV | /Leetcode/动态规划/198. 打家劫舍.py | 1,103 | 3.796875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/5 16:08
# 如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。
# 链表 空间优化!
from typing import List
class Solution:
def rob(self, nums: List[int]) -> int:
cur, pre = 0, 0
for num in nums:
cur, pre = max(pre + num, cur), cur
r... |
3fb42e318bf9566e631e0da52699724fcd5c86ac | Stevenzzz1996/MLLCV | /Leetcode/数组/56. 合并区间.py | 628 | 3.921875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/30 11:50
class Solution:
def merge(intervals):
n = len(intervals)
intervals.sort()
res = []
i = 0
while i < n:
left, right = intervals[i][0], intervals[i][1]
while i < n-1 a... |
f6dce469b517aa8bd27aebe21f8070bebafe6e59 | Stevenzzz1996/MLLCV | /Leetcode/基本语法集粹/接受用户输入.py | 248 | 3.625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/6/3 20:35
T = int(input())
for i in range(T):
N, K = [int(i) for i in input().split()]
print(res[k]+'\n')
T = int(input())
K = [int(i) for i in input().split()]
print(K) |
76970584defb1c3c5820f691622cd64007ba96ed | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题06. 从尾到头打印链表.py | 977 | 4 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/30 13:26
class LinkedList:
def __init__(self):
self.headval = None
class ListNode:
'''
data: 节点保存的数据
_next: 保存下一个节点对象
'''
def __init__(self, data, pnext=None):
self.data = data
self._next = pne... |
79764994b843bc6dd9a1646b321efdb132cff300 | Stevenzzz1996/MLLCV | /Leetcode/回溯/140. 单词拆分 II.py | 979 | 3.671875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/3 18:52
from typing import List
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:
import functools
if not wordDict:return []
wordDict = set(wordDict)
max_len = max(map(len, wor... |
410bc567b566d67da8d228ca25cbd6abd6459159 | Stevenzzz1996/MLLCV | /Leetcode/链表/61. 旋转链表.py | 1,302 | 3.984375 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/5/8 16:50
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
# 用双指针找到倒数k+1个数,然后直接反转
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNod... |
9d92f84b2284aa7961f45c64be08a1c97bea1881 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题27. 二叉树的镜像.py | 317 | 3.515625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/31 13:46
def mirrorTree(self, root: TreeNode) -> TreeNode:
if not root: return
root.left, root.right = root.right, root.left
mirrorTree(root.left) # 作为各自的跟继续寻找!
mirrorTree(root.right)
return root |
5ba88c29c6a26ec392ac893adb9ce39eff267fb2 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/面试题39. 数组中出现次数超过一半的数字.py | 1,057 | 3.765625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/4/1 10:50
from collections import Counter
def majorityElement(nums):
# count = Counter(nums)
# return count.most_common(1)[0][0] # 第一多的数字,然后返回第一个里面的第一个(key):比如2最多有4个,返回2
# dic = collections.Counter(nums)
# for key,val... |
3ef112e390e52136e65fbde8ea2d782571612369 | Stevenzzz1996/MLLCV | /Leetcode/二叉树/面试题33. 二叉搜索树的后序遍历序列.py | 856 | 3.9375 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/31 19:56
# 左右根,分治
# 判断数组是否为二叉搜索树的后序遍历!
class Solution:
def verifyPostorder(self, postorder: List[int]) -> bool:
def helper(sequence):
n = len(sequence)
if n <= 1: return True
root = sequence[-... |
1f3cd96e4a6fb10022ebf21925cd52e018832ff7 | Stevenzzz1996/MLLCV | /Leetcode/简单+剑指offer题/两数相加.py | 586 | 3.9375 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/29 17:55
# 直接从左往右加就完事了
def addTwoNumber(l1, l2) :
a, b, p, carry = l1, l2, None, 0
while a or b:
val = (a.val if a else 0) + (b.val if b else 0) + carry
carry = val // 10
val = val % 10
p = a if a els... |
268149e02fdb5fad248b720afcfbed5eeb6cb2ef | Stevenzzz1996/MLLCV | /Leetcode/链表/面试题35. 复杂链表的复制.py | 1,106 | 3.546875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 -*-
# author: sfhong2020 time:2020/3/31 21:54
class Solution:
def copyRandomList(self, head: 'Node') -> 'Node':
if not head: return
# 复制节点
cur = head
while cur:
tmp = cur.next
cur.next = Node(cur.val, None, None) # 创建一... |
c767096b6f3c700a8b46ec8c2d2759fe322a4af6 | BorisTheBrave/mc-dc | /marching_cubes_2d.py | 3,782 | 3.59375 | 4 | """Provides a function for performing 2D Marching Cubes"""
import math
from common import Edge, adapt, frange
from settings import XMIN, XMAX, YMIN, YMAX, CELL_SIZE
from utils_2d import V2, make_svg
def marching_cubes_2d_single_cell(f, x, y):
"""Returns a list of edges that approximate f's boundary for a single... |
72e725e0cff84a727dd6fe3df0ffa71832adf7f8 | arjunng/python-challenge | /PyPoll/Solved/main1.py | 2,612 | 3.671875 | 4 |
# Importing the necessory libraries
import os
import csv
import math
# Declaring the csv file path
file_path = os.path.join("..", "Resources", "03-Python_Instructions_PyPoll_Resources_election_data.csv")
# Dictionary declaration
myDict = {}
#Reading the csvfile
with open(file_path, newline='') as csvfile:
c... |
25a1716a61b2501710c31518757612cc4522bf9a | lmartin62/Ch-02-exercise-rework | /Ch 02 exercise 05.py | 117 | 3.828125 | 4 | #Lily Martin Ch 02 exercise 05
celsius = float(input('Celsius: '))
fahrenheit = (celsius * 1.8) + 32
print (fahrenheit) |
95b7857555c3b9bb111c7e1dd43fe2bc9be7cc9c | coffeelabor/Sprint-Challenge--Hash-BC | /hashtables/ex1/ex1.py | 1,588 | 3.5 | 4 | # Hint: You may not need all of these. Remove the unused functions.
from hashtables import (HashTable,
hash_table_insert,
hash_table_remove,
hash_table_retrieve,
hash_table_resize)
def get_indices_of_item_weights(weight... |
549e84ea5b26444a6efc30b93eeaa94c4bc9cad4 | JinYang-Law/-algorismS | /SingleLink/Slink.py | 3,277 | 3.71875 | 4 | class Node(object):
def __init__(self, item=None, next=None):
self.item = item
self.next = next
class SingleLink(object):
def __init__(self):
self._head = Node()
## 判断链表是否为空
def is_empty(self):
return True if self._head is None
""" 链表的长度, 遍历节点,统计指针指向... |
8d49aa6a2cd1279c4139b7041e6ebaf8a3c4b07a | ivan0124/python-programming | /py_argmax/test_argmax.py | 373 | 3.625 | 4 | #!/usr/bin/python
import numpy as np
def main():
my_y = [[1, 2, 3],
[4, 5, 1]]
# index [1, 1, 0] --> value [4, 5, 3]
my_y0 = np.argmax(my_y, axis=0)
print ("map my_y0 = %s \n" % my_y0)
# index [2, 1] --> value [3, 5]
my_y1 = np.argmax(my_y, axis=1)
print ("map my_y1 = %s ... |
d89340c0f194f333b962850bc6d0e94d0aee0385 | ivan0124/python-programming | /py_plot/plot.py | 492 | 3.953125 | 4 | #!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np
def main():
x = np.arange(0,180)
y = np.sin(x * np.pi / 180.0)
#input x,y list for drawing
plt.plot(x,y)
# set plot range
plt.xlim(-30,390)
plt.ylim(-1.5,1.5)
# set x, y label and title
plt.xlabel("x-axis")
... |
644d479fa7837e8964c802c1548bb47e6096880c | nishantml/Data-Structure-And-Algorithms | /Non-Linear-Data-structures/Binary-Search-Tree/kthSmallest.py | 714 | 3.671875 | 4 | """
230. Kth Smallest Element in a BST
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def kthSmallest(self, root: TreeNode, k: int) -> int:
A = []
... |
073ea729c515f95390490b6cf9cc6c98cc86ede7 | nishantml/Data-Structure-And-Algorithms | /searching-and-sorting/searching/linear-search.py | 231 | 3.734375 | 4 | def linear_search(arr, key):
for i in range(len(arr)):
if arr[i] == key:
print('Data found at index ', i)
return
print('Data not found ')
return
linear_search([3, 2, 3, 5, 6, 7, 1], 7)
|
aaa40103e0d98427c50b842fa1f16cc2a8f59206 | nishantml/Data-Structure-And-Algorithms | /basics-data-structure/linked-list/singly-linked-list.py | 3,276 | 3.765625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class SinglyLinkedList:
def __init__(self):
self.head = None
self.tail = None
def append(self, data):
new_node = Node(data)
if not self.head:
self.head = new_node
e... |
85f3571297d1fa3969cf23edc7932b2c30a8b49f | nishantml/Data-Structure-And-Algorithms | /leet/intersection.py | 615 | 3.8125 | 4 | """
349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.
Example 1:
Input: nums1 = [1,2,2,1], nums2 = [2,2]
Output: [2]
Example 2:
Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output: [9,4]
Note:
Each element in the result must be unique.
The result can be in any order.
... |
afd4a6b788a3c974be8830906237323584256f3a | nishantml/Data-Structure-And-Algorithms | /Non-Linear-Data-structures/Binary-Search-Tree/bst-implementation.py | 2,927 | 3.984375 | 4 | class Node:
def __init__(self, key):
self.left = None
self.right = None
self.val = key
class BST:
def __init__(self):
self.root = None
self.length = 0
def insert(self, value):
new_node = Node(value)
if self.root is None:
self.root = new... |
14a9b93cfaef6c37b395552b51850f1cf1aa8a22 | nishantml/Data-Structure-And-Algorithms | /startup-practice/string_int.py | 323 | 4.28125 | 4 | """
Create a function that takes a string and returns it as an integer.
Examples
string_int("6") ➞ 6
string_int("1000") ➞ 1000
string_int("12") ➞ 12
Notes
All numbers will be whole numbers.
"""
def string_int(txt):
return int(txt)
print(string_int("6"))
print(string_int("1000"))
print(string_int("12"))
|
9e9e6903ea9fe58e6916ec746e8772c1393d529e | nishantml/Data-Structure-And-Algorithms | /complete-dsa/array/kth-smallest-element.py | 287 | 3.96875 | 4 | def find_kth_smallest_element(arr, k):
arr.sort()
return arr[k - 1]
def find_kth_max_element(arr, k):
arr.sort()
print(arr)
return arr[k - 1]
# print(find_kth_smallest_element([21, 22, 1, 5, 4, 65, 7], 2))
print(find_kth_max_element([21, 22, 1, 5, 4, 65, 7], 2))
|
731ac5bdbb185f40842c6f055abe2cd641726c39 | nishantml/Data-Structure-And-Algorithms | /startup-practice/concat.py | 85 | 3.53125 | 4 | def concat(lst1, lst2):
return lst1 + lst2
print(concat([1, 3, 5], [2, 6, 8]))
|
212c1b206c70da92de2f9ccfe1f0bd709d028e14 | nishantml/Data-Structure-And-Algorithms | /searching-and-sorting/sorting/insertionSort.py | 340 | 4.0625 | 4 | def insertionSort(nums):
for i in range(len(nums)):
value = nums[i]
hole = i - 1
while hole >= 0 and nums[hole] > value:
nums[hole + 1] = nums[hole]
hole -= 1
nums[hole + 1] = value
return nums
arr = [3, 2, 1, 4, 5, 3, 65, 2, 45, 23, 21, 44, 100]
print(... |
eed6bb543412ed6c76c02ac795f1b061ab204147 | nishantml/Data-Structure-And-Algorithms | /startup-practice/count_true.py | 430 | 4.25 | 4 | """
Create a function which returns the number of True values in a list.
Examples
count_true([True, False, False, True, False]) ➞ 2
count_true([False, False, False, False]) ➞ 0
count_true([]) ➞ 0
Notes
Return 0 if given an empty list.
All list items are of the type bool (True or False).
"""
def count_true(lst):
... |
92c28036535759d932f4c4812dfe1c3ae4585779 | EvanSimpson/TweetCollector | /process.py | 3,856 | 3.671875 | 4 | '''
This file contains code to process json files containing twitter data and enter it into a database.
'''
import pymongo as mongo
import simplejson as json
count = 0
def categorize(text):
'''
Takes tweet text as argument, checks for keywords to categorize tweet.
Returns list of categories foun... |
16f4b4a49b702724d8dfc5a3678136dbbf4a02e9 | MKNachesa/Programming-1-for-Language-Technologists | /p1quiz/pgm/s6.py | 102 | 3.5625 | 4 | x = 'cat'
y = 'dog'
if x == 'cat':
y = 'crocodile'
if y == 'dog':
x = 'zebra'
print(x + y)
|
2eebf002ca1a3413b0406fc9c238c4506b52cc6a | robbailiff/macbook-projects | /zenva/shapes.py | 1,621 | 4.09375 | 4 | # Pygame development 1
# Start the basic game set up
# Set up the display
# Gain access to pygame library
import pygame
# Initilise pygame
pygame.init()
# Size of the screen
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800
SCREEN_TITLE = 'Crossy RPG'
# Colors according to RGB codes
WHITE_COLOR = (255, 255, 255)
BLACK_COLOR = ... |
cbf1023fa61bb6fdcfbd470c110fdc118c607214 | rmonaro/Log-Analysis-Project | /news_log_analysis.py | 3,020 | 3.5 | 4 | #! /usr/bin/env python
import psycopg2
DBNAME = "news"
# Here we query the db to get the answer to question 1
# What are the most popular three articles of all time?
mostPopularArticles = """
SELECT articles.title, COUNT(*) AS num FROM articles
JOIN log
ON log.path LIKE concat('/article/%',... |
cb9dd52235f5ad890682c6a576a66fb823874aa2 | hallgrimur1471/programming | /machine_learning/bypass_dummy_variable_trap_with_gradient_descent.py | 602 | 3.515625 | 4 | #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
N = 10
D = 3
X = np.zeros((N,D))
X[:,0] = 1
X[:5,1] = 1
X[5:,2] = 1
Y = np.array([0]*5 + [1]*5)
# does not work because: singular matrix
#w = np.linalg.solve(X.T.dot(X), X.T.dot(Y))
costs = []
w = np.random.randn(D) / np.sqrt(D)
learning_... |
44fb625d765136dec33a2b23eeca4372dfdb5b15 | hallgrimur1471/programming | /machine_learning/linear_regression_1d.py | 1,015 | 3.734375 | 4 | #!/usr/bin/env python3
"""
Calculates best line of fit and determines how good the fit was
"""
import numpy as np
import matplotlib.pyplot as plt
def main():
# load the data
X = []
Y = []
for line in open('data/data_1d.csv'):
x, y = line.split(',')
X.append(float(x))
Y.append(... |
f1d0ceb54bb39041fbdb4b6f2c832f406bf34db2 | berinhard/forkinrio_exercises | /exercicios/parte_3/parte_3_3.py | 1,140 | 3.875 | 4 | #-*- coding: utf-8 -*-
'''
3. Implementar um gerador que produza tuplas com as cores do padrao RGB
(R, G e B variam de 0 a 255) usando xrange() e uma funcao que produza uma
lista com as tuplas RGB usando range(). Compare a performance.
'''
import time
def gera_rgb_range():
r, g, b = 0, 0, 0
for i in range(256)... |
1a1421fdd2a8608428092446af756df4e236491b | berinhard/forkinrio_exercises | /exercicios/parte_2/parte_2_3.py | 1,161 | 3.96875 | 4 | #-*- coding: utf-8 -*-
'''
3. Implementar uma função que leia um arquivo e retorne uma lista de tuplas
com os dados (o separador de campo do arquivo é vírgula), eliminando as
linhas vazias. Caso ocorra algum problema, imprima uma mensagem de
aviso e encerre o programa.
'''
import sys
import os
from param_analyser imp... |
78ecaddfafc66abbae586f2ca30da06afc20c1c0 | berinhard/forkinrio_exercises | /exercicios/parte_1/parte_1_5.py | 774 | 4.25 | 4 | #-*- coding: utf-8 -*-
'''
Escreva uma função que:
* Receba uma frase como parâmetro.
* Retorne uma nova frase com cada palavra com as letras invertidas.
'''
#função
def inverte_todas_palavras_da_frase(frase):
lista_palavras = frase.split()
# com list comprehension
#lista_palavras_invertidas = [pal... |
6373736e04920d17a0703e15e47494e88086bcf8 | berinhard/forkinrio_exercises | /exercicios/parte_3/parte_3_1.py | 729 | 3.671875 | 4 | #-*- coding: utf-8 -*-
'''
1. Implementar um gerador de números primos.
'''
def gera_primos():
num = 1
while True:
num += 1
#o numero 2 já é primo
if num == 2:
yield num
#não dá o yield nos pares
if not(num % 2):
continue
... |
18d24edf49006889ca7624dcdd2065eae9912e7b | Marceloalf/Uri-debug | /question/lista/q2496.py | 633 | 3.75 | 4 | def comparison(not_ordered, ordered, n):
count = 0
for i in range(n):
if ordered[i] != not_ordered[i]: count += 1
return count
def chance(forms, index):
size = int(forms[index])
not_ordered = forms[index+1]
ordered = sorted(set(not_ordered))
if comparison(not_ordered, ordered, si... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.