blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
bf261b5de36e283f220eb283a19c65f3f149cb5d | Malikazz/YegSecCTF_HSCTF_2020 | /Miscellaneous/Primes/main.py | 411 | 3.640625 | 4 |
preFlag = "fe7l1Owa85YA9g8CELs3F{H11s1o258p6hOo77di7Y0V83M1feBdNeP3QuS9G7LVjd8EZUei9NOi3p3p9jKcbiUYsy4zA6P88Y7NP73jiLFW4nl8m6xN3LcHttxA2ML73J68g2PtR52926v1sDi22KE9VhBT8kgc26581q2pP77_bTZ6XPBR3iRT7Jbo9YvsEUiXE6Lv4y790z5wu145p6W8Mc6l38tCBPfCq30P7fXD2652g1INKDF3EeUnXm6gLUWOZ9NKhFr19gAaVldd7FkjlMuqSaNW3E0BEt4_6y8C35pI6y7I... |
4029d3fa920da71e6414e9ff90e780fe845de319 | CharlesSAhn/python-datastructure-algorithm-review | /tree/priority_queues_with_binary_heaps.py | 1,964 | 4.3125 | 4 | # acts like a queue in thtat you dequeue an item by removing it from the front.
# however, in a priority queue the logical order of items inside a queue is determined by their priority
# The highest priority items are att the front of the queue and the lowest priority items are at the back.
# when you enqueue an item o... |
e7b263ea1e7ca8b1d2cc3b72c41ed9385d6b4800 | CharlesSAhn/python-datastructure-algorithm-review | /arrays/array_pair_sum.py | 1,048 | 3.90625 | 4 | # Given an integer array, output all the unique pairs that sum up to a specific value k
# Ex:
# pair_sum([1,2,3,4], 4)
# Return: (1,3), (2,2)
def pair_sum(num_list, k):
pair_counter = 0
used_number = []
for digit in num_list:
if k - digit in num_list and digit not in used_number:
pa... |
835af78b5e11128036c629bb1e68dea79c60be58 | CharlesSAhn/python-datastructure-algorithm-review | /arrays/largest_continuous_sum.py | 446 | 3.90625 | 4 | # Given an array of integers (positive and negative) find the largest continuous sum
# ex. large_cont_sum([1,2,-1,3,4,10,10,-10,-1]) -> 29
def large_cont_sum(array):
if len(array) == 0:
return 0
max_sum = current_sum = array[0];
for num in array[1:]:
current_sum = max(current_sum+ nu... |
19236dc3eb826671ec0c6f7168dda2e0871b11df | CharlesSAhn/python-datastructure-algorithm-review | /arrays/string_compression.py | 575 | 3.75 | 4 | # Given a string in the form 'AAAABBBBCCCCCDDEEEE' compress it to become 'A4B4C5D2E4'
# its ok for 'AAB' to return 'A2B1'
# case sensitive
def compress(s):
i = 0
j = 0
count = 0
response = ""
if len(s) == 0:
return ""
if len(s) == 1:
return s + "1"
while j < len(s):
... |
ff30a62b46b6ffd2677d09be3617c3f752e3ae69 | andrealmar/algorithms_and_data_structures | /data_structures/bst.py | 4,793 | 3.75 | 4 | # coding=utf8
from __future__ import print_function
class Node:
def __init__(self, label):
self.label = label #possui uma chave KEY, que no caso aqui eh o label
#precisamos ter os apontadores para os filhos da direita e da esquerda
self.left = None #apontador para o filho da esquerda
self.right = None #a... |
e4c75e6ea6c4b1aaac399554a777a5fc648cfecb | king-kenneth/cs20-class-demos-fall2018 | /text-analysis.py | 785 | 4.34375 | 4 | file_in = open("moby.txt")
text = file_in.read()
def count_letter_frequency(text, letter_to_count):
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
number_of_es = 0
total_letters = 0
for letter in text:
if letter in alphabet:
total_letters = total_letters + 1
... |
2d0650ccb2f87605720659422e184cabe6cb2e42 | king-kenneth/cs20-class-demos-fall2018 | /data_types_demo_p5.py | 218 | 3.90625 | 4 | # My First Program
# Dan Schellenberg
# Oct 15, 2018
high_number = input("How high should we count to? ")
high_number = int(high_number)
counter = 1
while (counter <= high_number):
print(counter)
counter = counter + 1
|
3430632ea8008d221e491d31b88c18d3008a8144 | king-kenneth/cs20-class-demos-fall2018 | /l-systems-p5.py | 1,232 | 3.9375 | 4 | import turtle
def apply_rules(letter):
"""Apply rules to a single letter, and return the result."""
if letter == "F":
return "FF"
elif letter == "X":
return "--FXF++FXF++FXF--"
else:
return letter
def process_string(original_string):
"""Apply rules to every letter in a stri... |
637aa08303023bfff306aad41e4ed7085e68ffa7 | king-kenneth/cs20-class-demos-fall2018 | /cross-drawing.py | 449 | 3.609375 | 4 | import turtle
def draw_cross(some_turtle, side_length):
for counter in range(4):
for side in range(2):
some_turtle.forward(side_length)
some_turtle.left(90)
some_turtle.forward(side_length)
some_turtle.right(90)
canvas = turtle.Screen()
aaron = turtle.Turtle()
aar... |
351154ed3e29eddf02af8cb44918e4945385a358 | king-kenneth/cs20-class-demos-fall2018 | /turtle-race-period5.py | 1,167 | 3.953125 | 4 | # Turtle Race
# Dan Schellenberg
# Nov 2, 2018
import turtle
import random
FINISH_LINE = 250
#setup screen
window = turtle.Screen()
window.bgcolor("red")
#setup turtles
ben = turtle.Turtle()
ben.color("pink")
ben.shape("turtle")
ben.penup()
afaq = turtle.Turtle()
afaq.color("yellow")
afaq.shape("turtle")
afaq.penu... |
f6daf8867eb9be90298331cbca3525bb22c16a14 | king-kenneth/cs20-class-demos-fall2018 | /time-demo-p5.py | 713 | 4.03125 | 4 | import turtle
import random
canvas = turtle.Screen()
bob = turtle.Turtle()
# draw a square to represent the area the turtle needs to stay inside
bob.speed(0)
bob.penup()
bob.goto(-100, -100) # sends bob to a specific coordinate
bob.pendown()
for side in range(4):
bob.forward(200)
bob.left(90)
bob.penup()
# ... |
034c76c82cce24aea59d6e3f3ffb724732ab4878 | king-kenneth/cs20-class-demos-fall2018 | /cryptoquip.py | 356 | 3.921875 | 4 | alphabet = "abcdefghijklmnopqrstuvwxyz"
cipher = "zktmqurejyxwaovcbsgnpdilhf"
message = "hello, how was your day?"
encrypted_message = ""
for letter in message:
location = alphabet.find(letter)
if location != -1:
new_character = cipher[location]
else:
new_character = letter
encrypted... |
4dcb7846ffce5e537d1bf109263eed30aee2f2e5 | king-kenneth/cs20-class-demos-fall2018 | /first_day_demo_period5.py | 144 | 3.640625 | 4 | counter = 1
while counter < 1001:
print(counter)
counter = counter + 1 #decrease the counter each iteration
print("Phew. All done!") |
6680c6c0c6eb2884421d94d69eda976af35f8e38 | ArtificialEvolvingWorld/neural-net-tests | /scripts/two-pendulum-math.py | 3,174 | 3.671875 | 4 | #!/usr/bin/env python2
import sympy
from sympy import diff
sympy.init_printing()
# From http://robotfantastic.org/total-derivatives-in-sympy.html
def difftotal(expr, diffby, diffmap):
"""Take the total derivative with respect to a variable.
Example:
theta, t, theta_dot = symbols("theta t theta_dot"... |
bdef2bbdc86c07b1f6be42a26fedbb7608a2e7cf | ypyao77/python-startup | /python-cookbook/04.iterator-generator/05-reversed-iter.py | 1,179 | 4.46875 | 4 | #!/usr/bin/env python3
# 4.5 反向迭代
# 你想反方向迭代一个序列
# 很多程序员并不知道可以通过在自定义类上实现 __reversed__() 方法来实现反向迭代。
class Countdown:
def __init__(self, start):
self.start = start
# Forward iterator
def __iter__(self):
n = self.start
while n > 0:
yield n
n -= 1
# Reverse... |
00f2f78e41970f74280ef25be761e3ad4ca5cb56 | ypyao77/python-startup | /startup/00.base/all.py | 385 | 3.703125 | 4 | n = []
print("n = %s" %(n))
print("bool(n) = %s" %(bool(n)))
n = [1, 2, 3, 4, 5]
print("n = %s" %(n))
print("bool(n) = %s" %(bool(n)))
print("all(i > 2 for i in n) = %s" %(all(i > 2 for i in n)))
print("all(i > 0 for i in n) = %s" %(all(i > 0 for i in n)))
print("any(i > 10 for i in n) = %s" %(any(i > 10 for i in n)... |
357d25e09b08ce7676b3f0695d3d6eb287ef49ae | ypyao77/python-startup | /python-cookbook/01.data-algorithm/12-max-counter.py | 1,922 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 怎样找出一个序列中出现次数最多的元素呢
if __name__ == "__main__":
# collections.Counter 类就是专门为这类问题而设计的,它甚至有一个有用的most_common() 方法直接给了你答案。
# 为了演示,先假设你有一个单词列表并且想找出哪个单词出现频率最高
words = [
'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes',
'the', 'eye... |
13c4eab7950d730e689410c91123ba6fcdd96b97 | ypyao77/python-startup | /fluent-python/02.array/14-plus.py | 1,655 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 对序列使用+和*
if __name__ == "__main__":
l = [1, 2, 3]
print("l: {0}".format(l))
print("l * 5: {0}".format(l * 5))
print("5 * 'abcd': {0}".format(5 * 'abcd'))
board = [['_'] * 3 for i in range(3)]
print("board: {0}".format(board))
# 错误
boa... |
011848a5a261a4d3d52b46190cb78d53609ef180 | ypyao77/python-startup | /python-cookbook/01.data-algorithm/14-sorted-obj.py | 1,679 | 3.53125 | 4 | #!/usr/bin/env python3
# 排序不支持原生比较的对象
# 你想排序类型相同的对象,但是他们不支持原生的比较操作
# 内置的 sorted() 函数有一个关键字参数 key ,可以传入一个 callable 对象给
# 它,这个 callable 对象对每个传入的对象返回一个值,这个值会被 sorted 用来排序
# 这些对象。比如,如果你在应用程序里面有一个 User 实例序列,并且你希望通过他们
# 的 user_id 属性进行排序,你可以提供一个以 User 实例作为输入并输出对应 user_id
# 值的 callable 对象。
class User:
def __init__(self,... |
a87010f64fa829a1d2ab14cad111c08aee79cb05 | ypyao77/python-startup | /python-cookbook/08.class-and-object/03-support-context.py | 3,740 | 3.921875 | 4 | #!/usr/bin/env python3
# 8.3 让对象支持上下文管理协议
# 你想让你的对象支持上下文管理协议 (with 语句)
# 为了让一个对象兼容 with 语句,你需要实现 __enter__() 和 __exit__() 方法。例如,考虑如下的一个类,它能为我们创建一个网络连接
from socket import socket, AF_INET, SOCK_STREAM
class LazyConnection:
def __init__(self, address, family=AF_INET, type=SOCK_STREAM):
self.address = addr... |
2b0f30a798078bc64a5e99eb9ee883ca3016b052 | ypyao77/python-startup | /fluent-python/02.array/21-numpy.py | 970 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ❶ 安装 NumPy 之后, 导入它(NumPy 并不是 Python 标准库的一部分)
import numpy
# 示例 2-22 对 numpy.ndarray 的行和列进行基本操作
if __name__ == "__main__":
# ❷ 新建一个 0~11 的整数的 numpy.ndarry, 然后把它打印出来。
a = numpy.arange(12)
print("a: \n", a)
print("type(a): ", type(a))
# ❸ 看看数组的维度, 它... |
0099af5d45b26973125364023a2c8a8e555f465f | ypyao77/python-startup | /startup/05.context/switch.py | 221 | 3.828125 | 4 | def f(x):
return {
'a': 1,
'b': 2,
}.get(x, 9) # 9 is default if x not found
print("f('a') = {0}".format(f('a')))
print("f('b') = {0}".format(f('b')))
print("f('c') = {0}".format(f('c')))
|
572a00982e625e8c10fc9ab62e505488280cc9b6 | ypyao77/python-startup | /fluent-python/07.decorator-and-closure/08-clockdeco-demo.py | 551 | 3.75 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 使用 clock 装饰器
import time
from clockdeco import clock
@clock
def snooze(seconds):
time.sleep(seconds)
@clock
def factorial(n):
return 1 if n < 2 else n*factorial(n-1)
@clock
def sum2(*arg):
return sum(arg)
if __name__=='__main__':
print('*' * 40, 'Ca... |
dfd03bddcd8d93338b2f1d797fb9b88eb2c38322 | ypyao77/python-startup | /python-cookbook/03.digit-date-time/15-string-2-datetime.py | 1,470 | 3.984375 | 4 | #!/usr/bin/env python3
# 3.15 字符串转换为日期
# 你的应用程序接受字符串格式的输入,但是你想将它们转换为 datetime 对象以便在上面执行非字符串操作。
# 使用 Python 的标准模块 datetime 可以很容易的解决这个问题。
from datetime import datetime
if __name__ == "__main__":
text = '2019-04-20'
print("text: ", text)
y = datetime.strptime(text, '%Y-%m-%d')
print("y: ", y)
z ... |
e4c8dab6694b568e75a7fa77612d3b1865bf5f46 | ypyao77/python-startup | /python-cookbook/03.digit-date-time/12-dt-transfer.py | 2,389 | 4.28125 | 4 | #!/usr/bin/env python3
# 3.12 基本的日期与时间转换
# 你需要执行简单的时间转换,比如天到秒,小时到分钟等的转换
if __name__ == "__main__":
# 为了执行不同时间单位的转换和计算,请使用 datetime 模块。比如,为了表示一个时间段,可以创建一个 timedelta 实例,
from datetime import timedelta
a = timedelta(days=2, hours=6)
b = timedelta(hours=4.5)
c = a + b
print("a: ", a)
print("... |
f18bcd7e1b2d5bad2d4073c0e47995398a064b9e | ypyao77/python-startup | /startup/06.class/iter2.py | 301 | 3.515625 | 4 | class A(object):
def __init__(self, num):
self.l = num
self.a = 0
def __iter__(self):
return self
def __next__(self):
self.a = self.a + 1
if self.a > self.l:
raise StopIteration()
return self.a
for x in A(5):
print(x)
|
7672e78085de57b04f0dcf91c356a73ba45b2cd4 | ypyao77/python-startup | /python-cookbook/03.digit-date-time/14-month-days-range.py | 2,026 | 4.15625 | 4 | #!/usr/bin/env python3
# 3.14 计算当前月份的日期范围
# 你的代码需要在当前月份中循环每一天,想找到一个计算这个日期范围的高效方法。
# 在这样的日期上循环并需要事先构造一个包含所有日期的列表。你可以先计算出开始日期和结束日期,
# 然后在你步进的时候使用 datetime.timedelta 对象递增这个日期变量即可。
# 下面是一个接受任意 datetime 对象并返回一个由当前月份开始日和下个月开始日组成的元组对象。
from datetime import datetime, date, timedelta
import calendar
def get_month_range(st... |
0340e5348a2467a0fe88656cfa30a1a051b56159 | ypyao77/python-startup | /python-cookbook/07.functions/06-lambda.py | 1,561 | 4.3125 | 4 | #!/usr/bin/env python3
# 7.6 定义匿名或内联函数
if __name__ == "__main__":
# 你想为 sort() 操作创建一个很短的回调函数,但又不想用 def 去写一个单行函数,而是希望通过某个快捷方式以内联方式来创建这个函数
add1 = lambda x, y: x + y
print("add(2, 3): ", add1(2, 3))
print("add('hello ', 'world'): ", add1('hello ', 'world'))
# 当一些函数很简单,仅仅只是计算一个表达式的值的时候,就可以使用 lambda ... |
302ebeb237ed1a6add049fc3deaff69981c95a20 | Gabriel-Dropout/PyBresenham | /point.py | 570 | 4.09375 | 4 | class point:
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, p):
return point(self.x + p.x, self.y + p.y)
def __sub__(self, p):
return point(self.x - p.x, self.y - p.y)
def __str__(self):
return "("+str(self.x)+", "+str(self.y)+")"
if __name__ =... |
18dba707ac435060650cded0e32eae2165838704 | Coreenee/algorithm-study | /tuuuuuuuna/문자열 압축.py | 1,182 | 3.859375 | 4 | def zip(s,i):
len_s = len(s)
index = 0
now_string = ""
new_string = ""
cnt=1
while index <=len_s:
# print(now_string)
next_string=s[index:index+i]
# print("next",next_string)
if now_string == next_string:
cnt += 1
else:
if cnt == 1:... |
b3d135ff70e41f05b1fb137cf6798f39823355dc | DuskEagle/Sortable-Coding-Challenge | /src/Product.py | 2,837 | 3.5625 | 4 | import re
from Normalizer import *
class Product:
def __init__(self, obj):
""" obj is a Python dictionary made from calling json.loads()
on a JSON string """
self.obj = obj
""" We don't match on product_name, but we need it for printing, so we
don't normalize ... |
85d1b7906647ee5ea351058bb1f9c8af280d1914 | MathMargarita/Bioinformatics-Rosalind | /Python/preostali_zadaci/BA1I.py | 4,554 | 3.796875 | 4 | """
A solution to a ROSALIND bioinformatics problem.
Problem Title: Find the Most Frequent Words with Mismatches in a String
Rosalind ID: BA1I
URL: http://rosalind.info/problems/ba1i
"""
def suffix(pattern):
#substring of pattern without first letter
return pattern[1:]
def HammingDistance(p, q):
... |
98c2609c072c19cfa4bbb3ac5b934afb1088b5ce | wruibo/tools | /python/security/utl/math/matrix.py | 11,150 | 4.15625 | 4 | """
multi-dimension array process methods, matrix storage by 2-dimension array like:
[
[v11, v12, ..., v1m]
[v21, v22, ..., v2m]
[ ... ]
[vn1, vn2, ..., vnm]
]
is an n*m dimension array.
"""
from . import array
def create(arr, *dim... |
60bd9ee1dee1d0a14b87dcb7750a6ef74517594d | wruibo/tools | /python/mlpy/sim.py | 9,583 | 3.671875 | 4 | #!/usr/bin/env python3
import math
'''
compute item similarity with collaborative filtering.
distance computing method:
1.cosine distance
2.euclidean distance
3.pearson correlation
4.tanimoto correlation(generalized jaccard)
method input & output:
... |
aa7d6f7b3447cc4154e08728e215167414c5cbe5 | wruibo/tools | /python/security/sal/calc/__init__.py | 1,994 | 4.21875 | 4 | """
calculate total for general financial usage
"""
def interest_fixed_capital(amount, rate, periods):
"""
calculate the captial and interest by average capital every period.
:param amount: float, total capital amount
:param rate: float, rate of interest per period
:param periods: int, tota... |
9ba5856684d30e1830560088406d72860c41416e | wxl24life/projecteuler_python_practice | /problem_3.py | 3,337 | 3.609375 | 4 | #Largest prime factor
import datetime
####################################
############ is_prime ##############
####################################
def is_prime_first_version(n):
# n needs to be an integer
if n < 2:
return False
fac_count = 0;
for i in range(1, n+1):
if n % i == 0:... |
f9450d9d739592eaffc8c8a37bb813d368a246fc | pytoday/pycode | /example_codes/mass_example/exp_codes/car.py | 1,930 | 4.03125 | 4 | #!/usr/bin/env python3
# coding=utf-8
# title :car.py
# description :practice for class
# author :JackieTsui
# organization :pytoday.org
# date :2017/8/3 18:38
# email :jackietsui72@gmail.com
# notes :
# ==================================================
# Import the m... |
1fd91edaa0c599b714dd030574bbf11fdeaa1bcd | pytoday/pycode | /data_visualization/random_walk.py | 2,116 | 3.5 | 4 | #!/usr/bin/env python3
# coding=utf-8
# title :random_walk.py
# description :
# author :JackieTsui
# organization :pytoday.org
# date :2017/8/20 下午5:09
# email :jackietsui72@gmail.com
# notes :
# ==================================================
# Import the module ne... |
833197fa4ded524ccaac995f736795649ec5d021 | pytoday/pycode | /example_codes/mass_example/exp_codes/printTable.py | 595 | 3.984375 | 4 | #!/usr/bin/env python3
# coding=utf-8
# 测试
tableData = [
['apple', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']
]
def printTable(t_data):
length = [0]*len(t_data) # int length for store length of tableData
for i in range(len(t... |
ec3e803a8a2192d316105b90cd6531722cdeeeb6 | yushu-liu/30daysofCode | /arraysday7.py | 232 | 3.953125 | 4 | # Given an array, , of integers,
# print 's elements in reverse order as a
# single line of space-separated numbers.
n = int(raw_input().strip())
arr = map(int, raw_input().strip().split(' '))
for val in arr[::-1]:
print val,
|
54aaa8f9ca08ff0c148e02a315640a2b52617179 | yushu-liu/30daysofCode | /recursionday9.py | 224 | 4.125 | 4 | # Write a factorial function that takes a positive integer, N as a
# parameter and prints the result of N! (N factorial).
def factorial(n):
return 1 if n == 0 else n * factorial(n - 1)
print(factorial(int(input())))
|
c20377548f073eef553d49770fc2cdc659d5953d | lccyx001/leetcode | /1-100/20.py | 521 | 3.53125 | 4 | class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
stack = []
maps = {"]":"[","}":"{",")":"("}
for al in s:
if al not in maps.keys():
stack.append(al)
else:
if len(stack) <1:
... |
d5707c91b6fa99c1ae3c7ed008baf6e17a4218cf | clugen/pyclugen | /pyclugen/helper.py | 8,455 | 3.59375 | 4 | # Copyright (c) 2020-2023 Nuno Fachada and contributors
# Distributed under the MIT License (See accompanying file LICENSE.txt or copy
# at http://opensource.org/licenses/MIT)
"""This module contains the helper functions."""
from typing import Callable
from numpy import abs, arctan, argmax, argmin, sum, zeros
from n... |
df82613b62bb16321e2b97d93abfecf99aaa0dc5 | DSLYL/Study_Arithmetic | /dict_Sort.py | 418 | 3.53125 | 4 | # def Dict(a):
# a1=len(a)
# for i in range(a1-1,0,-1):
# j=i-1
# if a[i]> a[j]:
# break
# for k in range(a1-1,j,-1):
# if a[k]>a[j]:
# a[k],a[j]=a[j],a[k]
# break
# a[j+1::]=a[-1:j:-1]
# if __name__ == '__main__':
# a=list()
# b=int(in... |
df9ca881d5041c6ef8bf2b19e3748f40212b2610 | bradellison/games | /pacman.py | 7,412 | 3.546875 | 4 | #! /usr/bin/env python
import os
import random
from random import randint
import pygame
# Class for the orange dude
class Player(object):
def __init__(self):
self.size = 24
self.rect = pygame.Rect(240, 384, self.size, self.size)
self.score = 0
self.speed = 2
self.powerup = False
self.powerupend = 0
d... |
b93d66013aa521faa7423211ddfaf0b1e7c6985c | ConejaAvalos/Python | /Tarea2.py | 646 | 3.9375 | 4 |
import random
import string
"""
Genera una contraseña
Recibe un 3 numeros qe dfiniran el numero de minusculas, mayusculas y digitos
"""
def contra(u, l, d):
str_u, str_l, str_d = '', '', ''
for i in range(u):
str_u += random.SystemRandom().choice(string.ascii_uppercase)
for i in ra... |
6bda51028e0cdeb704fdb30a9a7ca195c771d112 | Melwyna/LaboratorioFuncionesRemoto | /parte_3a.py | 256 | 4.09375 | 4 | def is_prime():
cont = 0
for i in range(1, b + 1):
if b % i == 0:
cont += 1
if cont == 2:
print("is a prime number")
else:
print("is not a prime number")
b = int(input("Ingrese un numero"))
is_prime()
|
74ab00e1327aa57ceb154d49721613f2e22919d7 | dostonhamrakulov/django-calendar-contribution-app | /images/mashqlar.py | 9,893 | 4.1875 | 4 | import sys
import math
# ========================= Question_1: ===========================================
# Write a program which will find all such numbers which are divisible by 7 but
# are not a multiple of 5,
# between 2000 and 3200 (both included).
# The numbers obtained should be printed in a comma-separated ... |
065c7089586649eeb65e8131253ef8a3aaefde17 | cugis2019-miami/cugis2019-miami-ramatouilejar82 | /Ramatoulie Jarjue.py | 805 | 4.125 | 4 |
print("I am learing to code in python today")
dprint(53)
print(5*2)
print(5/2)
print(5-2)
print(5**2)
print((8/9)
print("the division of 5/2 is,"5/2)
def plus(a,b):
plus= a+b
Pls(2,3)
def plus(c,b,a):
plus=c,b,a
print("plus")
plus(5,6,3)
def triangle(b,h):
triangle=(1/2)*b*h
print(triangle)
tria... |
783208234d27c718f5997d0f4e02d0bf683886d1 | luluxu9466/sqlalchemy-challenge | /.ipynb_checkpoints/app-checkpoint.py | 1,696 | 3.9375 | 4 | # 1. import Flask
from flask import Flask
# 2. Create an app, being sure to pass __name__
app = Flask(__name__)
# 3. Define what to do when a user hits the index route
@app.route("/")
# List all routes that are available
def home():
return (
f"Welcome to the Percipitation API!<br/>"
f"Available R... |
8c2ba2156de9dccf148235b8f0455b03cd6d7aa4 | ChrisLuginbuhl/cjekel.github.io | /assets/2017-09-27/Python/pythonSpeed.py | 2,079 | 3.53125 | 4 | import time as time
import numpy as np
import numba
# generate 1 billion samples
n = 1000000000
# Add 2 * Y to X, element by element:
# Slowest
# Create two int arrays, each filled with with one billion 1's.
X = np.ones(n, dtype=np.int)
Y = np.ones(n, dtype=np.int)
t0 = time.time()
X = X + 2.0 * Y
t1 = time.time()
p... |
0b98f4c20b062ff5d47d39bc902526ca87dd9907 | kartik2309/Home-Price-Prediction | /eda_n.py | 6,689 | 3.5 | 4 |
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.stats import norm
from sklearn.preprocessing import StandardScaler
from scipy import stats
import warnings
warnings.filterwarnings('ignore')
dataset = 'train'
# Here we obtain the data.
path = 'Datasets/' + datas... |
ea263ce04716e5c511b5ea7c86f32187e61fc9a2 | AlexLiuyuren/AIHomework | /AIhomework2/main.py | 446 | 3.5 | 4 | from expr import Expr, Exprs
from bfs import bfs
from dfs import dfs
if __name__ == '__main__':
# 记录输入信息
file = open("input.txt", "r")
list_lines = file.readlines()
list_exprs = []
num = int(list_lines[0])
for i in range(1, num+1):
tmp = Exprs(list_lines[i])
list_exprs.append(tm... |
dc6e3ab956e1eee8ebca0e02464cf47cacf9ea0f | programmerunit/ADS | /BST.py | 2,367 | 4.09375 | 4 | class BS: #initialisation class, node initialised with 12 and both childs set to null
def __init__(self,key):
self.key = key
self.lchild = None
self.rchild = None
def __repr__(self): #This method returns the string representation of the object.
return str(self.key)
... |
59f749a3808dccf334decb3e7ce82e573605f96d | HanSeYeong/CNU-ImageLab | /6 April_Group Anagrams/seyeong.py | 411 | 3.953125 | 4 | strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
def groupAnagrams(strs):
categories = []
result = []
for word in strs:
sorted_word = sorted(word)
if sorted_word not in categories:
result.append([word])
categories.append(sorted_word)
else:
result... |
6aa3fe83f5287c7737a93e63dff0a7fde59d1d84 | HanSeYeong/CNU-ImageLab | /_20 April_Construct Binary Search Tree from Preorder Traversal/seyeong.py | 440 | 3.546875 | 4 | class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
root = None
for e in preorder:
root = self.bst(root, e)
return root
def bst(self, node, val):
if node is None:
return TreeNode(val)
if val < node.val:
no... |
b84b41af237730e5f2181ca4df07ce75783c112f | HanSeYeong/CNU-ImageLab | /8 April_Middle of Linked LIst/seyeong.py | 460 | 3.8125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def middleNode(self, head):
head_node = head
count = 0
while True:
count += 1
if head_node.next == None:
... |
cb9dab799d99e9e6fa23d25e82bfa34f7abd0270 | HanSeYeong/CNU-ImageLab | /_20 April_Construct Binary Search Tree from Preorder Traversal/JongHo.py | 922 | 4 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def bstFromPreorder(self, preorder):
"""
:type preorder: List[int]
:rtype: TreeNode
"""
... |
0f41cf88eeb937de84951e3b875b285c82f4d978 | HanSeYeong/CNU-ImageLab | /_10 April_Min Stack/chaewon.py | 567 | 3.828125 | 4 | class MinStack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.Arr = []
def push(self, x):
"""
:type x: int
:rtype: None
"""
self.Arr.append(x)
def pop(self):
"""
:rtype... |
0b88abd88e39d39864717fe9af4bdcff9380f229 | HanSeYeong/CNU-ImageLab | /2 April_Happy Number/seyeong.py | 360 | 3.53125 | 4 |
def isHappy(n):
fail_number = set()
while True:
nums = str(n)
total = 0
for num in nums:
total += int(float(num)) ** 2
if total == 1:
return True
if total not in fail_number:
fail_number.add(total)
else:
return Fal... |
b1b2821bdea93e5dc9400144b54c127d92ca0edf | arjungprs/pythonlearning | /student.py | 416 | 4 | 4 | class Student:
school_name = "Springfield Elementary"
def __init__(self,name,student_id=121):
self.name = name
self.student_id = student_id
# student = {"name": name, "student_id" : student_id}
# students.append(self)
def __str__(self):
return "Studdent" + self.name
... |
735b70924fafa82fb5f4fe852905426e5c42fed3 | lydiatwdai/QM2-team9 | /Summary Statistics/summary_code.py | 5,893 | 3.75 | 4 | import pandas as pd
df = pd.read_csv (r'/content/1970.csv')
print (df)
mean1 = df['Length'].mean()
max1 = df['Length'].max()
min1 = df['Length'].min()
count1 = df['Length'].count()
median1 = df['Length'].median()
std1 = df['Length'].std()
var1 = df['Length'].var()
print ('Mean length: ' + str(mean1))
print ('Max ... |
a0d20fa43e769607726f63ba0444b7db400da1d4 | PabloSzx/Torneo-Programacion | /3.8.8/main.py | 394 | 3.515625 | 4 | todo = ""
while (True):
a = str(input())
todo += a
todo += "\n"
if (a == " "):
break
contador = 0;
resultado = ""
todoSeparado = todo.replace("\n", " ").split(" ")
for i in todoSeparado:
if ((contador + len(i)) > 72):
resultado += "\n"
contador = 0
resultad... |
e25c3713d676af44595a7ed4dad7103dc49c1659 | manoj06/MIT_PYTHON_PRACTICE_PROGRAMMING | /pb1_1a.py | 459 | 4.0625 | 4 | annual_salary=float(raw_input("Enter annual salary:"));
portion_saved=float(raw_input("Enter the portion saved:"));
total_cost=float(raw_input("Enter total cost:"));
portion_down_payment=0.25
down_payment=portion_down_payment*total_cost
current_savings=0.0
r=0.04
monthly_salary=annual_salary/12.0
i=0;
while(cur... |
741b1776dc6a9e4bdaaa76cc3633364926835d7a | Prajwal-Kaushal/Neural-Networks-Basics | /nn07_ReLU.py | 995 | 4.21875 | 4 | '''
Now we have to add activation function to our code so that our model can fit to
non linear data. There are many activation functions which we can use like:
Step function
Linear Activation
Sigmoid
ReLU - Rectified linear
Equations for the above can be seen on the internet.
We wont be using Step fun... |
79315350b23b0f73609bf631b38443e49b8cc40d | phil-mansfield/gotetra | /render/scripts/deriv.py | 5,620 | 3.953125 | 4 | import math
import scipy.interpolate as intr
import numpy as np
def vector_deriv(xs, ys, order=2):
""" Function vector_deriv takes two np.arrays representing the x and y
values of a function and returns a numpy array of the derivative of that
function evaluated at those x values.
Keyword arguments... |
fdd5422570a997ce20cdd539f6b17aaacb6a3709 | singularity0/Python_101 | /week13/play.py | 1,372 | 3.65625 | 4 | # class Iterable:
# def __init__(self, iterable_one, iterable_two):
# iterable_three = concat(iterable_one, iterable_two)
# def __iter__(self, ):
# pass
# def __next__(self):
# pass
# def chain(iterable_one, iterable_two):
# iterable_three = Iterable(iterable_one, iterable_two... |
ceda5a11df1e4b419e71d1f80365ab730cdc8b83 | sandx94/euler | /euler_34.py | 868 | 3.640625 | 4 | import os
import itertools
import sys
import math
dc_facts = {}
#-----
def main():
num = 3
total = 0
ls_fin = []
for i in range(0,10):
dc_facts[str(i)] = math.factorial(i)
while num <= 2903040:
if valid(num):
string = str(num)
add = 0 ... |
83cc1515fbf2e8b5fd8001f06de7e5be7f16c489 | Mattymar/dsp | /python/advanced_python_dict.py | 884 | 4 | 4 | import csv
from itertools import islice
faculty_dict = {}
professor_dict = {}
with open('faculty.csv', 'r') as file:
reader = csv.reader(file)
next(reader) # skip the header
for row in reader:
# Build dict with last names as keys
faculty_dict[row[0].split()[-1]] = {'degree': row[1], 'titl... |
98346b89ec64f49597b4f65b90e50b4c961467bf | Park-Jiho20/MSE_Python | /ex030.py | 555 | 4.09375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
# string값에 "abcd"를 설정해준다.
string = "abcd"
# string에 있는 b를 B로 바꾸어준다.
string.replace('b', 'B')
# string값을 출력해준다.
print(string)
# 실행결과 : abcd
# 해설 : 문자열은 변경될수 없다. 따라서 replace함수를 사용하면 aBcd를 저장한 새로운 메모리가 형성되는데, 이를 바인딩해주는 값을
# 정해주지 않았기 때문에 이 메모리는 곧 사라지게 되고, 여전히 string은 abcd... |
1c1aa6ad6c2d95b50c1ec7317fb42e6db7816996 | Park-Jiho20/MSE_Python | /ex140.py | 750 | 3.671875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
# range(4)를 쓰면 [0, 1, 2, 3] 리스트 같은것이 생성되는데, 이때 i는 0,1,2,3을 바인딩 하므로 print("------")를 총 4번 실행하게 된다.
for i in range(4): # [0, 1, 2, 3]
print("------")
# 실행결과 : ------
# ------
# ------
# ------
# 해설 : 파이썬 for문은 들여쓰기된 코드가 자료구조의 데이터 ... |
db7ff5bc49b1215f8aea09d657894e8f5e5e3c2e | lucassilva-2003/Cursoemvideo_Python_100exs | /ex050.py | 264 | 3.6875 | 4 | # Somador de números pares
s = 0
x = 0
for c in range(1, 7):
n = int(input('Digite um número inteiro [{} de 6]: '.format(c)))
if n % 2 == 0:
s += n
x += 1
print('A soma dos {} valores pares digitados é igual A {}'.format(x, s))
|
197caec1dd643fd62764ed1288cc080293aff892 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex039.py | 1,295 | 3.78125 | 4 | from datetime import date
from playsound import playsound
a = int(input('Em que ano você nasceu? '))
s = str(input('Sexo (masculino ou feminino): ')).lower().strip()
ano = date.today().year
q = ano - a
print('Quem nasceu em {} tem {} anos em {}'.format(a, q, ano))
if q > 130:
print('\033[4;31mSinto lhe in... |
05049f2863e0fef923223922ed72d7ecbb4766ac | lucassilva-2003/Cursoemvideo_Python_100exs | /ex100.py | 546 | 3.59375 | 4 | # Funções para somar e gerar numeros aleatórios
from random import randint
from time import sleep
def sortear(lst):
for c in range(1, 6):
lst.append(randint(1, 10))
print(f'Sorteando... ', end='')
for c in lst:
print(c, end=' ')
sleep(0.3)
print()
def somapar(lst2):
... |
306428ad13da96efe5db3949d6e0db4cfb57b5ad | lucassilva-2003/Cursoemvideo_Python_100exs | /ex025.py | 133 | 3.625 | 4 | # Silva verificaitor
n = input('Digite seu nome completo: ')
n2 = n.lower()
print('Seu nome tem Silva?')
print('silva' in n2)
|
a0caee2960999b95ec505979f8e8cc8017f50e01 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex095.py | 2,711 | 3.5 | 4 | dcn = dict()
info = list()
tot = list() # iniciei 1 dicionários e 2 lista
while True:
total = 0 # variavel total para calular o total de gols criada(no inicio do while para resetar a cada repetição)
dcn['nome'] = str(input('Qual o nome do jogador? ')).capitalize() # Pergunta o nome e o c... |
6c9a46a80bba0aff2294801a4c79cb26b92fad61 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex028.py | 483 | 3.671875 | 4 | # Jogo da Adivinhação
from random import randint
from playsound import playsound
a = randint(0, 5) # Número aleatório de 0 a 5
print('-=-' * 20)
print('Vou pensar em um número de 0 a 5 tente adivinhar')
print('-=-' * 20)
ap = int(input('Insira Aqui: '))
if ap == a:
print('Você acertou!!!')
playsound... |
edc762c1fbb00cd6ffb7753b549fd999958b5c57 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex058.py | 543 | 3.78125 | 4 | # Advinhação V2
from random import randint
print('='* 50)
print('{:^40}'.format('Vou pensar em um número de 0 a 10 tente adivinhar!'))
print('='* 50)
n = 0
pc = randint(1, 10)
c = 0
while n != pc:
n = int(input('Sua escolha: '))
if n < pc:
print('Mais...', end='')
if n > pc:
pri... |
aaba767efbcd539412cea36a5e21cc2da268ee9c | lucassilva-2003/Cursoemvideo_Python_100exs | /ex044.py | 1,021 | 3.578125 | 4 | print('{:=^40}'.format('Lucas Lojas'))
p = float(input('Qual o valor do produto? '))
print('Escolha a opção de pagamento')
print('[ 1 ] À vista dinheiro/Cheque')
print('[ 2 ] À vista no cartão')
print('[ 3 ] Em até 2X no cartão')
print('[ 4 ] 3X ou mais no cartão')
n = int(input('Escolha uma opção: '))
op = [p*... |
ef9727ce5736a593806c59c64554410d9d5daf75 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex029.py | 349 | 3.84375 | 4 | # Cobrador de multas
print('{:=^40}'.format('Radar Eletronico?'))
n = int(input('Digite sua velocidade: '))
limite = n - 90
multa = limite * 7
if n > 90:
print('Multado Valor total a pagar {}R$'.format(multa))
else:
print('Dentro do limite, use sempre o cinto de segurança')
print('Velocidade detectada:... |
635455e943ae5ba2e28e3a96edbbb4083a82f307 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex080.py | 2,819 | 3.921875 | 4 | lista = [] # iniciei uma lista vazia
for c in range(0, 5): # O for irá repidir 5 vezes para ler 5 números
n = int(input('Digite um número: '))
if c == 0: # Caso o c seja 0 o número so pode ser adcionado na posição 0 pois é o começo a 1 vez
lista.insert(c, n)
print('Adici... |
7a8d6df10a6632f38eafbf6715a87a9c7faa2f98 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex061.py | 216 | 3.765625 | 4 | # PA com while
n = int(input('Digite o primeiro termo da PA:'))
n2 = float(input('Digite a razão da PA:'))
t = 1
d = n +(10-1)*n2
while n <= d:
print('{} termo = {}'.format(t, n))
t +=1
n += n2
|
b0fb5bc366ba714f4766bc6c73b77343ff887509 | lucassilva-2003/Cursoemvideo_Python_100exs | /ex094.py | 1,646 | 3.828125 | 4 | dici = dict()
lista = list() # inicia uma lista e um dicionário
media = 0
while True:
dici['Nome'] = str(input('Nome: ')).capitalize() # No dicionário são colocadas as informações nome e idade
dici['Idade'] = int(input('Idade: '))
media += dici['Idade'] # as idades digidadas são somad... |
8b76c95824251f08481b265e9bdf8883080b9c71 | daria19-meet/y2s18-python_review | /exercises/for_loops.py | 66 | 3.59375 | 4 | a=0
i=2
for i in range(101):
if i%2==0:
a=a+i
print(a) |
3c32f28e6821bf0043ed5de899eb3ce701afe8d2 | brucemingxinliu/Image_Classification | /Image_Classfication_Keras/classifier_from_little_data_script_2/classifier2.py | 6,697 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 22 15:02:51 2017
@author: TWang
Using the bottleneck features of a pre-trained network: 90% accuracy in a minute
A more refined approach would be to leverage a network pre-trained on a large dataset.
Such a network would have already learned features that are useful fo... |
9201f32dbe97d4dfe6c0ab16da8a3dc9bf071598 | Codesane/python_labs | /lab7/lab7b.py | 428 | 3.828125 | 4 | # lab7B.py
# @author Felix Ekdahl
# Student-ID: felno295
# http://www.ida.liu.se/~TDDD64/python/la/la7.shtml
to_sort = [34, 93, 23, 14, 56, 26, 17, 59, 75]
def quicksort(slist):
if not slist:
return slist
else:
pivot = slist[0]
left = []
right = []
for i in slist[1:]:
if i < pivot:
left.append(i)
... |
cfde63656770eef1eda251c5756bf307580fb0e1 | lukasz-otowski/python-funk | /highest.py | 370 | 4 | 4 | inp = str(input("Input a numbers divided by space: "))
# change all element in list into integers
inp = list(map(int, inp.split()))
iteration = 0
curr = 0
while iteration < len(inp):
if curr < inp[iteration]:
curr = inp[iteration]
if iteration == len(inp):
break
else:
iteration +... |
16c1606bb3a1b052528e758359d534c6107521d3 | ewarlock/ITEC-2905-80-Lab-02 | /AuthorClass.py | 1,006 | 3.796875 | 4 | #create Author class
class Author:
def __init__(self, name):
#initialize with name and an empty book list
self.name = name
self.books = []
def publish(self, book):
self.books.append(book)
def __str__(self):
#will do stuff only if the value is true
#falsy va... |
935a0f67f7a38b83ad4bca8f7b216c515096def4 | mikebrown24/Dojo-Work- | /PythonCd/coinTosses.py | 591 | 3.84375 | 4 | import random
def coinToss():
return random.randrange(2)
print "Starting the program...."
heads_count = 0
tails_count = 0
for i in range(1, 5001):
if coinToss() == 0:
heads_count += 1
print "Attempt #{}: Throwing a coin... It's a {}! ... Got {} head(s) so far and {} tail(s) so far".format(i... |
37af27e50dcee9de65ff29139f00010b7a62c071 | tsainez/examples | /python/adding.py | 348 | 3.90625 | 4 | # adder.py
# Anthony Sainez
while True:
try:
nums = input("Enter numbers: ")
total = 0
if(len(nums.split(' ')) > 1):
for num in nums.split(' '):
total += float(num)
print(total)
break
except ValueError:
print("Error: incorrect input. P... |
c70f4be482abfe900208219f112a13a9d712cc37 | tsainez/examples | /python/punishment.py | 226 | 3.765625 | 4 | with open("CompletedPunishment.txt", "w") as file:
sentence = input("Enter in a sentence: ")
repeats = input("Enter in how many times to repeat: ")
for i in range(int(repeats)):
file.write(sentence + "\n")
|
38e7614d974d59a89080b143aaba4a5671f060c3 | aliavang/holbertonschool-higher_level_programming | /0x03-python-data_structures/7-add_tuple.py | 364 | 3.640625 | 4 | #!/usr/bin/python3
def add_tuple(tuple_a=(), tuple_b=()):
len_a, len_b = len(tuple_a), len(tuple_b)
if len_a == 1 or len_a == 0:
tuple_a += (0, 0)
if len_b == 1 or len_b == 0:
tuple_b += (0, 0)
tuple_a = tuple_a[0:2]
tuple_b = tuple_b[0:2]
tuple_c = ((tuple_a[0] + tuple_b[0]), (t... |
5d99531c087d6e3437266ab245e288858d1821ed | aliavang/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 1,078 | 3.75 | 4 | #!/usr/bin/python3
"""
python3 -c 'print(__import__("my_module").__doc__)'
"""
def error_raise(num):
"""Raise error depending on number that is passed to function"""
if num == 1:
raise TypeError("matrix must be a matrix (list of lists) of\
integers/floats")
elif num == 2:
raise Ty... |
a829e837e1b1bd21f4e2426aa30910f879f825af | aliavang/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/7-islower.py | 119 | 3.703125 | 4 | #!/usr/bin/python3
def islower(c):
if (ord(c) <= 122) and (ord(c) >= 97):
return (True)
return (False)
|
d457eb5ce215dd606ac0c738ee024a33e7dd3dc1 | emgv/python | /cows.py | 1,175 | 3.734375 | 4 | import random
def char_count(pstr):
occ= {}
for c in pstr:
if(c not in occ):
occ[c]= pstr.count(c)
return occ
def cows_and_bulls(num_str, answer):
i=0
cows_ct=0
bulls_ct=0
bulls= {}
len_ans=len(answer)
while(i < len_ans):
n= num_str[i]
if(n == an... |
eaf5be3fec6cd8ffe78034636da06e2862206710 | hsy118/TIL_algorithm | /daily_hw/4866 괄호검사.py | 733 | 3.65625 | 4 | """
print('{} {}'.format(1, 2))
N, M = map(int, input().split())
print('#{} {}'.format(tc, find())
"""
def check(string):
result = []
for i in range(len(text)):
if string[i] == '(' or string[i] == '{':
result.append(string[i])
elif string[i] == ')':
if len(result) == 0 or... |
d5ed0e5db78b2fbb9f38865335a9077187dcba4f | nfischer/intellijester | /src/mp3.py | 1,235 | 3.734375 | 4 | """
Functions for downloading and playing mp3 files that read jokes out loud
"""
import os
import pyglet
import urllib2
import urllib
# Constants
MP3_FILE_NAME = "joke.mp3"
URL_BASE = "http://tts-api.com/tts.mp3?"
## Make an api call to get an mp3 file of a computer voice reading the input text
## @param input_text:... |
ff758a9147fbec8a2bd10624554c1cc14974e36f | shakutori/hangman | /hangman.py | 1,361 | 3.9375 | 4 | # http://tinyurl.com/h9q2cpc
import random
def hangman(word):
wrong = 0
stages = ["",
" ",
"_______ ",
"| ",
"| | ",
"| O ",
"| /|| ",
"| /| ",
... |
bc6858dfc3a78250bda56d7719a4087b23052426 | h-j-13/Algorithms-Soulution | /剑指offer/孩子们的游戏.py | 1,542 | 3.671875 | 4 | # -*- coding:utf-8 -*-
class Solution:
"""
题目描述
每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,
今年亦是如此。HF作为牛客的资深元老,自然也准备了一些小游戏。
其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。
然后,他随机指定一个数m,让编号为0的小朋友开始报数。
每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,
并且不再回到圈中,从他的下一个小朋友开始,继续0...m-1报数....这样下去....直到剩下最后一个小朋友,
可以不用表演,并且拿到牛客名贵的“名侦探柯... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.