blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
fe703b6364b1835b433410da896166adaf129654 | elijahsk/cpy5python | /practical04/q05_count_letter.py | 509 | 4.1875 | 4 | # Name: q05_count_letter.py
# Author: Song Kai
# Description: Find the number of occurences of a specified letter
# Created: 20130215
# Last Modified: 20130215
# value of True as 1 and value of False as 0
def count_letter(string,char):
if len(string)==1: return int(string[0]==char)
return int(string[0]==char)+... | true |
66488b56ef595a4ce86f4936262ce9c47c2030d0 | elijahsk/cpy5python | /practical03/q08_convert_milliseconds.py | 813 | 4.1875 | 4 | # Name: q08_convert_milliseconds.py
# Author: Song Kai
# Description: Convert milliseconds to hours,minutes and seconds
# Created: 20130215
# Last Modified: 20130215
# check whether the string can be converted into a number
def check(str):
if str.isdigit():
return True
else:
print("Please enter a prope... | true |
6dce3c4965f32564385623ffb9ef1528a180a016 | siddk/hacker-rank | /miscellaneous/python_tutorials/mobile_number.py | 469 | 4.125 | 4 | """
mobile_number.py
Given an integer N, and N phone numbers, print YES or NO to tell if it is a valid number or not.
A valid number starts with either 7, 8, or 9, and is 10 digits long.
"""
n = input()
for i in range(n):
number = raw_input()
if number.isdigit():
number = int(number)
if (len... | true |
b90e89de330807f02410bee5f6faa321376c0a26 | siddk/hacker-rank | /miscellaneous/python_tutorials/sets.py | 684 | 4.3125 | 4 | """
sets.py
You are given two sets of integers M and N and you have to print their symmetric difference in ascending order. The first line of input contains the value of M followed by M integers, and then N and N integers. Symmetric difference is the values that exist in M or N but not in both.
"""
m = input()
m_lis ... | true |
cbb33de2960bed126ad694a163a15aca703bc40a | askwierzynska/python_exercises | /exercise_2/main.py | 702 | 4.125 | 4 | import random
print('-----------------------------')
print('guess that number game')
print('-----------------------------')
print('')
that_number = random.randint(0, 50)
guess = -1
name = input("What's your name darling? ")
while guess != that_number:
guess_text = input('Guess number between 0 an 50: ')
gues... | true |
1607baf5554044a4870c9402e79c1ae0867faa0e | obayomi96/Algorithms | /Python/simulteneous_equation.py | 786 | 4.15625 | 4 | # solving simultaneous equation using python
print('For equation 1')
a = int(input("Type the coefficient of x = \n"))
b = int(input("Type the coefficient of y = \n"))
c = int(input("Type the coefficient of the constant, k = \n"))
print("For equation 2")
d = int(input("Type the coefficient of x = \n"))
e = int(input("T... | true |
9b6acd981eb913452c020d5bd66aac70f329fd6c | heyhenry/PracticalLearning-Python | /randomPlays.py | 1,096 | 4.15625 | 4 | import random
randomNumber = random.randint(1, 10)
randomNumber = str(randomNumber)
print('✯ Welcome to the guessing game ✯')
username = input('✯ Enter username: ')
guessesTaken = 0
print(username, 'is it? \nGreat name! \nOkay, the rules are simple.\n')
print('⚘ You have 6 attempts. \n⚘ Enter a number ranging betwe... | true |
de5a9fdc707edaee79994df174ca98968d07228c | ivy-liu/re-Automation | /0311_01.py | 980 | 4.34375 | 4 | #算术运算符
a=21
b=10
c=0
c=a+b
print("a+b=",c)
c=a//b
print("a//b=",c)#取整除 - 返回商的整数部分(向下取整)
c=a/b
print("a/b=",c)
c=a**b
print("a**b=",c)
c=a*b
print("a*b=",c)
#条件语句,判断
jin=90
qu=75
ts=(jin-qu)/qu*100
print('小明成绩提升百分点:%.1f' % ts+'%')
flag=False
name="xiaoming"
if name=='小明'or'xiaoming':
flag=True
print('是的,对... | false |
39f360ae4828952b4da6249bacfadda4671911d2 | aryashah0907/Arya_GITSpace | /Test_Question_2.py | 454 | 4.40625 | 4 | # 3 : Write a Python program to display the first and last colors from the following list.
# Example : color_list = ["Red","Green","White" ,"Black"].
# Your list should be flexible such that it displays any color that is part of the list.
from typing import List
color_list = ["Red", "Green", "White", "Black", "Pink", ... | true |
ac9de1f5797579203874fef062220415cc7a3c13 | cvhs-cs-2017/sem2-exam1-LeoCWang | /Function.py | 490 | 4.375 | 4 | """Define a function that will take a parameter, n, and triple it and return
the result"""
def triple(n):
n = n * 3
return (n)
print(triple(5))
"""Write a program that will prompt the user for an input value (n) and print
the result of 3n by calling the function defined above. Make sure you include
the neces... | true |
1ce5245bebfd0e12605f9a1fac47a3fd985c080c | luffysk/coderesources | /python/1.base/11.str_format.py | 255 | 4.28125 | 4 | # 格式化输出字符串有三种方式
# 第一种
a = 'str'
b = 'str2'
print('a is ' + a + ', b is ' + b)
# 第二种
a = 's1'
b = 's2'
print('a is %s, b is %s' % (a, b))
# 第三种, 推荐此种
a = 'fstr'
b = 'fstr2'
print(f'a is {a}, b is {b}') | false |
9040c3eeb0c6b4bf7cdff293644912e879a07eee | dexterpengji/practice_python | /fishC/038_class_inherit.py | 919 | 4.15625 | 4 | # -*- coding: utf-8 -*
import random as r
class Fish:
def __init__(self):
self.x = 100
self.y = 100
def move(self):
self.x += r.randint(-5,5)
self.y += r.randint(-5,5)
print("position",self.x,self.y)
class Gold_Fish(Fish):
def __init__(self):
#Fish.__init__(self) # way 1
super().__i... | false |
1712892d8d87ea7ffc0532bedeb31afd088c47bc | damianserrato/Python | /TypeList.py | 693 | 4.46875 | 4 | # Write a program that takes a list and prints a message for each element in the list, based on that element's data type.
myList = ['magical unicorns',19,'hello',98.98,'world']
mySum = 0
myString = ""
for count in range(0, len(myList)):
if type(myList[count]) == int:
mySum += myList[count]
elif type(m... | true |
2d5273b86616f827bed2a4496b4fe6854acf5ac3 | damianserrato/Python | /FindCharacters.py | 388 | 4.15625 | 4 | # Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character.
word_list = ['hello','world','my','name','is','Anna']
char = 'o'
newList = []
for count in range(0, len(word_list)):
for c in word_list[count]:
if ... | true |
8a833841f94024fa0c6e5185a78d4b404716ba8c | Hikareee/Phyton-exercise | /Programming exercise 1/Area of hexagon.py | 266 | 4.3125 | 4 | import math
#Algorithm
#input the side
#calculate the area of the hexagon
#print out the area
#input side of hexagon
S = eval(input("input the side of the hexagon: "))
#area of the hexagon
area=(3*math.sqrt(3)*math.pow(S,2))/2.0
#print out the area
print (area) | true |
51150a87bda43b7f1a9c1787005001a034b73232 | rvrn2hdp/informatorio2020 | /FuncionesComp/func9.py | 1,182 | 4.21875 | 4 | '''Ejercicio 9: ¿Un string representan un entero?
En este ejercicio escribirá una función llamada es_entero que determina
si los caracteres en una cadena representan un número entero válido.
Al determinar si un string representa un número entero, debe ignorar cualquier
espacio en blanco inicial o final. Una vez que... | false |
9d0d3dd9396aa1135f9d3f84d5d6ba7c76c3cffa | rvrn2hdp/informatorio2020 | /FuncionesComp/func6.py | 731 | 4.125 | 4 | '''Ejercicio 6: Centrar una cadena en la terminal
Escriba una función que tome una cadena de caracteres como primer parámetro
y el ancho de la terminal en caracteres como segundo parámetro.
Su función debe devolver una nueva cadena que consta de la cadena original
y el número correcto de espacios iniciales para que... | false |
2580e93a9665e26326c9478950be89a27e1709e0 | rvrn2hdp/informatorio2020 | /Desafios1/desafiorepetitiva5.py | 1,350 | 4.125 | 4 | """Se está desarrollando un sistema de control de vehículos
desde donde se han tirado restos de basura a la vía pública.
Para ello la ciudad cuenta con sistemas de monitoreo de patentes
que devuelve 3 letras y un valor numérico de 5 dígitos a la Central
con el siguiente significado:
3 letras: Correspondientes a... | false |
7633108013a04f6e5ef0c4287c65002bd12e70c6 | rvrn2hdp/informatorio2020 | /FuncionesComp/func10.py | 1,074 | 4.21875 | 4 | '''Ejercicio 10: Precedencia del operador
Escriba una función llamada precedencia que devuelve un número entero
que representa la precedencia de un operador matemático.
Una cadena que contiene el operador se pasará a la función como su único parámetro.
Su función debe devolver 1 para + y -, 2 para * y /, y 3 para ˆ... | false |
e74ddfcc4b04789ce051adee50598c592547d7fb | congyingTech/Basic-Algorithm | /medium/hot100/2-add-two-numbers.py | 2,341 | 4.25 | 4 | """
给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。
请你将两个数相加,并以相同形式返回一个表示和的链表。
你可以假设除了数字 0 之外,这两个数都不会以 0 开头。
输入:l1 = [2,4,3], l2 = [5,6,4]
输出:[7,0,8]
解释:342 + 465 = 807.
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/add-two-numbers
解题思路:
每个数位都是逆序的,所以可以从头遍历两个链表,把两个链表的值相加
"""
# Definition for sing... | false |
070b897a2f9365ae21c150490d0949a4b3d47960 | congyingTech/Basic-Algorithm | /data_structure/3.directed-graph.py | 1,586 | 4.21875 | 4 | # encoding:utf-8
"""
问题描述:有向(可能有环图)图
"""
class DirectedGraph(object):
def __init__(self,vertices):
self.vertices = vertices
self.graph = [[0]*self.vertices for i in range(self.vertices)]
def add_edges(self, src, dest):
self.graph[src][dest] = 1
def print_graph(self):
for i ... | false |
30698c43e3ce59495f42fb6d0bff2c5cce4a525b | congyingTech/Basic-Algorithm | /getOffer/17.merge-two-sorted-lists.py | 2,753 | 4.125 | 4 | # encoding:utf-8
"""
问题描述:合并两个上升排序的链表,使之合并后有序
解决方案:递归的方案,
非递归的方案:先比较第一个节点,节点小的那一个作为主链表,把循环遍历另一条链表,把其中的元素插入到主链表中
在主链表设置两个指针:mainHead/mainNext,次链表只有secondHead一个指针,做次链表单节点插入主链表的动作。
"""
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
cla... | false |
0fd112e01e2545fb78af3211f1f1d12dd0159d24 | Lukhanyo17/Intro_to_python | /Week7/acronym.py | 538 | 4.15625 | 4 | def acronym():
acro = ''
ignore = input("Enter words to be ignored separated by commas:\n")
title = input("Enter a title to generate its acronym:\n")
ignore = ignore.lower()
ignore = ignore.split(', ')
title = title.lower()
titleList = title.split()
titleList.append("end"... | true |
a51357020c8422857735e9092ed7b35fa3992060 | samvelarakelyan/ACA-Intro-to-python | /Practicals/Practical5/Modules/pretty_print.py | 667 | 4.25 | 4 |
def simple_print(x:int):
"""
The function gets an integer and just prints it.
If type of function argument isn't 'int' the function print 'Error'.
"""
if isinstance(x,int):
print("Result: %d" %x)
else:
print("Error: Invalid parametr! Function parametr should be integer")
def... | true |
76e9d759bbee0884ff88b287e491ae097580f41b | imsk003/Python | /reverse_words.py | 224 | 4.25 | 4 | def reverseWords(input):
inputWords = input.split(" ")
inputWords=inputWords[-1::-1]
output = ' '.join(inputWords)
return output
if __name__ == "__main__":
input = 'hello python'
print(reverseWords(input))
| false |
6ca26100985fc23524b13578e97cde54a42f2f70 | twhay/Python-Scripts | /Dice Simulator.py | 509 | 4.21875 | 4 | # Python Exercise - Random Number Generation - Dice Generator
# Import numpy as np
import numpy as np
# Set the seed
np.random.seed(123)
# Generate and print random float
r = np.random.rand()
print(r)
# Use randint() to simulate a dice
dice = np.random.randint(1,7)
print(dice)
# Starting step
step = 50
# Finish th... | true |
6065b6d6ecb45e18d532a5a3bcf765851e97d1eb | iMeyerKimera/play-db | /joins.py | 929 | 4.34375 | 4 | # -*- coding: utf-8 -*-
# joining data from multiple tables
import sqlite3
with sqlite3.connect("new.db") as connection:
c = connection.cursor()
# retrieve data
c.execute("""
SELECT population.city, population.population,
regions.region FROM population, regions
WHERE population.city = r... | true |
2909e9da710ee8da8f33f9c67687f697c8db7385 | lorenanicole/abbreviated-intro-to-python | /exercises/guessing_game_two.py | 1,143 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import random
"""
ITERATION THREE: Now that you have written a simple guessing
game, add some logic in that determines if the game is over
when either:
* user has correctly guesses the number
* user has reached 5 guesses
Let's use tw... | true |
b9a599544b5dbf2e0cf855cfe9b848f3fec098eb | juliakyrychuk/python-for-beginners-resources | /final-code/oop/car.py | 777 | 4.25 | 4 | class Car:
"""Represents a car object."""
def __init__(self, colour, make, model, miles=0):
"""Set initial details of car."""
self.colour = colour
self.make = make
self.model = model
self.miles = miles
def add_miles(self, miles):
"""Increase miles by given n... | true |
70504fde426af3e446033709871f1d5219844539 | Farmerjoe12/PythonLoanLadder | /pythonLoanLadder/model/Loan.py | 1,234 | 4.1875 | 4 | import numpy
import math
class Loan:
""" A representation of a Loan from a financial institution.
Loans are comprised of three main parts, a principal
or the amount for which the loan is disbursed, an interest rate
because lending companies are crooked organizations which charge
y... | true |
0a0558e50b0bd8f9f41348596aae5c06ac66c7e7 | LIZETHVERA/python_crash | /chapter_7_input_while/parrot.py | 788 | 4.3125 | 4 | message = input ("Tell me something, and i will repetar it back to you: ")
print (message)
name = input ("please enter your name: ")
print ("hello, "+ name + "!")
prompt = "If you tell us who you are, we can personalize the messages you see"
prompt += "\nWhat is your first name?"
name = input (prompt)
print ("\nHe... | true |
f25f1e4333a6c8a4ef1f22eb18a430ad3be862ab | olsgaard/adventofcode2019 | /day01_solve_puzzle1.py | 801 | 4.5 | 4 | """
Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
For example:
For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2.
For a mass of 14, dividing by 3 and rounding do... | true |
a00d0f8ef6e6f6ba51524c3c0309ebe863ab9581 | osmandi/programarcadegames | /Capítulo 4: Adivianzas con números aleatorios y bucles/ejemplos_de_while.py | 1,633 | 4.21875 | 4 | """
# Sample Python/Pygame Programs
# Simpson College Computer Science
# http://programarcadegames.com/
# http://simpson.edu/computer-science/
"""
# Podemos emplear un bucle while allí donde, también, podríamos usar un bucle for:
i = 0
while i < 10:
print(i)
i = i + 1
# Es lo mismo que:
for i in range(10):
... | false |
77da7fdefd5a5ddc68ce5652094f4ad1b627d3a3 | stefantoncu01/Pizza-project | /pizza_project.py | 2,981 | 4.125 | 4 | class Pizza:
"""
Creates a pizza with the attributes: name, size, ingredients
"""
def __init__(self, name, size):
self.name = name
self.size = size
self.ingredients = None
@property
def price(self):
"""
Calculates the price based on size and i... | true |
e378f29d1bd2dbf43f88f0a0d2333f811150be2f | scvetojevic1402/CodeFights | /CommonCharCount.py | 660 | 4.15625 | 4 | #Given two strings, find the number of common characters between them.
#Example
#For s1 = "aabcc" and s2 = "adcaa", the output should be
#commonCharacterCount(s1, s2) = 3.
#Strings have 3 common characters - 2 "a"s and 1 "c".
def commonCharacterCount(s1, s2):
num=0
s1_matches=[]
s2_matches=[]
f... | true |
c2d0e8489e7783edf1fc6a5548825a77da605e57 | dayanandtekale/Python_Basic_Programs | /basics.py | 1,303 | 4.125 | 4 | #if-else statements:
#score=int(input("Enter your score"))
#if score >=50:
# print("You have passed your exams")
# print("Congratulations")
#if score <50:
# print("Sorry,You have failed Exam")
#elif statements:
#score=109
#if score >155 or score<0:
# print("Your score is invalid")
#elif s... | true |
49063cf5cbae4fc79e96e59d6dfd07178f16b211 | cxdy/CSCI111-Group4 | /project2/final.py | 597 | 4.40625 | 4 | # Find the distance between two points
# Class: CSCI 111 - Intro to Computer Science
# Group: Project Group 4
import math
# Ask for the 2 xy coordinates
x1 = float(input("Point #1 x-coord: "))
y1 = float(input("Point #1 y-coord: "))
x2 = float(input("Point #2 x-coord: "))
y2 = float(input("Point #2 y-coord: "))
# S... | false |
613a833ae062123c4f5a81af2e957fb28fea74cd | cxdy/CSCI111-Group4 | /project1/GroupProect1 BH.py | 1,054 | 4.40625 | 4 | firstname1 = input("Enter a first name: ")
college = input("Enter the name of a college: ")
business = input("Enter the name of a business: ")
job = input("Enter a job: ")
city = input("Enter the name of a city: ")
restaurant = input("Enter the name of a restaurant: ")
activity1 = input("Enter an activity: ")
activity2... | true |
10e396f5019fd198a588d543c6746a642867496c | DSR1505/Python-Programming-Basic | /04. If statements/4.05.py | 309 | 4.15625 | 4 | """ Generate a random number between 1 and 10. Ask the user to guess the number and print a
message based on whether they get it right or not """
from random import randint
x = randint(1,10)
y = eval(input('Enter a number between 1 and 10: '))
if(x == y):
print('You get it right')
else:
print('Try again') | true |
4c590e8a0ff2058228a40e521d4dc31b1978ee9e | DSR1505/Python-Programming-Basic | /02. For loops/2.14.py | 276 | 4.34375 | 4 | """ Use for loops to print a diamond. Allow the user to specify how high the
diamond should be. """
num = eval(input('Enter the height: '))
j = (num//2)
for i in range(1,num+1,2):
print(' '*j,'*'*i)
j = j - 1
j = 1
for i in range(num-2,0,-2):
print(' '*j,'*'*i)
j = j + 1 | true |
1ddc261cf174c109583fd0ead1f537673d29090a | athirarajan23/luminarpython | /regular expression/validation rules/rules with eg.py | 2,250 | 4.15625 | 4 | #rules used for pattern matching
# #1. x='[abc]' either a,b or c
#eg:
# import re
# x="[abc]"
# matcher=re.finditer(x,"abt cq5kz")
# for match in matcher:
# print(match.start())
# print(match.group())
#2. x='[^abc]' except abc
#eg:
# import re
# x="[^abc]"
# matcher=re.finditer(x,"abt cq5kz")
# for match in ... | false |
af8f6a301de6b7bcf12dce96898944ec99928b6d | vickylee745/Learn-Python-3-the-hard-way | /ex30.py | 925 | 4.46875 | 4 |
people = 30
cars = 40
trucks = 15
if cars > people:
print("We should take the cars.")
elif cars < people:
print("We should not take the cars.")
else:
print("We can't decide.")
if trucks > cars:
print("That's too many trucks.")
elif trucks < cars:
print("Maybe we could take the trucks.")
else:
... | true |
8684285a1e580d4249b60a838d4eec6bc85222db | kkashii/Python-NRS568 | /Class 2/Challenge2.2.py | 391 | 4.125 | 4 | # List Overlap
list_a = ['dog', 'cat', 'rabbit', 'hamster', 'gerbil']
list_b = ['dog', 'hamster', 'snake']
def overlap(list_a, list_b):
list_c=[value for value in list_a if value in list_b]
return list_c
print(overlap(list_a, list_b))
for x in list_a:
if x not in list_b:
pri... | false |
33dffd72dbc71e9bf6d0669e3570557c5102418d | Chyi341152/pyConPaper | /Concurrency/codeSample/Part4_Thread_Synchronuzation_Primitives/sema_signal.py | 1,236 | 4.65625 | 5 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# sema_signal.py
#
# An example of using a semaphore for signaling between threads
import threading
import time
done = threading.Semaphore(0) # Resource control.
item = None
def producer():
global item
print("I'm the producer and I produce data.")
... | true |
3df062d10ddff464e32ed814ddd2012dc97d326d | DataKind-DUB/PII_Scanner | /namelist.py | 1,231 | 4.25 | 4 | #!/usr/bin/python3 -i
"""This file contain functions to transform a list of names text file to a set
"""
def txt_to_set(filename):
"""(str) -> set()
Convert a text file containing a list of names into a set"""
res = set()
with open(filename,'r') as f:
for line in f:
l = line.strip().split()
for item in l:... | true |
061f34d0ae2055ecaa8c26aaa5ef2d43dcb473cf | tzpBingo/github-trending | /codespace/python/tmp/strings.py | 661 | 4.15625 | 4 | """
字符串常用操作
Version: 0.1
Author: 骆昊
Date: 2018-02-27
"""
str1 = 'hello, world!'
print('字符串的长度是:', len(str1))
print('单词首字母大写: ', str1.title())
print('字符串变大写: ', str1.upper())
# str1 = str1.upper()
print('字符串是不是大写: ', str1.isupper())
print('字符串是不是以hello开头: ', str1.startswith('hello'))
print('字符串是不是以hello结尾: ', str1.end... | false |
307b9a3b8ac5d9d65ad3c9a834cabab1b51c6c62 | tzpBingo/github-trending | /codespace/python/tmp/example16.py | 1,731 | 4.25 | 4 | """
魔术方法
如果要把自定义对象放到set或者用作dict的键
那么必须要重写__hash__和__eq__两个魔术方法
前者用来计算对象的哈希码,后者用来判断两个对象是否相同
哈希码不同的对象一定是不同的对象,但哈希码相同未必是相同的对象(哈希码冲撞)
所以在哈希码相同的时候还要通过__eq__来判定对象是否相同
"""
class Student():
__slots__ = ('stuid', 'name', 'gender')
def __init__(self, stuid, name):
self.stuid = stuid
self.name = name
... | false |
9a049b0cd58d5c48f564591f9edb5ff6b19e1ae9 | Ishita46/PRO-C97-NUMBER-GUESSING-GAME | /gg.py | 551 | 4.25 | 4 | import random
print("Number Guessing Game")
Number = random.randint(1,9)
chances = 0
print("Guess a number between 1-9")
while chances < 5:
guess = int(input("Enter your guess"))
if guess == Number:
print("Congratulations you won!")
break
elif guess < Number:
print("Yo... | true |
36a5612ef360eeb868da742bc9f29f535cb3fb84 | saparia-data/data_structure | /geeksforgeeks/maths/2_celcius_to_fahrenheit.py | 852 | 4.5 | 4 | """
Given a temperature in celsius C. You need to convert the given temperature to Fahrenheit.
Input Format:
The first line of input contains T, denoting number of testcases. Each testcase contains single integer C denoting the temperature in celsius.
Output Format:
For each testcase, in a new line, output the temper... | true |
795bc9954ddcd5e52ad3477bf197c5bedd9a9650 | saparia-data/data_structure | /geeksforgeeks/linked_list/segregate_even_and_odd_nodes_in_linked_list_difficullt.py | 2,808 | 4.15625 | 4 | '''
Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list.
Also, keep the order of even and odd numbers same.
https://www.geeksforgeeks.org/segregate-even-and-odd-elements-in-a-linked-list/
'''
class Node: ... | true |
17d7ca663bf8697b79bd7824a49e561839818cf3 | saparia-data/data_structure | /pepcoding/dynamic_programming/4_climb_stairs_with_minimum_moves.py | 1,375 | 4.15625 | 4 | '''
1. You are given a number n, representing the number of stairs in a staircase.
2. You are on the 0th step and are required to climb to the top.
3. You are given n numbers, where ith element's value represents - till how far from the step you
could jump to in a single move. You can of-course fewer number of ste... | true |
fea46e295115747dfcc38e182eb865603b501e74 | saparia-data/data_structure | /pepcoding/recursion/1_tower_of_hanoi.py | 961 | 4.15625 | 4 | '''
1. There are 3 towers. Tower 1 has n disks, where n is a positive number. Tower 2 and 3 are empty.
2. The disks are increasingly placed in terms of size such that the smallest disk is on top and largest disk is at bottom.
3. You are required to
3.1. Print the instructions to move the disks.
3.2. from tower... | true |
60937f08311c74e6773fa09eaec056097efb9496 | saparia-data/data_structure | /pepcoding/generic_tree/17_is_generic_tree_symmetric.py | 1,776 | 4.1875 | 4 | '''
The function is expected to check if the tree is symmetric, if so return true otherwise return false.
For knowing symmetricity think of face and hand. Face is symmetric while palm is not.
Note: Symmetric trees are mirror image of itself.
Sample Input:
20
10 20 50 -1 60 -1 -1 30 70 -1 80 -1 90 -1 -1 40 100 -1 1... | true |
008b19ff7efc7fc9be540903c086a792aed6c0d2 | saparia-data/data_structure | /geeksforgeeks/maths/7_prime_or_not.py | 1,297 | 4.34375 | 4 | '''
For a given number N check if it is prime or not. A prime number is a number which is only divisible by 1 and itself.
Input:
First line contains an integer, the number of test cases 'T'. T testcases follow. Each test case should contain a positive integer N.
Output:
For each testcase, in a new line, print "Yes" i... | true |
3fb0fefa594130bd865c342d60d0f7ff34127f7f | saparia-data/data_structure | /geeksforgeeks/linked_list/4_Insert_in_Middle_of_Linked_List.py | 1,343 | 4.15625 | 4 | '''
Given a linked list of size N and a key. The task is to insert the key in the middle of the linked list.
Input:
The first line of input contains the number of test cases T. For each test case,
the first line contains the length of linked list N
and the next line contains N elements to be inserted into the linked... | true |
296acd0cb1655e3fd6d57e80b9bd72529ffb4ecc | saparia-data/data_structure | /geeksforgeeks/matrix/8_Boundary_traversal_matrix.py | 2,384 | 4.34375 | 4 | '''
You are given a matrix A of dimensions n1 x m1.
The task is to perform boundary traversal on the matrix in clockwise manner.
Input:
The first line of input contains T denoting the number of testcases. T testcases follow.
Each testcase two lines of input. The first line contains dimensions of the matrix A, n1 and... | true |
789288e7c8987df76436b463f7e8fa6f2d9b1a8a | saparia-data/data_structure | /geeksforgeeks/tree/6_height_of_binary_tree.py | 698 | 4.125 | 4 | '''
Hint:
1. If tree is empty then return 0
2. Else
(a) Get the max depth of left subtree recursively i.e.,
call maxDepth( tree->left-subtree)
(a) Get the max depth of right subtree recursively i.e.,
call maxDepth( tree->right-subtree)
(c) Get the max of max depths of left and ri... | true |
770ac8812cac09b77d0990edacc7fed78c612480 | saparia-data/data_structure | /geeksforgeeks/maths/1_absolute_value_solved.py | 1,062 | 4.375 | 4 | '''
You are given an interger I. You need to print the absolute value of the interger I.
Input Format:
The first line of input contains T, denoting number of testcases. Each testcase contains single integer I which may be positive or negative.
Output Format:
For each testcase, in a new line, output the absolute value... | true |
35030f181df15a7fb1ad550279aadc98a6baf954 | saparia-data/data_structure | /geeksforgeeks/sorting/11_Counting_Sort.py | 1,265 | 4.25 | 4 | '''
Given a string S consisting of lowercase latin letters, arrange all its letters in lexographical order using Counting Sort.
Input:
The first line of the input contains T denoting number of testcases.Then T test cases follow. Each testcase contains positive integer N denoting the length of string.The last line of i... | true |
d476ee8753b489e9a160984ca1a71e49eed86f2d | saparia-data/data_structure | /geeksforgeeks/array/3_majority_in_array_solved.py | 2,439 | 4.40625 | 4 | '''
We hope you are familiar with using counter variables. Counting allows us to find how may times a certain element appears in an array or list.
You are given an array arr[] of size N. You are also given two elements x and y. Now, you need to tell which element (x or y) appears most in the array.
In other words, pri... | true |
8f2e60355dfe700cfde7b30b569d431ce959b7e5 | saparia-data/data_structure | /geeksforgeeks/strings/6_check_if_string_is_rotated_by_two_places.py | 1,986 | 4.21875 | 4 | '''
Given two strings a and b. The task is to find if the string 'b' can be obtained by rotating another string 'a' by exactly 2 places.
Input:
The first line of input contains an integer T denoting the number of test cases.
Then T test cases follow. In the next two lines are two string a and b respectively.
Output:
... | true |
b6bf8024d4250adafec321751f4317591391a1c9 | saparia-data/data_structure | /geeksforgeeks/tree/26_Foldable_Binary_Tree.py | 1,007 | 4.4375 | 4 | '''
Given a binary tree, find out if the tree can be folded or not.
-A tree can be folded if left and right subtrees of the tree are structure wise mirror image of each other.
-An empty tree is considered as foldable.
Consider the below tree: It is foldable
10
/ \
7 15
\ /
9 1... | true |
b05134767f55b443af849edfa92df6ae5937491b | saparia-data/data_structure | /geeksforgeeks/matrix/11_Reversing_the _columns_Matrix.py | 1,919 | 4.40625 | 4 | '''
You are given a matrix A of dimensions n1 x m1.
The task is to reverse the columns(first column exchanged with last column and so on).
Input:
The first line of input contains T denoting the number of testcases. T testcases follow.
Each testcase two lines of input. The first line contains dimensions of the matrix... | true |
e76d09cc97d9d6d8677ae32ba52425ec5fa34a0f | cginiel/si507 | /lecture/week3/2020.01.21.py | 2,638 | 4.46875 | 4 | # # import datetime
# # date_now = datetime.datetime.now()
# # print(date_now.year)
# # print(date_now.month)
# # print(date_now.day)
# # print(type(date_now))
# # class is a type of thing, object is a particular instance of that class!!!!!
# # BEGIN CLASS DEFINITION
# """
# class Dog:
# def __init__(self, nm, ... | true |
8288e5fd26c497ab9b285289e0218d5ab2cba302 | jpchato/pdx_code | /programming_101/unit_3/exercise_1.py | 1,026 | 4.15625 | 4 | import math
# 1.1
tri_side_1 = 1
tri_side_2 = 2
hypotenuse = (tri_side_1*tri_side_1 + tri_side_2*tri_side_2)
def triangle_perimeter(tri_side_1, tri_side_2, hypotenuse):
print(tri_side_1 + tri_side_2 + hypotenuse)
return tri_side_1 + tri_side_2 + hypotenuse
# 1.2
def triangle_area(tri_side_2, tri_side_1):
... | false |
1d07ee37723cc22548908a0a75b02facb6664100 | alexbenko/pythonPractice | /classes/magic.py | 787 | 4.125 | 4 | #how to use built in python methods like print on custom objects
class Car():
speed = 0
def __init__(this,color,make,model):
this.color = color
this.make = make
this.model = model
def __str__(this):
return f'Your {this.make},{this.model} is {this.color} and is currently going {this.speed} mph'
... | true |
b1ec77cac2953516ced165066ea926e67f236c14 | xenron/sandbox-github-clone | /qiwsir/algorithm/delete_space.py | 508 | 4.375 | 4 | #! /usr/bin/env python
#coding:utf-8
#删除一个字符串中连续超过一次的空格。
def del_space(string):
split_string = string.split(" ") #以空格为分割,生成list,list中如果含有空格,则该空格是连续空格中的后一个
string_list = [i for i in string if i!=""]
result_string = " ".join(string_list)
return result_string
if __name__=="__main__":
one_str = "He... | false |
b821bd68661a42ae46870bd01178d181656149e6 | xenron/sandbox-github-clone | /qiwsir/algorithm/divide.py | 2,005 | 4.125 | 4 | #! /usr/bin/env python
#coding:utf-8
def divide(numerator, denominator, detect_repetition=True, digit_limit=None):
# 如果是无限小数,必须输入限制的返回小数位数:digit_limit
# digit_limit = 5,表示小数位数5位,注意这里的小数位数是截取,不是四舍五入.
if not detect_repetition and digit_limit == None:
return None
decimal_found = False
... | true |
465074ef23a66b649ac36eb6a259c9ace2732cb3 | YYYYMao/LeetCode | /374. Guess Number Higher or Lower/374.py | 1,424 | 4.15625 | 4 | 374. Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows:
I pick a number from 1 to n. You have to guess which number I picked.
Every time you guess wrong, I ll tell you whether the number is higher or lower.
You call a pre-defined API guess(int num) which returns 3 possible results (-1... | true |
b7cfe79cf0003bdb6d174d1471fbb672b0700b7f | codeAligned/interview_challenges | /sort_and_search/binary_search.py | 442 | 4.25 | 4 | def binary_search(iterable, target):
"""Determine if target value is in sorted iterable containing numbers"""
sorted_iterable = sorted(iterable)
low = 0
high = len(sorted_iterable) - 1
while low <= high:
midpoint = (high + low) // 2
if sorted_iterable[midpoint] == target:
return True
elif sorted_iterable[... | true |
c92ba78a30f78a134befad3de91f7572a201b1ef | szk0139/python_tutorial_FALL21 | /mysciW4/readdata.py | 1,018 | 4.1875 | 4 |
def read_data(columns, types = {}, filename= "data/wxobs20170821.txt"):
"""
Read data from CU Boulder Weather Stattion data file
Parameters:
colums: A dictonary of column names mapping to column indices
types: A dictonary of column names mapping to the types to which to convert each colum... | true |
9b34c6cc778d0a45f819a5667308a2e4f5f7f1f8 | Stepancherro/Algorithm | /stack.py | 1,879 | 4.1875 | 4 | # -*- encoding: utf-8 -*-
# Stack() creates a new stack that is empty.
# It needs no parameters and returns an empty stack.
# push(item) adds a new item to the top of the stack.
# It needs the item and returns nothing.
# pop() removes the top item from the stack.
# It needs no parameters and returns the item.... | true |
5b7ad9bbd58b59d7e7319bad5d970b5dbba1a529 | moha0825/Personal-Projects | /Resistance.py | 1,018 | 4.375 | 4 | # This code is designed to have multiple items inputted, such as the length, radius, and
# viscosity, and then while using an equation, returns the resistance.
import math
def poiseuille(length, radius, viscosity):
Resistance = (int(8)*viscosity*length)/(math.pi*radius**(4))
return Resistance
def main():
... | true |
bad4bb04bb518a8b45e3c0e75dabde665ef5d942 | jojadev/simpsons-test | /main.py | 383 | 4.15625 | 4 | name = input("Who is your favourite Simpson household member? ").capitalize()
if name == 'Homer':
print("You the man Homer!")
elif name == 'Marge':
print("Way to go mom!")
elif name == 'Lisa':
print("Eww, Lisa!")
elif name == 'Maggie':
print("What's up you cool baby?")
else:
print("I'm Bart Simpson... | false |
d0a53a4ca42e65bb86f1e4453bdfe747ea8227ee | AmineNeifer/holbertonschool-interview | /0x19-making_change/0-making_change.py | 578 | 4.25 | 4 | #!/usr/bin/python3
""" Contains makeChange function"""
def makeChange(coins, total):
"""
Returns: fewest number of coins needed to meet total
If total is 0 or less, return 0
If total cannot be met by any number of coins you have, return -1
"""
if not coins or coins is None:
re... | true |
3b2c0d8d806dcc4b73a80bf0564a77f77b906b67 | laurenhesterman/novTryPy | /TryPy/trypy.py | 1,832 | 4.5625 | 5 | #STRINGS
# to capitalize each first letter in the word use .capitalize() method, with the string before .capitalize
characters = "rick"
print characters.capitalize()
#returns Rick
#returns a copy of the whole string in uppercase
print characters.upper()
#returns RICK
#.lower() returns a copy of the string converted ... | true |
017ccb38921399323ccb3c169a50063b3057a118 | Alex-Reitz/Python_SB | /02_weekday_name/weekday_name.py | 566 | 4.25 | 4 | def weekday_name(day_of_week):
"""Return name of weekday.
>>> weekday_name(1)
'Sunday'
>>> weekday_name(7)
'Saturday'
For days not between 1 and 7, return None
>>> weekday_name(9)
>>> weekday_name(0)
"""
i = 0
weekdays = ["Sunday", "Monday", "Tuesd... | true |
5c39c42c7787b07e51728b67855c4f58fa98fd0f | leios/OIST.CSC | /hello_world/python/hello_world.py | 788 | 4.15625 | 4 | #-------------hello_world.py---------------------------------------------------#
#
# In most traditional coding courses, they start with a simple program that
# outputs "Hello World!" to the terminal. Luckily, in python... this is pretty
# simple. In fact, it's only one line (the line that follows this long comment).#... | true |
53c935628a3bcee64d664a7304417cc509031e12 | LittltZhao/code_git | /342_Power_of_Four.py | 202 | 4.125 | 4 | # -*- coding:utf-8 -*-
#判断一个数是否为4的幂数
def isPowerOfFour(num):
return num>0 and (num&(num-1))==0 and (num-1)%3==0#(num&(num-1))==0判断是否为2的幂
print isPowerOfFour(16)
| false |
ec4030fa14128f11e3354b789203588dddf333ff | flashlightli/math_question | /leetcode_question/mid_question/29_Divide_Two_Integers.py | 2,103 | 4.125 | 4 | """
给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符(取余)。
返回被除数 dividend 除以除数 divisor 得到的商。
整数除法的结果应当截去(truncate)其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2
示例 1:
输入: dividend = 10, divisor = 3
输出: 3
解释: 10/3 = truncate(3.33333..) = truncate(3) = 3
示例 2:
输入: dividend = 7, divisor = -3
输出: -2... | false |
cbabb745d29b004c700fa4edfa9c16c1d4424d5a | flashlightli/math_question | /leetcode_question/mid_question/114_Flatten_Binary_Tree_to_Linked_List.py | 1,404 | 4.25 | 4 | """
给定一个二叉树,原地将它展开为一个单链表。
例如,给定二叉树
1
/ \
2 5
/ \ \
3 4 6
将其展开为:
1
\
2
\
3
\
4
\
5
\
6
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
"""
class TreeNode:
def __init... | false |
457ac15fcea68d766279c72296236295daa866d1 | Hanlen520/Leetcode-4 | /src/114. 二叉树展开为链表.py | 1,746 | 4.1875 | 4 | """
给定一个二叉树,原地将它展开为链表。
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# 其实就是先序遍历,下面采用迭代的方法
class Solution:
def flatten(self, root: TreeNode) -> None:
"""
Do not return anything, modify root... | false |
4508866832b2578a43788e47e00c3e9781bb6b44 | cesarmarroquin/blackjack | /blackjack_outline.py | 2,089 | 4.1875 | 4 | """
I need to create a blackjack Game. In blackjack, the player plays against the dealer. A player can win in three
different ways. The three ways are, the player gets 21 on his first two cards, the dealer gets a score higher than 21,
and if the player's score is higher than the dealer without going over 21. The deale... | true |
3883f41652fa43d96be453f5d5434aead2cf3ead | mohit131/python | /project_euler/14__Longest_Collatz_sequence.py | 1,095 | 4.21875 | 4 | '''The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing ... | true |
c7404efed6d6384bcf49df15f0dc508c01a7fef5 | mohit131/python | /project_euler/9__Special_Pythagorean_triplet.py | 490 | 4.125 | 4 | '''A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.'''
for m in range(1,5000):
for n in range(1,500):
if m>n:
a=m*... | false |
5a97036b637ec09c393d8fae0178db26b3db1603 | adidrmwan/basic-python | /leapYear.py | 503 | 4.1875 | 4 | def is_leap(year):
leap = False
leap_year = year % 4
leap_year_divided_100 = year % 100
leap_year_divided_400 = year % 400
if leap_year == 0:
leap = True
if leap_year_divided_100 == 0:
leap = False
if leap_year_divided_400 == 0:
leap = ... | false |
df01dc415a7750095dcd99b64690469a7c41b983 | Chittadeepan/P342 | /lab5_q2.py | 1,328 | 4.1875 | 4 | #importing everything from math module
from math import *
#importing all functions from library
from library import *
#poly_f(x) function
def poly_f(x,coeff,n):
sum=0
for i in range(1,n+1):
sum=sum+coeff[i-1]*x**(n-i)
return sum
#main program
def main():
#initialising fi... | true |
e537efac5d4877eb9b8516a4b02cee19f7985323 | PratheekH/Python_sample | /comp.py | 201 | 4.28125 | 4 | name=input("Enter your name ")
size=len(name)
if size<3:
print("Name should be more than 3")
elif size>50:
print("Name should not be more than 50")
else:
print("Name looks fine") | true |
134a72d4bd4ca94b8e3a0d2d7c5a4f6b83bf9480 | cjrzs/MyLeetCode | /重要的算法模板/排序算法模板/冒泡排序.py | 667 | 4.28125 | 4 | """
coding: utf8
@time: 2020/12/8 17:18
@author: cjr
@file: 冒泡排序.py
"""
# 冒泡排序使用当前元素与下一个元素做比较,把符合条件的后移一位或者不动,
# 这样每次都会把最大或者最小的数放在最后一个位置。
# 重复这种排序思路。就可以从后到前的排序好数组。
def bubble_sort(nums):
n = len(nums)
for i in range(n - 1):
for j in range(n - i - 1):
if nums[j] > nums[j + 1]:
... | false |
3f9f28e504e80d7a04fb13f7750d12c873a063a0 | xdyxiang/pythonlearn | /python_base/digui.py | 574 | 4.15625 | 4 | # 遍历一个盘符下的所有文件(包括子文件夹、文件)
import os
def getFile(path):
try:
filelist = os.listdir(path) # 得到该文件夹下的所有文件
for file in filelist:
file = os.path.join(path, file) # 将文件名和路径结合起来
if os.path.isdir(file):
getFile(file) # 在这里如果判断一个文件是文件夹,那么就会再次调用自己
... | false |
2a8ea1f95001015fba07fc2130024b5c6a8375c7 | aashishah/LocalHackDay-Challenges | /EncryptPassword.py | 702 | 4.28125 | 4 | #Using Vignere Cipher to encrpt password of a user using a key that is private to the user.
def encrypt(password, key):
n = len(password)
#Generate key
if len(key) > n:
key = key[0:n]
else:
key = list(key)
for i in range(n - len(key)):
key.append(key[i % len(key)... | true |
15c76b453894e5eb09fcaa195a0a8a66351b1048 | Karlo5o/rosalind_problems | /RNA.py | 700 | 4.1875 | 4 | """
An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'.
Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing all occurrences of 'T' in t with 'U' in u.
Given: A DNA string t having length at most 1000 nt.
Return: The transcribed RNA... | true |
d6c9481fd67e920623b9c3ac06f98d0051db1c95 | SaulAlekss/clienteservidor | /listas.py | 1,328 | 4.5625 | 5 | def main():
# Una lista es una estructura de datos en python
# # La ventaja aceptan datos de tipos distintos
# # Creamos una lista
lista = [1,23.01, False, "hola lista", "A",[-1,-5, "hola", 0.0], -12,"A"]
# Lista Vacia
listaVacia = []
# Accesando a elementos de la lista
for elemento in l... | false |
d516d08d9c1af9bce8e845f69552a45377b6696b | marcusiq/w_python | /greeting.py | 1,570 | 4.4375 | 4 |
"""
Generally. There is no method overloading in python.
Overloading in other languages occurs when two methods have the same name, but different numbers of arguments.
In python, if you give more than one definition using the same name,
the last one entered rules, and any previous definitions are ignored.
"""
# Her... | true |
0db7eaa487bf54eb30f885b7baf11d93dfd6eabd | adamelliott1982/1359_Python_Benavides | /lab_04/1359-lab_04/drop_grade.py | 1,549 | 4.34375 | 4 | # Program: drop_grade.py
# Programmer: Adam Elliott
# Date: 02/26/2021
# Description: lab 4 - lists and for statements
########################################################
# create list of 5 grades and initialize
grades = [100, 80, 70, 60, 90]
# print report name – DROP LOWEST GRADE PROGRAM
print('DRO... | true |
8c2a6954dbcdb20dba141975559470e8b04ad921 | BenjaminLivingstone/fundamentos-python | /Otros/ejerciciopython1.py | 1,116 | 4.1875 | 4 | # GRUPO 2:
# Crea una funcion que dado una palabra diga si es palindroma o no.
def palindroma(palabra):
if ("hola"[::-1]==palabra):
print("La palabra",palabra,"es palindroma")
else:
print("La palabra",palabra,"NO es palindroma")
palabra="hola";
palindroma(palabra)
palabra="python"
print(palab... | false |
f371184ca3169f6fffe54319969f8ed2cf8ef2d6 | DishT/Python100- | /ex2.py | 297 | 4.1875 | 4 | def factorial(num):
number = 1
for i in range(int(num)):
number = (i+1)*number
print (number)
# 8! = 8 * 7!....... , 0! = 1
def factorial_2(num):
if num == 0 :
return 1
else:
return num * factorial_2(num-1)
def factorial_3(num):
num = input()
factorial(num)
print (factorial_2(num)) | false |
37ac60fa04dbaed484d77e43317c6069a26ad777 | marc-p-greenfield/tutor_sessions | /payment_system.py | 602 | 4.21875 | 4 | number_of_employees = int(input("How many employees do you want to enter:"))
total_payment = 0
for i in range(number_of_employees):
name = input('Please enter name: ')
hours = float(input('How many hours did you work this week? '))
rate = float(input('What is your hourly rate?'))
payment = 0
overt... | true |
a9f5a386203fe02efc9f289408744aef6e326c57 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch08/code_8_6.py | 392 | 4.125 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 8.6 집합의 항목에 접근하는 연산, 207쪽
#
numbers = {2, 1, 3}
if 1 in numbers: # 1이라는 항목이 numbers 집합에 있는가 검사
print("집합 안에 1이 있습니다.")
numbers = {2, 1, 3}
for x in numbers:
print(x, end=" ")
for x in sorted(numbers):
print(x, end=" ") | false |
f26e9e6bc1103c6c72fbe0fc72ed2435b62281ad | KishoreMayank/CodingChallenges | /Cracking the Coding Interview/Arrays and Strings/StringRotation.py | 349 | 4.1875 | 4 | '''
String Rotation:
Check if s2 is a rotation of s1 using only one call to isSubstring
'''
def is_substring(string, sub):
return string.find(sub) != -1
def string_rotation(s1, s2):
if len(s1) == len(s2) and len(s1) != 0:
return is_substring(s1 + s1, s2) # adds the two strings together and calls ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.