seq_id stringlengths 4 11 | text stringlengths 113 2.92M | repo_name stringlengths 4 125 ⌀ | sub_path stringlengths 3 214 | file_name stringlengths 3 160 | file_ext stringclasses 18
values | file_size_in_byte int64 113 2.92M | program_lang stringclasses 1
value | lang stringclasses 93
values | doc_type stringclasses 1
value | stars int64 0 179k ⌀ | dataset stringclasses 3
values | pt stringclasses 78
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
6066425882 | from rest_framework import status
from rest_framework.response import Response
from rest_framework.decorators import api_view
from accounts.api.serializers import UserSerializer
from rest_framework_simplejwt.tokens import RefreshToken
@api_view(['POST'])
def user_registration(request):
# here we will serialize ... | master-8702/mezgeba_app | accounts/api/views.py | views.py | py | 1,721 | python | en | code | 0 | github-code | 90 |
27414534804 | class Node:
def __init__(self,data = None):
self.data = data
self.next = None
class linkedList:
def __init__(self):
self.head = Node()
# def append(self,data):
# temp = Node(data)
# if self.head is None:
# self.head = temp
#return
#p = self.head
#while p.next is not None:
... | AbdussamadYisau/ds-and-algos | Miscellanous/reverseLinkedListWithYahaya.py | reverseLinkedListWithYahaya.py | py | 1,187 | python | en | code | 2 | github-code | 90 |
31972053851 | import sys
from orders import load_orders, save_orders
from commands import list_orders, create_order, get_order
def cli():
if len(sys.argv) == 1:
print("Please specify a command!")
print("Options: get, create, list, remove")
exit(-1)
command = sys.argv[1]
path = './order.txt'
... | davidl0673/pythonstuff | order_cli/cli.py | cli.py | py | 1,453 | python | en | code | 0 | github-code | 90 |
31501282331 |
def testReEle(lis):
c=0 #计数器初始化为0
while len(lis)!=0: #循环,对列表内每一个元素进行判断
b=lis[0] #保存表第一个元素
lis.remove(lis[0]) #删除列表第一个元素
if b in lis: #判断删除这一个元素之后列表内是否还有相同元素
c+=1 #若存在相同元素则计数器加1
else:
c+=0 ... | JinsidaFF/Python | 判断重复次数.py | 判断重复次数.py | py | 898 | python | zh | code | 3 | github-code | 90 |
16766075726 | # Complete project details at https://RandomNerdTutorials.com
def sub_cb(topic, msg):
print((topic, msg))
if topic == b'URA/robo1/acao' and msg == b'f':
print('ESP received, forward')
robot.forward()
if topic == b'URA/robo1/acao' and msg == b's':
print('ESP received, stop')
robot.st... | Natalnet/lib_ura_esp | devs/MQTT/main.py | main.py | py | 2,112 | python | en | code | 6 | github-code | 90 |
72984731175 | class Solution:
def shiftGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:
m, n, res =len(grid), len(grid[0]), []
k %= (m * n)
for i in grid:
for j in i:
res.append(j)
res = res[m * n - k:] + res[0: m * n - k]
c, temp,... | DayeemParkar/LeetCode-GFG-Submissions | 1260-shift-2d-grid/1260-shift-2d-grid.py | 1260-shift-2d-grid.py | py | 529 | python | en | code | 0 | github-code | 90 |
11124502817 | import copy
import os
import cv2
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from PIL import Image
from torchvision import transforms
"""
A few functions to Plot results
"""
# Basic plot setting
def plot_basic_set():
plt.rcParams['font.sans-serif'] = 'Times New Roman'
# change axi... | newbee-ML/MIFN-Velocity-Picking | utils/PlotTools.py | PlotTools.py | py | 27,615 | python | en | code | 4 | github-code | 90 |
10232224521 | import asyncio
from fastapi import FastAPI
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
import requests
import random
random.seed(54321)
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/ping")
async def health_check():
return "pong"
@app.... | sureshdsk/sample-fastapi-app | app/main.py | main.py | py | 903 | python | en | code | 4 | github-code | 90 |
70326115176 | import serial
import pandas as pd
ser=serial.Serial('COM9',115200,timeout=0.5)
data=[]
count=0
while True:
if(ser.inWaiting()>0):
k=ser.readline().decode('utf-8')
k=k.split(',')
hum=k[0].split(':')[1][1:]
temp=k[1].split(':')[1][1:-2]
#print(hum,temp)
dummy=[]
... | maddydevgits/nit-trichy-iot-fdp-session | day1/data-preparation-app.py | data-preparation-app.py | py | 540 | python | en | code | 0 | github-code | 90 |
15977878755 | """given a channel/experiment/collection
outputs messages in SQS for every cuboid in BOSS
"""
import itertools
import json
import logging
import os
import time
import boto3
import click
import pandas as pd
from botocore.exceptions import ClientError
from boss_export.libs import bosslib, mortonxyz, ngprecomputed
from... | neurodata/boss-export | boss_export/utils/gen_messages.py | gen_messages.py | py | 11,507 | python | en | code | 1 | github-code | 90 |
13454876798 | # https://leetcode.com/problems/product-of-array-except-self
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
array_length = len(nums)
left: int = 1
right: int = 1
l_index = 0
r_index = array_length - 1
answer = [1] * array_length
w... | petercrackthecode/LeetcodePractice | productExceptSelf/best_solution.py | best_solution.py | py | 668 | python | en | code | 1 | github-code | 90 |
6458531037 | # import cfg
import requests
import cfg
# read black words
# with open(cfg.BLACK_WORDS_PATH, "r") as f:
# black_words = f.read().splitlines()
# black_words = set(black_words)
# print(black_words)
def get_asr_content(wav_url="http://106.14.148.126:9000/testing/2p1c8k.wav", spkid="zhaosheng"):
hit_keyw... | nuaazs/VAF | src/utils/asr/wenet_asr.py | wenet_asr.py | py | 896 | python | en | code | 16 | github-code | 90 |
39094842981 | from selenium import webdriver
from scrapy import Selector
import time,csv
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
chrome_options = Options()
chrome_options.add_argument("--disable-extensions") # Disable extensions
chrome_options.add_argument("--page-load-stra... | Siddhant0507Shekhar/PrimeNumbers-Assignment | assignment.py | assignment.py | py | 1,816 | python | en | code | 0 | github-code | 90 |
71878487658 | from rest_framework import serializers
import statistics
from foundation.models import TimeSeriesDatum, Sensor, Instrument
class DashboardSerializer(serializers.BaseSerializer):
def get_values(self,sensor_name, insturments):
sensor = Sensor.objects.get(
name = sensor_name,
instrume... | ydang5/indoorair-back | indoorair_back/api/serializers/dashboard/dashboard_serializers.py | dashboard_serializers.py | py | 1,924 | python | en | code | 0 | github-code | 90 |
31081107024 | from ampalibe import Model
class Requete (Model):
def __init__(self, conf):
"""
Connexion à notre base de donnée
"""
Model.__init__(self, conf)
@Model.verif_db
def Get_Menus(self):
"""
Recupérer les menus de la carte
"""
req = """
... | joseeange04/MenuViz | requete.py | requete.py | py | 533 | python | en | code | 0 | github-code | 90 |
37843533144 | import matplotlib.pyplot as plt
import numpy as np
import cv2
import os
def ensuredir(path):
if not os.path.exists(path):
os.makedirs(path)
modalities = ['green', 'hinselmann', 'schiller']
in_path = os.sys.argv[1]
out_path = os.sys.argv[2]
border = 10
for modality in modalities:
filenames = list(... | kelwinfc/ordinal-segmentation | ordinal_segmentation/data/cervix/huc.py | huc.py | py | 2,028 | python | en | code | 0 | github-code | 90 |
15296421212 | """
Created Oct 23, 2017
@author: Spencer Vatrt-Watts (github.com/Spenca)
"""
from django.conf.urls import url
from pbal import views
app_name = 'pbal'
urlpatterns = [
url(r'^library/(?P<pk>\d+)$', views.PbalLibraryDetail.as_view(), name='library_detail'),
url(r'^library/list$', views.PbalLibraryList.as_view... | molonc/colossus | pbal/urls.py | urls.py | py | 2,105 | python | en | code | 3 | github-code | 90 |
30948024654 | board = [' ' for x in range(10)]
#Inserir uma letra em uma dada posicao
def insertLetter(letter, pos):
board[pos] = letter
#Verificar se o espaco escolhido esta vazio
def spaceIsFree(pos):
return board[pos] == " "
#Printar o tabuleiro na tela
def printBoard(board):
print(" " + board[1] + "/ "... | GuilhermeRuy97/miniProgramas | jogoDaVelha.py | jogoDaVelha.py | py | 3,549 | python | en | code | 0 | github-code | 90 |
73910552935 | #!/usr/bin/python
# -*- coding:utf-8 -*-
__author__ = 'Ydface'
import pygame
import mypygame
import util.node
import button
import gamestate
import gameresource
import battle
screen = mypygame.screen
screenwidth = mypygame.screenwidth
screenheight = mypygame.screenheight
class LevelButton1(button.B... | ydface/pygame | game_ui/mission_map.py | mission_map.py | py | 4,799 | python | en | code | 0 | github-code | 90 |
2097384606 | import turtle
import pandas
screen = turtle.Screen()
screen.title("U.S States Games")
image = "Code_100/Day_25/us-states-game-start/blank_states_img.gif"
screen.addshape(image)
turtle.shape(image)
data = pandas.read_csv(
"Code_100/Day_25/us-states-game-start/50_states.csv")
guessed_state = []
all_states = data[... | sahn54/Code_100 | Day_25/us-states-game-start/main.py | main.py | py | 1,544 | python | en | code | 1 | github-code | 90 |
18120983079 | class Dice(object):
"""Dice Class
"""
def __init__(self, numbers):
"""
Args:
numbers:
"""
self.numbers = {1: numbers[0], 2: numbers[1], 3: numbers[2], 4: numbers[3], 5: numbers[4], 6: numbers[5]}
self.vertical = [self.numbers[1], self.numbers[2], self.... | Aasthaengg/IBMdataset | Python_codes/p02383/s328335843.py | s328335843.py | py | 1,857 | python | en | code | 0 | github-code | 90 |
1239575959 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 1 12:46:50 2018
@author: virginiedo
"""
from keras.callbacks import ModelCheckpoint
from create_dataset import create_feature_df
from sklearn.model_selection import train_test_split
import numpy as np
import keras
from keras.models import Seque... | virginie-do/ECG_classification | CNN.py | CNN.py | py | 2,831 | python | en | code | 2 | github-code | 90 |
4950551937 | from django.conf import settings
from rest_framework.routers import DefaultRouter, SimpleRouter
from .views import *
from django.urls import path
if settings.DEBUG:
router = DefaultRouter()
else:
router = SimpleRouter()
router.register("", PostsViewSet)
router.register("my-posts", CreatePostViewSet)
app_name... | An-Tran-2001/The_Wings_0.1.0 | thewings_backend/posts/router.py | router.py | py | 455 | python | en | code | 1 | github-code | 90 |
43843726020 | """
给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。
你可以假设数组中无重复元素。
示例 1:
输入: [1,3,5,6], 5
输出: 2
示例 2:
输入: [1,3,5,6], 2
输出: 1
示例 3:
输入: [1,3,5,6], 7
输出: 4
示例 4:
输入: [1,3,5,6], 0
输出: 0
"""
# 解答:先处理size为0,小于最小值大于最大值的边界情况,然后用二分法进行寻找,找到直接返回坐标,没找到时low比high大了,则返回high+1的坐标即可
class Solution(object):
def ... | wtrnash/LeetCode | python/035搜索插入位置/035搜索插入位置.py | 035搜索插入位置.py | py | 1,247 | python | zh | code | 2 | github-code | 90 |
20667936871 | #!/usr/bin/env python3
import re
import sys
import atexit
import asyncio
import functools
from pathlib import Path
from typing import List, Tuple
from operator import attrgetter
import httpx
import click
from .site_parser import parse_site, InvalidSite
from .podcasts import PODCASTS
from .podcast_dl import (
ensure... | kissgyorgy/simple-podcast-dl | podcast_dl/cli.py | cli.py | py | 8,206 | python | en | code | 51 | github-code | 90 |
15801950135 | # -*- coding: utf-8 -*-
"""
1817. Finding the Users Active Minutes
You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array
logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.
Multiple users can... | tjyiiuan/LeetCode | solutions/python3/problem1817.py | problem1817.py | py | 1,373 | python | en | code | 0 | github-code | 90 |
4738198111 | import asyncio
import websockets
async def send_text_message():
async with websockets.connect('ws://localhost:15010/ws') as websocket:
# message = input("Enter message: ")
message = "test message"
await websocket.send(message)
x = await websocket.recv()
print(f"recv message... | MetaPath01/sanicdemo4gpt | tests/test_demo001.py | test_demo001.py | py | 394 | python | en | code | 0 | github-code | 90 |
18285613769 | n = int(input())
arm = []
for _ in range(n):
x, l = map(int,input().split())
arm.append([x-l, x+l])
arm.sort(key=lambda x: x[1])
cnt = 0
pr = -float('inf')
for a in arm:
if pr <= a[0]:
cnt += 1
pr = a[1]
print(cnt)
| Aasthaengg/IBMdataset | Python_codes/p02796/s343061471.py | s343061471.py | py | 243 | python | en | code | 0 | github-code | 90 |
9325422748 | # TO create a reference state |p> from a default state |0>, we run the default state through a non-parameterized unitary
from qiskit import QuantumCircuit
# Basic referece unitary Ur = X0
qc = QuantumCircuit(3)
qc.x(0)
qc.draw("mpl")
# Template circuits for reference unitary
from qiskit.circuit.library import Two... | Hoponga/semantiq | variational_qc/reference.py | reference.py | py | 1,234 | python | en | code | 2 | github-code | 90 |
11076545501 | #!/usr/bin/python3
from sys import stdin
from itertools import repeat
def mergerer(liste1, liste2):
sorterte = []
liste1.append((float('inf'), ""))
liste2.append((float('inf'), ""))
index1 = 0
index2 = 0
for i in range(0, len(liste1) + len(liste2) - 2):
if liste1[index1][0] > liste2[i... | halvorbmundal/Algdat | Kortstokker/Kortstokker.py | Kortstokker.py | py | 1,212 | python | en | code | 0 | github-code | 90 |
18766556176 |
from Vintageous import plugins
from Vintageous.vi.cmd_defs import ViOperatorDef
from Vintageous.vi.utils import modes
class VintageousOrigamiBase(ViOperatorDef):
def __init__(self, *args, **kwargs):
ViOperatorDef.__init__(self, *args, **kwargs)
self.repeatable = False
self.mot... | rodcloutier/Vintageous-Origami | action_cmds.py | action_cmds.py | py | 4,691 | python | en | code | 45 | github-code | 90 |
20115954172 | '''
Given an integer array nums of unique elements, return all possible subsets (the power set).
The solution set must not contain duplicate subsets. Return the solution in any order.
Example 1:
Input: nums = [1,2,3]
Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
'''
class Solution:
def subsets(self, nums: ... | XihangJ/leetcode | DFS/78. Subsets.py | 78. Subsets.py | py | 1,789 | python | en | code | 1 | github-code | 90 |
3917290654 | import pika
import uuid
import Messenger
import time
import datetime
class TweetRPCClient(Messenger.Messenger):
def __init__(self, name, host="localhost"):
Messenger.Messenger.__init__(self, name=name, host=host)
self.response = None
self.corr_id = None
self._channel.basic_consume... | Bilistic/Twitter-Sentiment-Analysis | TimerClient.py | TimerClient.py | py | 1,393 | python | en | code | 1 | github-code | 90 |
2588325744 | #-*-coding:utf-8-*-
import csv
import re
import pandas as pd
import gensim
import nltk
from nltk.corpus import stopwords
import numpy as np
import math
import ssl
import random
import collections
def cos_sim(a, b):
a_norm = np.linalg.norm(a)
b_norm = np.linalg.norm(b)
cos = np.dot(a,b)/(a_norm * b_norm)
... | XURIGHT/Advisor-Advisee_SAE | preprocessing.py | preprocessing.py | py | 4,348 | python | en | code | 1 | github-code | 90 |
10446367192 | #!/usr/bin/env python3
# A not-so-simple module to hold code for quick parsing of SAM file fields
import argparse
import logging
import re
import subprocess
import sys
try:
import cigarlib
except ImportError:
from bfx import cigarlib
__version__ = '0.10'
NULL_STR = '*'
HEADER_REGEX = r'^@[A-Za-z][A-Za-z]$'
FIELDS ... | NickSto/bfx | samreader.py | samreader.py | py | 13,172 | python | en | code | 0 | github-code | 90 |
26498517170 | # Overall goal is to create a PDF from single sided scans of a double sided document
import pathlib
import os
FN1 = "interleave1.tif"
FN2 = "interleave2.tif"
OUT_DIR = "Output"
PDF_W = 210
PDF_H = 297
def count_pages(fn: str) -> int:
import PIL.Image
"""Count the pages in a TIF"""
im = PIL.Image.open(f... | pscheidler/tif_pdf | tif_to_pdf.py | tif_to_pdf.py | py | 3,196 | python | en | code | 0 | github-code | 90 |
44761696664 | import sys
import os
import re
# Get params from cmdline args
MANIFEST = sys.argv[1]
DESTINATION = sys.argv[2] or "files"
def parse_img_links(c, r, s):
"""
* Takes MD content `c` and substitutes patterns matching `r` with `s`
param c: str; content of MD file to be parsed
param r: rstr; regex pattern t... | BirnadinErick/hn-bank | mv-files.py | mv-files.py | py | 1,132 | python | en | code | 0 | github-code | 90 |
23188028476 | class Month(str):
"""
Month with the year corresponding to it.
It is epected in the format of %Y-%m.
"""
@classmethod
def __get_validators__(cls):
# one or more validators may be yielded which will be called in the
# order to validate the input, each validator will receive as an... | naamiinepal/covid-tweet-classification | server/app/tweets_common/types.py | types.py | py | 1,382 | python | en | code | 7 | github-code | 90 |
14866793083 | import scrapy
from ho.spiders.base import BaseSpider, get_response_data, get_header
import ho.const as const
STATUS_HISTORY = 'all' # 已结束历史数据
STATUS_SPECIAL = 'del' # 删除/延迟
STATUS_TODAY = 'today' # 当日结束
# scrapy crawl match -a game=dota -a status=all
# 比赛列表
# 频率限制: 1次/每秒
# 建议更新频率:15分钟/次
class MatchSpider(BaseSpide... | tianyanglly/data-source | ho/ho/spiders/match.py | match.py | py | 3,709 | python | en | code | 0 | github-code | 90 |
31870864197 |
def config_DialogWAE():
conf = {
'maxlen':40, # maximum utterance length
'diaglen':10, # how many utterance kept in the context window
# Model Arguments
'emb_size':200, # size of word embeddings
'n_hidden':300, # number of hidden units per layer
'n_layers':1, # number of layers
'noise_radi... | guxd/DialogWAE | configs.py | configs.py | py | 1,351 | python | en | code | 125 | github-code | 90 |
18228636879 | from itertools import accumulate
from collections import Counter
def solve(n):
return n * (n - 1) // 2
s = input()[::-1]
MOD = 2019
# 事前計算
rest = []
for i, x in enumerate(s):
# 1, 10, 100, 1000...の剰余を順に計算し、各桁までの剰余を計算
if i == 0:
tmp = 1
else:
tmp = tmp * 10 % MOD
rest.append(int(... | Aasthaengg/IBMdataset | Python_codes/p02702/s690738690.py | s690738690.py | py | 642 | python | en | code | 0 | github-code | 90 |
73407034215 | from django.shortcuts import render, redirect
from .models import User, Student, Teacher
from std.models import Std
from .forms import UserRegisterForm, StudentRegisterForm, TeacherRegisterForm
import datetime
from django.urls import reverse
from django.contrib import messages, auth
from django.contrib.auth.hash... | ankitdevelops/dashboard | account/views.py | views.py | py | 4,906 | python | en | code | 0 | github-code | 90 |
30552860965 |
# -*- coding:utf-8 -*-
# import re
# phone = '123-4567-1234'
# new_phone = re.sub('\D', '', phone)
# print (new_phone)
# 12345671234
# a = 'one11two2three3'
# infos = re.search('\d+', a)
# print (infos.group())
# # 11
# infoss = re.findall('\d+', a)
# print (infoss)
# (.*?)表示()内的内容作为返回结果
# b = 'xxIxxjshdxxlovexxsff... | wsj2012/PythonLib | Practise/Test.py | Test.py | py | 2,127 | python | en | code | 0 | github-code | 90 |
40509992804 | # n=int(input("enter the number"))
# i=1
# sum=0
# while i<=10:
# sum=sum+i
# print(i)
# i=i+1
# print("sum of first","10","natural number is:",sum)
# i=1
# sum=1
# while i<=4:
# sum=sum+i
# print(i)
# i+=1
# print("sum of first","10","natural number is:",sum)
i=1
product=1
while i<=10:
pro... | seminao/loops | Q6.sum of first 10 natural no..py | Q6.sum of first 10 natural no..py | py | 412 | python | en | code | 0 | github-code | 90 |
29415558553 | ## Represents a single node in the Trie
class TrieNode:
def __init__(self):
## Initialize this node in the Trie
self.is_word = False
self.children = {}
def insert(self, char):
## Add a child node in this Trie
if char not in self.children:
self.children[char] ... | lorenzowind/python-programming | Data Structures & Algorithms/Project Basic Algorithms/Problems/problem_5.py | problem_5.py | py | 2,054 | python | en | code | 1 | github-code | 90 |
1757855565 | from Level_Up_App.models import Job, Skill, CareerPosition, CareerSkills
def getJobRecommendation(skillset):
return getMatchJob(skillset)
def getMatchJob(skills):
joblist = list()
jobs = Job.objects.all()
for job in jobs:
skillreq = job.skillRequired.all()
if matchSkills(skillreq, skil... | raymondng76/IRS-MR-RS-2019-07-01-IS1FT-GRP-Team10-LevelUp | SystemCode/Level_Up/Level_Up_App/jobrecommendationrules.py | jobrecommendationrules.py | py | 935 | python | en | code | 2 | github-code | 90 |
18322377999 | # https://atcoder.jp/contests/abc145/tasks/abc145_e
# なんとなくナップサック問題っぽい
# A分以内に食べきる事のできる最大の美味しさは?ならすぐにできる。
# 問題は最後のA分は必要ないこと
# →i番目の料理を最後に食べたときに、それ以外の料理でT分以内に食べることのできる美味しさの最大は?
# O(n^3) ∵ 各iについて(3000) × dp(3000*3000)
# →TLEしてしまいそう...
# 普通にナップサックして解いてから。もしiを最後に食べてたらの処理をする?
# ナップサック復元して、まだ食べてないもののなかから美味しさが最大のものを食べればよい!... | Aasthaengg/IBMdataset | Python_codes/p02863/s877918248.py | s877918248.py | py | 2,642 | python | ja | code | 0 | github-code | 90 |
36400450291 | #this file is to match the top_100_played_apps to the dataframe we sort out according to the numbers of positive reviews
import pandas as pd
import numpy as np
top = pd.read_csv('top_100_file.csv', index_col=0)
for index1, row1 in top.iterrows():
top.loc[index1, 'current_players'] = int(row1['Current Players'].rep... | JayZhuUCSD/ECE143_G15 | trash/Dataframes_Generated_to_Analyze/data3.py | data3.py | py | 870 | python | en | code | 0 | github-code | 90 |
35410177977 | from fastapi import FastAPI
# websocket
from fastapi import WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse
from starlette.middleware.cors import CORSMiddleware
from app.api.v1.api import api_router
from app.core.config import settings
app = FastAPI(
title=settings.PROJECT_NAME, openapi... | lance691991/fastapi_template | app/main.py | main.py | py | 3,347 | python | en | code | 0 | github-code | 90 |
12660971719 | import json
from datetime import datetime, timedelta
import pandas as pd
import streamlit as st
from bokeh.models import DatetimeTickFormatter, HoverTool
from bokeh.plotting import figure
from calendar import month_name
from dateutil.relativedelta import relativedelta
from CurrencyExchangeAPIRetriever import Currency... | ilias4780/currency_exchange_rates_dashboard | dashboard.py | dashboard.py | py | 10,132 | python | en | code | 0 | github-code | 90 |
71794758697 | # -*- coding: utf-8 -*-
import scrapy
import json
from Letv.items import LetvItem
class LetvliveSpider(scrapy.Spider):
name = 'LetvLive'
allowed_domains = ['letv.com']
pre = "http://dynamic.live.app.m.letv.com/android/dynamic.php?luamod=main&mod=live&ctl=liveHuya&act=channelList&pcode=010210000&version... | LIMr1209/Internet-worm | day07/teacher/Letv/Letv/spiders/LetvLive.py | LetvLive.py | py | 1,603 | python | en | code | 0 | github-code | 90 |
27482137344 | import discord
from discord.ext import commands
class fakeBan(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.color = self.bot.main_color
@commands.command(name="pban", aliases=['fban'])
async def fban(self, ctx, member: discord.Member = None, reason = None):
aw... | Ronish1122/Modmail-Plugins | fakeban/fakeban.py | fakeban.py | py | 994 | python | en | code | null | github-code | 90 |
18440431339 | N,A,B,C = map(int,input().split())
L = [int(input()) for i in range(N)]
ans = float('inf')
for a in range(1<<N):
at = []
for i in range(N):
if a&(1<<i):
at.append(L[i])
if not at: continue
ap = 10*(len(at)-1) + abs(A - sum(at))
for b in range(1<<N):
if a&b: continue
... | Aasthaengg/IBMdataset | Python_codes/p03111/s171463897.py | s171463897.py | py | 807 | python | en | code | 0 | github-code | 90 |
31229465902 | # -*- coding: utf-8 -*-
"""
Created on 2019-06-10 09:21:14
author: huangyunbin
email: huangyunbin@sina.com
QQ: 592440193
ST股票研究
"""
import os
import re
import pandas as pd
import xlrd
from pypinyin import lazy_pinyin, Style, load_single_dict
def py(s):
'''
汉字拼音大写首字母缩写
'''
load_single_dict({ord('长... | RoveAllOverTheWorld512/hyb_ta | stock_pandas/misc/styj.py | styj.py | py | 4,088 | python | en | code | 3 | github-code | 90 |
5513431816 | from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import socket
import os
def tf_config_from_flux(ps_number, cluster_size=4, job_name="flux-sample", port_number=2222):
"""
Creates configuration for a distributed tensorflow session
from environme... | flux-framework/flux-operator | examples/machine-learning/tensorflow/tensorflow_flux/tensorflow_flux.py | tensorflow_flux.py | py | 1,972 | python | en | code | 21 | github-code | 90 |
19848904500 | #!/usr/bin/python3
from selenium import webdriver
import time
from selenium.webdriver.support.ui import Select
driver_path = ".\chromedriver.exe"
# 支付demo界面
for i in range(1, 100):
print(i)
driver = webdriver.Chrome(executable_path=driver_path)
driver.get('https://testpay.hongnaga.com/?debug=true')
# ... | Tinywan/automated-test | pay/auto_form_pay.py | auto_form_pay.py | py | 950 | python | en | code | 3 | github-code | 90 |
12501166889 | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import numpy as np
import time
import random
def navigateToPro... | dotto44/CS3130 | FinalProject/python/scrape_data.py | scrape_data.py | py | 2,012 | python | en | code | 0 | github-code | 90 |
72745038058 | import smtplib as root
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
lgreen = '\033[92m'
clear = '\033[0m'
print(clear+lgreen+""" ▗▜ ▞▀▖▛▀▖ ▙▗▌
▛▚▀▖▝▀▖▄▐ ▚▄ ▙▄▘▝▀▖▌▘▌
▌▐ ▌▞▀▌▐▐ ▖ ▌▌ ▞▀▌▌ ▌
▘▝ ▘▝▀▘▀▘▘▝▀ ▘ ▝▀▘▘ ▘ Version 1.0"""+lgreen+clear)
... | Roundstg04/spamMail | mailSPAM.py | mailSPAM.py | py | 1,810 | python | ru | code | 0 | github-code | 90 |
1142464195 | import unittest
class BSTNodeP:
def __init__(self, value=0, parent=None, left=None, right=None):
self.value = value
self.left = left
self.right = right
self.parent = parent
def __str__(self):
return str(self.value)
class BSTP:
def __init__(self, root_value=0):
... | elishaking/CTCi | chapter_4/4_6_successor.py | 4_6_successor.py | py | 2,001 | python | en | code | 1 | github-code | 90 |
5370600971 | import tensorflow as tf
import argparse
from tqdm import tqdm
import os
def main(inpath, outpath):
val_path = outpath + 'val/val_{}.tfrecords'
samples_per_file = 900
files = []
for file in os.listdir(inpath):
if file.endswith(".tfrecords"):
files.append(inpath+file)
dataset = ... | freundma/can-ids | unsupervised/x-canids/split_val.py | split_val.py | py | 980 | python | en | code | 0 | github-code | 90 |
31071818609 | import sqlite3,colorama,os,urllib.request
from sys import version
from colorama import Fore, Back, Style
# init color class
colorama.init()
red = Fore.RED
green = Fore.GREEN
yellow = Fore.YELLOW
magenta = Fore.MAGENTA
reset = Fore.RESET
def build():
os.system("pyinstaller --onefile --hidden-import co... | alan890104/sqlite3-shell | db_shell.py | db_shell.py | py | 5,147 | python | en | code | 8 | github-code | 90 |
18230433796 | #! /usr/bin/env python3
import datetime
import mwparserfromhell
import httpx
from .CheckerBase import get_edit_summary_tracker, localize_flag
from .ExtlinkStatusChecker import ExtlinkStatusChecker
import ws.ArchWiki.lang as lang
from ws.parser_helpers.encodings import urlencode, anchorencode
from ws.parser_helpers.w... | lahwaacz/wiki-scripts | ws/checkers/ManTemplateChecker.py | ManTemplateChecker.py | py | 4,183 | python | en | code | 27 | github-code | 90 |
21178095451 | class Computer:
def __init__(self):
self.n = "DELL"
self.a = 2016
def Compare(self,c2):
if self.a == c2.a:
return True
else:
return False
def update(self):
self.a =2019
c1 = Computer()
c2 = Computer()
if c1.Compare(c2):
print("Same")
else:... | bhavanshu-1112/Python-Programming | oops2.py | oops2.py | py | 402 | python | en | code | 0 | github-code | 90 |
11039837682 | class Solution(object):
import collections
def minAreaRect(self, points):
"""
:type points: List[List[int]]
:rtype: int
"""
ys = collections.defaultdict(list)
for x, y in points:
ys[x].append(y)
d ={}
area = float('inf')
for x i... | liangliannie/LeetCode | 939. Minimum Area Rectangle.py | 939. Minimum Area Rectangle.py | py | 725 | python | en | code | 0 | github-code | 90 |
29708652886 | import imp
import sys
from collections import defaultdict
seen = set()
hindecies = defaultdict(list)
maxhi = 1
def DFS(G, node, hi):
mhi = hi
# create dfs...
for v in G[node]:
if v not in seen or hindecies[v] > hi:
seen.add(v)
mhi = hi + 1
hindecies[mhi].a... | MikkelNilsson/Kattis | Python/horror/horror.py | horror.py | py | 968 | python | en | code | 1 | github-code | 90 |
36729614908 | BATCH_SIZE = 32
WARM_UP = 10
ATTENTION_HEADS = 2
NUM_LAYERS = 4
NUM_OUT_HEADS = 2
HIDDEN_UNITS = 512
IN_DROP = 0
ATTENION_DROP = 0
LEAKY_ALPHA = 0.2
RESIDUAL = True
L_R = 0.0001
WT_DECAY = 0.01
EPOCHS = 20
| sujit-khanna/StockGAT | gat_parameters.py | gat_parameters.py | py | 206 | python | en | code | 0 | github-code | 90 |
70902300777 | """
Define a function called key_list_items that can accept an unlimited number of lists along with another argument
The function should return the second to last item in the specific list specified by the user of the function.
Example:
This should return George
key_list_items("people", objects=['car', 'pho... | Crypto-V/Courses | Assignment/Ex6.py | Ex6.py | py | 592 | python | en | code | 0 | github-code | 90 |
18358488559 | import sys
sys.setrecursionlimit(10**4)
inf = float('inf')
# 計算量O(VE) V:頂点数, E:辺の数
# True - >正常に更新, False -> startからendまでの経路において負閉路有り
def bellmanford(start, end):
global dist
dist = [inf] * N
dist[start] = 0
# 頂点数Nなら更新は高々N-1回で済む
for _ in range(N-1):
for v ,nv, w in edges:
if di... | Aasthaengg/IBMdataset | Python_codes/p02949/s566786218.py | s566786218.py | py | 1,340 | python | en | code | 0 | github-code | 90 |
18354445489 | #!/usr/bin/env python3
#ABC138 E
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from... | Aasthaengg/IBMdataset | Python_codes/p02937/s644751910.py | s644751910.py | py | 937 | python | en | code | 0 | github-code | 90 |
34622083220 | import xarray as xr
__all__ = ["add_indices", "cs1", "dvi", "ndvi"]
CHUNKS = {'band': 1, 'x': 2048, 'y': 2048}
def _get_band_locations(raster_bands: list, requested_bands: list):
"""
Get list indices for band locations.
"""
locations = []
for b in requested_bands:
try:
locatio... | nasa-nccs-hpda/terragpu | terragpu/indices/hls_indices.py | hls_indices.py | py | 6,622 | python | en | code | 7 | github-code | 90 |
33855559651 | #!/usr/bin/env python3
import sys
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 12 10:31:39 2018
@author: sumeetmishra
"""
def Roll_3_Dice(D1,D2,D3):
e_value=3.5 #expected value of a dice is 3.5
A=[1,2,3,4,5,6]
if D1 in A:
if D2 in A:
if D3 in A:
if... | sumeetmishra199189/Elements-of-AI | Game of Chance/Game_of_chance0.py | Game_of_chance0.py | py | 1,634 | python | en | code | 2 | github-code | 90 |
33707440108 | #### ----------------------------------------
#### Import modules:
#### -----------------
import numpy as np
import pandas as pd
#### Computer function
import os
import os.path
import sys
import subprocess
import shutil
import time
#### modules for reading and converting data
import linecache
from datetime impo... | zachwaldron4/pygeodyn | pygeodyn/pygeodyn/archive/obsolete_util_ControlTools.py | obsolete_util_ControlTools.py | py | 20,480 | python | en | code | 4 | github-code | 90 |
19552687158 | jogo = {
'tesoura' : ['papel', 'lagarto'],
'papel' : ['pedra', 'Spock'],
'pedra' : ['lagarto', 'tesoura'],
'lagarto' : ['Spock', 'papel'],
'Spock' : ['tesoura', 'pedra'],
}
jogos = int(input())
for x in range(jogos):
j = input().split()
if j[1] in jo... | gguillaux/UriOnlineJudge | Uri1828.py | Uri1828.py | py | 529 | python | pt | code | 1 | github-code | 90 |
17932311859 | #!/usr/bin/env python3
import sys
def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from itertools import chain
mat = floyd_warshall(np.array(c, dtype=np.int64), directed=True)
return int(sum(mat[a][1] for a... | Aasthaengg/IBMdataset | Python_codes/p03546/s688374978.py | s688374978.py | py | 1,022 | python | en | code | 0 | github-code | 90 |
431884631 | import sys
from PyQt5 import QtWidgets, QtCore, QtGui
import tkinter as tk
import numpy as np
class MyWidget(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle(' ')
self.begin = QtCore.QPoint()
self.end = QtCore.QPoint()
self.setWindowOpacity(0.1... | slamjeron/AutoGrinder | controlers/screenCapt.py | screenCapt.py | py | 1,683 | python | en | code | 1 | github-code | 90 |
195229189 | from typing import Union, Tuple, Type
import pyautogui, tesserocr, datetime, numpy, time, json, sys, cv2, PIL, os
from keyio.windowutils import WindowUtils
from keyio.mouseutils import MouseUtils
from keyio.keyutils import KeyUtils
class GearSeller:
SLEEP_PREEMPTIVE = True
PAD_LENGTH ... | keyywind/keywiz | Gear-Auctioner.py | Gear-Auctioner.py | py | 29,041 | python | en | code | 0 | github-code | 90 |
13633748195 |
"""
Sandbox for ensemble model
"""
import yaml
import logging
import os
import matplotlib.pyplot as plt
import numpy as np
from glob import glob
from code import (GESDatabase, plot, summary)
from astropy.table import Table
# Initialize logging.
logger = logging.getLogger("ges.idr5.qc")
logger.setLevel(logging.DEBUG... | andycasey/ges-idr5 | sandbox_ensemble.py | sandbox_ensemble.py | py | 7,903 | python | en | code | 0 | github-code | 90 |
42996569623 | # These are the only modules that you can use in lab2
import pandas as pd
import numpy as np
x = [3, 1, 18, 11, 13, 17]
num_bins = 4
def SSE(L):
mean = sum(L) / float(len(L))
sse = 0
for i in L:
sse = sse + (i - mean ) ** 2
if sse == 0.0:
sse = 0
return sse
def v_opt_dp(x, b):
... | 15851826258/UNSW_courses_XinchenWang | COMP9318/9318 Lab/lab2mmt.py | lab2mmt.py | py | 1,378 | python | en | code | 0 | github-code | 90 |
18371481259 | N, D = map(int, input().split())
X = [input().split() for i in range(N)]
count = 0
d_2 = 0
d = 0
for i in range(1, N):
for j in range(0, i):
d_2 = 0
d = 0
for k in range(D):
d_2 += (float(X[i][k]) - float(X[j][k]))**2
d = d_2**(1/2)
if d.is_integer() == True:
... | Aasthaengg/IBMdataset | Python_codes/p02982/s720106210.py | s720106210.py | py | 368 | python | en | code | 0 | github-code | 90 |
30071730330 | # -*- coding: utf-8 -*-
# @Author: JanKin Cai
# @Date: 2018-06-27 16:59:55
# @Last Modified by: caizhengxin16@163.com
# @Last Modified time: 2018-07-02 18:28:23
# 登录
from django.conf import settings
PREFIX = 'api'
SERVER_PORT = '443'
LOGIN_URL_PATH = 'checkUser'
# 基础防火墙
NEW_FIRE_RULE_PATH = 'NewF... | liushiwen555/unified_management_platform_backend | api_path_constants.py | api_path_constants.py | py | 4,738 | python | en | code | 0 | github-code | 90 |
18454284839 | from sys import stdin
s = int(stdin.readline().strip())
mem = []
a = s
for i in range(1000000):
if a in mem:
print(i+1)
exit()
mem.append(a)
if a % 2 == 0: a = a // 2
else: a = 3 * a + 1 | Aasthaengg/IBMdataset | Python_codes/p03146/s328161560.py | s328161560.py | py | 204 | python | en | code | 0 | github-code | 90 |
6236315514 | #!/usr/bin/env python
from setuptools import setup, find_packages
import ite8291r3_ctl
with open("README.md") as f:
long_description = f.read()
setup(
name='ite8291r3-ctl',
version=ite8291r3_ctl.__version__,
description='ITE 8291 (rev 0.03) userspace driver',
long_description=long_description,
long_descriptio... | Slimbook-Team/keyboard | backlight/titan/ite8291r3-ctl/setup.py | setup.py | py | 1,355 | python | en | code | 5 | github-code | 90 |
33703187367 | # 문제 : 퀵 정렬
# 퀵 정렬을 구현해 N개의 정수를 정렬해 리스트 A에 넣고,
# A[N//2]에 저장된 값을 출력하는 프로그램을 만드시오.
# [입력]
# 첫 줄에 테스트케이스의 수 T가 주어진다. 1<=T<=50
# 다음 줄부터 테스트 케이스의 별로 정수의 개수 N이 주어지고, 다음 줄에 N개의 정수 ai가 주어진다.
# 5<=N<=1,000,000, 0 <= ai <= 1,000,000
# 2
# 5
# 2 2 1 1 3
# 10
# 7 5 4 1 2 10 3 6 9 8
# [출력]
# #1 2
# #2 6
# 각 줄마다 "#T" (T는 테스트 케이스 번호... | kimujinu/python_PS | SW_Expert_Problem10.py | SW_Expert_Problem10.py | py | 1,209 | python | ko | code | 0 | github-code | 90 |
28294404216 | import heapq
from collections import defaultdict
def get_itenerary(flights, source, destination, k):
prices = defaultdict(dict)
for u, v, cost in flights:
prices[u][v] = cost
path = [source]
visited = set()
heap = [(0, source, k+1, path)]
while heap:
cost, u, k, path = heapq.heappop(heap)
visite... | myhangshi/minus | games/get_itenerary.py | get_itenerary.py | py | 791 | python | en | code | 0 | github-code | 90 |
18416936879 | # -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().d... | Aasthaengg/IBMdataset | Python_codes/p03069/s059762178.py | s059762178.py | py | 970 | python | en | code | 0 | github-code | 90 |
73427602858 | '''.A file “t1.txt” contains alphanumeric characters. Open the file in suitable access mode such that user can able to write the content into file and then read it without closing the file. Write a program to write few more lines into file, read the file content, count and display the total number of capital letters, ... | Biancaa-R/simple-python-programs-for-absolute-beginers- | Assignment10/readwrite.py | readwrite.py | py | 561 | python | en | code | 0 | github-code | 90 |
73649297897 | import pybullet as p
import time
import pybullet_data
from dataset_generation_tools.robot_control.cartesian_robot_control import CartesianControl, Movements
from dataset_generation_tools.grasp_proposal_generator.grasp_proposal_types import TypesGenerator
from dataset_generation_tools.grasp_proposal_generator.proposal_... | LarissaCasteluci/MastersProject | 1DatasetGeneration/src/bullet_test.py | bullet_test.py | py | 2,301 | python | en | code | 0 | github-code | 90 |
73052608616 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 19 14:46:10 2019
@author: Jain
Input:
dt, tf, MC_n, xdim, au, bu
Output:
MC_propagation: 1st column represents the time step, everything else represent the states
"""
import numpy as np
from sklearn.utils import shuffle
import scipy
#... | axj307/Moment-Calculation | Airplane2D/MonteCarlo_propagation.py | MonteCarlo_propagation.py | py | 2,494 | python | en | code | 0 | github-code | 90 |
22831541524 | from transformers import BertTokenizer
from prep import get_train_dev_test
import pandas as pd
import numpy as np
from sklearn import preprocessing
import torch
from torch.utils.data import TensorDataset,DataLoader,RandomSampler
from nltk import word_tokenize,pos_tag,download
download('averaged_perceptron_tagger')
fro... | untergunter/enriched_stancy | bert_preprocessing.py | bert_preprocessing.py | py | 5,089 | python | en | code | 0 | github-code | 90 |
71440872616 | # Geopy for coordinates and distances
from geopy.geocoders import Nominatim
from geopy.distance import geodesic
# Pandas to read cities names
import pandas as pd
import numpy as np
from dataPath import *
names = ['id', 'cities']
for i in range(1, 53):
names.append(str(i))
names.append('total')
# Get all cities... | Franreno/RJNetwork | munincipiosRJ/rj_csv.py | rj_csv.py | py | 3,407 | python | en | code | 0 | github-code | 90 |
41979806187 | from random import randint, choice
from turtle import Turtle
COLORS = ["red", "orange", "yellow", "black", "blue", "purple"]
STARTING_MOVE_DISTANCE = 5
MOVE_INCREMENT = 10
class CarManager(Turtle):
def __init__(self):
super().__init__()
self.penup()
self.speed("fastest")
self.sha... | RubenPinheiro/cross-road-game | car_manager.py | car_manager.py | py | 547 | python | en | code | 0 | github-code | 90 |
18792361266 | from django.http import HttpResponse
from django.template import loader
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.permissions import IsAuthenticated
from rest_framework import generics, pagination
from rest_framework.views import APIView
from rest_framework.response import Respon... | dmitryro/django-starter | api/api/video/views.py | views.py | py | 1,963 | python | en | code | 0 | github-code | 90 |
18580187599 | import sys, os
f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
sys.stdin = open('./input.txt', 'r')
def solve():
m = f()[0]
print(24*2 - m)
solve()
| Aasthaengg/IBMdataset | Python_codes/p03473/s348595268.py | s348595268.py | py | 184 | python | en | code | 0 | github-code | 90 |
11299662169 | # -*- coding: utf-8 -*-
# Usage: python landscape_envelope.py
from tqdm import tqdm
from pycalphad import equilibrium
from pycalphad import variables as v
from constants import *
Titles = (r"$\gamma$", r"$\delta$", r"Laves")
xspan = (-0.05, 1.05)
yspan = (-0.05, 0.95)
nfun = 3
npts = 500
ncon = 100
xmin = 1.0e-4
xma... | usnistgov/phasefield-precipitate-aging | thermo/landscape_envelope.py | landscape_envelope.py | py | 1,736 | python | en | code | 29 | github-code | 90 |
18464434209 | import sys
def main():
out = 0
for i in range(1, n+1):
if dp[i]:
di = dp[i]
if di > out:
out = di
else:
di = cal(i)
if di > out:
out = di
print(out)
def cal(a):
if xy[a]:
ans = 0
for b in xy[a]:
if dp[b]:
num = dp[b]
e... | Aasthaengg/IBMdataset | Python_codes/p03166/s906894159.py | s906894159.py | py | 669 | python | en | code | 0 | github-code | 90 |
43442057987 | """
while conditie:
cod - instructiuni
cod
cod
"""
# executam de 3 x print
from re import X
n = 0
while n < 3:
print("Hello")
n = n + 1
# 1. n = 0
# 2. n = 1
# 3. n = 2
# 4. n = 3 - nu se executa
n = 6
k = 1
n = int(input("Introdu n: "))
k = 1
while k <= n:
print("*" * k, "+" * (n... | tohhhi/it_school_2022 | Sesiunea 4/while.py | while.py | py | 417 | python | en | code | 0 | github-code | 90 |
18490459959 | from collections import Counter
n = int(input())
v = list(map(int, input().split()))
x = Counter(v[::2]).most_common(2)
y = Counter(v[1::2]).most_common(2)
ans = n
if x[0][0] == y[0][0]:
if len(x) == len(y) == 1:
ans = n//2
else:
s = max([a[1] for a in x]) + min([b[1] for b in y])
t = min([a[1] for a ... | Aasthaengg/IBMdataset | Python_codes/p03244/s164386917.py | s164386917.py | py | 416 | python | en | code | 0 | github-code | 90 |
73775827495 | # -*- coding: utf-8 -*-
# Author:songroger
# Aug.13.2016
from __future__ import unicode_literals
import json
import traceback
from pttools.pthttp import PtHttpResponse
from django.views.decorators.http import require_http_methods, require_safe
from django.contrib.auth.decorators import login_required
from tab.utils imp... | cash2one/pt | cms/cms/tab/api.py | api.py | py | 2,004 | python | en | code | 0 | github-code | 90 |
17983056019 | def main():
N = int(input())
a = [int(input()) for _ in range(N)]
cnt = 0
tmp = 1
while cnt<=100001:
tmp = a[tmp-1]
cnt += 1
if tmp == 2:
return cnt
elif tmp == 1:
return -1
return -1
print(main())
| Aasthaengg/IBMdataset | Python_codes/p03680/s499367101.py | s499367101.py | py | 280 | python | en | code | 0 | github-code | 90 |
22377359315 | # 리턴값을 구하는 재귀 함수
# 호출되는 함수 순서: Fn(5), Fn(4), Fn(3), Fn(2), Fn(1) 종료
# 계산되는 순서: Fn(1), Fn(2), Fn(3), Fn(4), Fn(5)
# 종료조건을 만난 뒤, 호출된 함수 반대방향으로 계산하여 리턴
def Fn(n):
if n == 1:
return n
return n * Fn(n-1)
print(Fn(5))
# 리턴값을 구하지 않는 재귀 함수 (res에 함수인자를 기록하는 게 목적)
# 호출되는 함수 순서: Fn(5), Fn(4), Fn(3), Fn(2), Fn(1... | hannayangg/penwing | # ridi/재귀 순서!!!.py | 재귀 순서!!!.py | py | 1,196 | python | ko | code | 0 | github-code | 90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.