blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
48ea70aaf45047d633f7469efd286ddcfb1a4ec3
jamesjakeies/python-api-tesing
/python3.7quick/5polygon.py
347
4.53125
5
# polygon.py # Draw regular polygons from turtle import * def polygon(n, length): """Draw n-sided polygon with given side length.""" for _ in range(n): forward(length) left(360/n) def main(): """Draw polygons with 3-9 sides.""" for n in range(3, 10): polygon(n, 80) ...
1f7ed4325ab493a60d95e04fa38d22d30578a966
jamesjakeies/python-api-tesing
/python3.7quick/4face.py
622
4.25
4
# face.py # Draw a face using functions. from turtle import * def circle_at(x, y, r): """Draw circle with center (x, y) radius r.""" penup() goto(x, y - r) pendown() setheading(0) circle(r) def eye(x, y, radius): """Draw an eye centered at (x, y) of given radius.""" circle_at(x, y, ra...
d6d0c17beb728a9731c6869436b05a2df5805458
jamesjakeies/python-api-tesing
/python_crash_tutorial/Ch2/mymax2.py
689
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author: xurongzhong#126.com wechat:pythontesting qq:37391319 # 技术支持 钉钉群:21745728(可以加钉钉pythontesting邀请加入) # qq群:144081101 591302926 567351477 # CreateDate: 2018-6-12 # mymax2.py # Write max function without built-in max(). def mymax2(x, y): """Return larger of ...
8b356cc4864e395ad9b3f85e7ed89774d0a1fe3e
jamesjakeies/python-api-tesing
/python_crash_tutorial/Ch2/evens_comp.py
200
4.21875
4
# evens_comp.py # Find even values in a list of numbers using list comprehension def evens(items): """Return list of even values in items.""" return [item for item in items if item % 2 == 0]
68f115a2695bbabb5b8fbfadb15119bbad899585
jamesjakeies/python-api-tesing
/python_crash_tutorial/Ch2/mymin.py
235
4.09375
4
# mymin.py # Find smallest element of a list def mymin(items): """Return smallest element in items.""" smallest = items[0] for item in items[1:]: if item < smallest: smallest = item return smallest
29362f4276d7ac83c520b89417bed94d2a771a4f
jamesjakeies/python-api-tesing
/python_crash_tutorial/Ch1/randomwalk.py
352
4.25
4
# randomwalk.py # Draw path of a random walk. from turtle import * from random import randrange def random_move(distance): """Take random step on a grid.""" left(randrange(0, 360, 90)) forward(distance) def main(): speed(0) while abs(xcor()) < 200 and abs(ycor()) < 200: random_move(10...
758a998bc6b956e29baec359b0d916ff8992fd32
Chetan2808/Basic-Python-Questions
/Find_Substring.py
116
3.71875
4
User=input("Enter a string:") for i in range(len(User)): for j in range(i,len(User)): print(User[i:j+1])
72ccfe3dc8a06d969b0a10750ff5e759c3362367
waynelinbo/ToC_DEMO
/GuessA4B4.py
1,929
3.546875
4
import random class GuessA4B4(): def __init__(self): self.answer = "" self.record = "" self.generate() def generate(self): self.record = "" a = int((random.random())*10) b = int((random.random())*10) while b == a : b = int((rando...
a3a9af479cf44706b7a4f4902e64ebcabf88094c
WillDutcher/Python_Essential_Training
/chap05/precedence.py
682
4.03125
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Completed Chap05: Lesson 24 - Operator precedence # Precedence order is: print("**\n\tExponent\n") print("+x, -x\n\tPositive, negative\n") print("*, /, //, %\n\tMultiplication, division, remainder\n") print("+, -\n\tAddition and subtraction\n"...
51578c97eb0b4a7478be114fa2eca98b713613ca
WillDutcher/Python_Essential_Training
/Chap05/bitwise.py
674
4.375
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Completed Chap05: Lesson 21 - Bitwise operators x = 0x0a y = 0x02 z = x & y # 02x gives two-character string, hexadecimal, with leading zero # 0 = leading zero # 2 = two characters wide # x = hexadecimal display of integer value # 08b gives eight-char...
2b5a45674ba5f67b391b312f89361584336efb8c
WillDutcher/Python_Essential_Training
/Chap02/while.py
627
3.71875
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ words = ['one', 'two', 'three', 'four', 'five'] n = 0 while(n < 5): print(words[n]) n += 1 moreWords = ["ten", "nine", "eight", "seven", "six", "five", "four", "three", "two", "one", "zero"] x = 10 while(x < 11): print('x = ', moreWords[x]) ...
1ce0280f860821796f022583f2b5b96950f587b9
WillDutcher/Python_Essential_Training
/Chap05/boolean.py
670
4.1875
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Completed Chap05: Lesson 23 - Comparison operators print("\nand\t\tAnd") print("or\t\tOr") print("not\t\tNot") print("in\t\tValue in set") print("not in\t\tValue not in set") print("is\t\tSame object identity") print("is not\t\tNot same object identity...
192b0b3df4141933e1bbb32f231016f6df1ff8b6
Purav16/Collections-Java-Data-Structures-Java-Python-3.6-JavaScript-Programs
/Reversed_Array.py
145
3.5625
4
import numpy as np import numpy as np x = np.arange(12, 38) print("Original array:") print(x) print("Reverse array:") x = x[::-1] print(x)
3034e9856e10055dce53165daf2219e69158ceea
Purav16/Collections-Java-Data-Structures-Java-Python-3.6-JavaScript-Programs
/Python list operations.py
411
3.859375
4
#list operations power = [1,2,3,4,5,6,7,8,9] list2 = [x*x for x in power] print(list2) #getting values wth both lists #Square operation within the list with index values list3 = [[x,x*x] for x in power] print(list3) #loops list4 = [x*x for x in power if x > 4] print(list4) #Strip() function list5 = ['111n111', '111m...
b550146c5d6d639c6e90bcc3b43078f00c5ee973
Purav16/Collections-Java-Data-Structures-Java-Python-3.6-JavaScript-Programs
/Sets_Duplication_Python.py
197
3.953125
4
#Python Sets set_1 = {'One' , 'Two' , 'Three' , 'Four'} print_set={x for x in set_1} print(print_set,1) #Duplication removal/not allowed in Sets a = set('vslvnlsndlsvSHVJskdslhsjksaa') print(a)
fef1ca3fec0d8aa599fba152711d7715fc4bcbe7
Qg2TzVSm/leetcode
/arraypartitioni.py
940
3.609375
4
# Given an array of 2n integers, # your task is to group these integers into n pairs of integer, # say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n # as large as possible. # Example 1: # Input: [1,4,3,2] # Output: 4 # Explanation: n is 2, and the maximum sum of pairs is 4 ...
501c5e366a15a6a278849893d83c9497d8bf3c19
BhuviGoel/Backup-Files
/backupFiles.py
1,933
4.09375
4
import os import shutil import time def main(): # initializing the count deleted_folders_count = 0 deleted_files_count = 0 # specify the path path = input("Enter the path of files/folder you want to delete: ") # converting days to seconds days = 30 seconds = time.time() - (days * 24 * 60 * 60) if os.path.e...
f6f56d895de0d31d13cbd555a4c467ff87a128c6
krishna6431/Python-For-Everybody-Specialization-Coursera-Assignment
/Course3_Using Python to Access Web Data/Week6_JSON/Assignment1/json_parsing.py
484
3.890625
4
# json parsing assignment #code is written by krishna #part of course 3 of python for everybody specialization import json import urllib.request url=input("Enter location: ") data=urllib.request.urlopen(url).read().decode('utf-8') print("Retrieving",url) print("Retrieved",len(data),"characters") info=json.load...
c3a7c04b0d8508310f94bde26fd9cb387dd95d9b
krishna6431/Python-For-Everybody-Specialization-Coursera-Assignment
/Course2_Python Data Structures/Week1_Graded_Assignment/week1_assignment.py
445
3.765625
4
# Problem Statement : # 6.5 Write code using find() and string slicing (see section 6.10) to extract # the number at the end of the line below. Convert the extracted value to a # floating point number and print it out. # Code is Written By Krishna # The code below almost works text = "X-DSPAM-Confidence...
e11c85cd026cab5ee7c69cba87b1a1f9d5ee8812
frendylio/EE362
/Quizes/selection.py
587
3.90625
4
def selection(L): # Para todos los indexes for LoopIndexes in range(len(L)): IndexMin = LoopIndexes for LoopMin in range(LoopIndexes+1, len(L)): if L[IndexMin] > L[LoopMin]: IndexMin = LoopMin # Cambia el IndexMin wit...
04a8f02c0f4f8ed0e69ee61eac3d7fc15c511570
spacesanjeet/Calculator_func
/calculator_func2.py
3,292
4.21875
4
# author: sanjeet # calculator with functions import math # math module def _sum(x, y): # addition funcition return x + y def subtract(x, y): # subtraction function return x - y def multiply(x, y): # multiplication function return x * y def divide(x, y): # division function return x / y def f...
a2c421eb4362050d43e86b98dd059a7d60c42f2d
Gborgman05/algs
/py/recursion/pascals_triangle_row.py
464
3.671875
4
# returns a list representing that row in pascals triangle # row index starts at 0 for [1] class Solution: def getRow(self, rowIndex: int) -> List[int]: if rowIndex == 0: return [1] else: prev = self.getRow(rowIndex - 1) summed = [1] for i in range(len...
c39b64942c8f2733a95a17299b71a8bdcf27c186
Gborgman05/algs
/ds_scratch/queue.py
322
3.515625
4
# Galen Borgman # 8/17/2022 # queue class Q: def __init__(self, contents=None): if contents: self.contents = contents self.len = len(contents) else: self.contents = [] self.len = 0 def __len__(self): return self.len # def enqueue(self,...
4b19e1b99629ed304bad294febfa89a0889959d3
Gborgman05/algs
/py/binary_search.py
985
3.609375
4
import pdb # https://leetcode.com/problems/binary-search/submissions/ class Solution: def search(self, nums) -> int: def sub_search(nums, target, min_index, max_index): index = (max_index + min_index) // 2 if max_index < min_index: return -1 elif nums[inde...
40a908c9b3cf99674e66b75f56809d485f0a81f9
Gborgman05/algs
/py/populate_right_pointers.py
1,019
3.859375
4
""" # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, root: 'Optional[Node]') -> 'Option...
d1c0270de8164f19ea92d9683d6e320cd3d3e37b
Gborgman05/algs
/py/two_sum_sorted.py
482
3.59375
4
# common problem variant, the input array is sorted class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: # Use two pointers traverse from others start = 0 end = len(numbers) - 1 while start < end: summ = numbers[start] + numbers[end] ...
4675d4799ea461abc8cbf6dc89446c5fd0814e23
Gborgman05/algs
/llist/rot_llist.py
785
3.921875
4
# https://leetcode.com/explore/learn/card/linked-list/213/conclusion/1295/ # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[ListNo...
b0bee34fec7a1510ab5c017f505e1495fc15bcf9
Gborgman05/algs
/py/is_power_of_three.py
252
3.640625
4
class Solution: def isPowerOfThree(self, n: int) -> bool: po = 0 tst = 0 while n > tst: tst = 3 ** po if n == tst: return True po += 1 return False
f4fe5b4f7033a7378bb3cee62f1044e49a1b48da
Gborgman05/algs
/py/reverse_words.py
490
3.71875
4
# reverses words but maintains the order of words in a sentence s class Solution: def reverseWords(self, s: str) -> str: def reverse(word): word = list(word) l = 0 h = len(word) - 1 while l < h: tmp = word[l] word[l] = word[h] ...
0de0a4d4ab72a858625e1f5778457805ad813e7f
JoshuaKrause/Diodes
/python/game.py
3,288
3.859375
4
import player import board import deck import random import copy class Game(): def __init__(self, player_one=player.Player("ONE"), player_two=player.Player("TWO")): self.player_one = player_one self.player_two = player_two self.active_player = self.player_one self.other_player = se...
9be5e6cad8942160830e3d4bcca8c66dcac52370
Avinashgurugubelli/python_data_structures
/linked_lists/singly_linked_list/main.py
2,546
4.46875
4
from linked_list import LinkedList from node import Node # Code execution starts here if __name__ == '__main__': # Start with the empty list linked_list_1 = LinkedList() # region nodes creation first_node, second_node, third_node = Node(), Node(), Node() first_node.data = 5 second_node.data = 1...
901a642b7560b36db5eefdc85f3df7d50919a136
Avinashgurugubelli/python_data_structures
/linked_lists/doubly_linked_lists/doubly_linked_list.py
4,462
3.59375
4
from dl_node import DLNode class DoublyLinkedList: def __init__(self): self.head = DLNode # print list def print_list(self): current_node = self.head while current_node != None: print(str(current_node.data)) current_node = current_node.next def get_len...
2156df459912744499eb02f3c4fc9418428a85a9
DayGitH/Python-Challenges
/DailyProgrammer/DP20150601A.py
4,068
3.5
4
""" [2015-06-01] Challenge #217 [Easy] Lumberjack Pile Problem https://www.reddit.com/r/dailyprogrammer/comments/3840rp/20150601_challenge_217_easy_lumberjack_pile/ #Description: The famous lumberjacks of /r/dailyprogrammer are well known to be weird and interesting. But we always enjoy solving their problems with s...
37c053274b93adc82558ab9dcca33eaac67fc591
DayGitH/Python-Challenges
/DailyProgrammer/DP20171121A.py
2,141
3.96875
4
""" [2017-11-21] Challenge #341 [Easy] Repeating Numbers https://www.reddit.com/r/dailyprogrammer/comments/7eh6k8/20171121_challenge_341_easy_repeating_numbers/ #Description Locate all repeating numbers in a given number of digits. The size of the number that gets repeated should be more than 1. You may either accept...
66231a3abc2241b21c33466b458eed3ac198ec13
DayGitH/Python-Challenges
/DailyProgrammer/20120307C.py
2,606
4.09375
4
# -*- coding: utf-8 -*- ''' Challenge #19 will use The Adventures of Sherlock Holmes [https://www.gutenberg.org/cache/epub/1661/pg1661.txt] from Project Gutenberg [https://www.gutenberg.org/]. Write a program that will build and output a word index for The Adventures of Sherlock Holmes. Assume one page contains 40 lin...
e6deb9da2c71fc5474e85b1fc19b40c1d1796d0f
DayGitH/Python-Challenges
/DailyProgrammer/DP20150213C.py
6,309
3.546875
4
""" [2015-02-13] Challenge #201 [Hard] Mission Improbable https://www.reddit.com/r/dailyprogrammer/comments/2vs1c6/20150213_challenge_201_hard_mission_improbable/ # **(Hard)**: Mission Improbable Imagine a scenario involving one event - let's call it event A. Now, this event can either happen, or it can not happen. T...
6413f86569da08a37374f72a6c330b1fd67ff02e
DayGitH/Python-Challenges
/DailyProgrammer/DP20170705B.py
896
4.21875
4
""" [2017-07-05] Challenge #322 [Intermediate] Largest Palindrome https://www.reddit.com/r/dailyprogrammer/comments/6ldv3m/20170705_challenge_322_intermediate_largest/ # Description Write a program that, given an integer input n, prints the largest integer that is a palindrome and has two factors both of string lengt...
8361a2e4b7a97bc2728ff6df895f0b77a184661d
DayGitH/Python-Challenges
/DailyProgrammer/DP20141031.py
6,892
3.625
4
""" [10/31/2014] Challenge #186 [Special] Code or Treat - Halloween 2014 https://www.reddit.com/r/dailyprogrammer/comments/2kwfqr/10312014_challenge_186_special_code_or_treat/ #Description: Happy Halloween. For Today's challenge we will go off our typical path and do a special challenge posting. I have come up with 2...
d3028bc45866eafad2bc8500fb8454c0ee67a798
DayGitH/Python-Challenges
/DailyProgrammer/DP20130308C.py
2,818
3.5
4
""" [03/08/13] Challenge #120 [Hard] Bytelandian Exchange 3 https://www.reddit.com/r/dailyprogrammer/comments/19whtk/030813_challenge_120_hard_bytelandian_exchange_3/ # [](#HardIcon) *(Hard)*: Bytelandian Exchange 3 Bytelandian Currency is coins with positive integers on them. (Don't worry about 0-valued coins becaus...
20cf5b34e570d982ae6a87c47d62ddab00c2b011
DayGitH/Python-Challenges
/DailyProgrammer/DP20130701A.py
2,368
3.875
4
""" [07/01/13] Challenge #131 [Easy] Who tests the tests? https://www.reddit.com/r/dailyprogrammer/comments/1heozl/070113_challenge_131_easy_who_tests_the_tests/ # [](#EasyIcon) *(Easy)*: Who tests the tests? [Unit Testing](http://en.wikipedia.org/wiki/Unit_testing) is one of the more basic, but effective, tools for ...
72b14d6febd7390c2adb660e704e6c62276a45b1
DayGitH/Python-Challenges
/ProjectEuler/pr0016.py
204
3.8125
4
""" 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? """ number = 2**1000 sum = 0 for n in str(number): sum += int(n) print(sum)
dda4acd237e4f4c44dcbd0febd58e09c71b83183
DayGitH/Python-Challenges
/DailyProgrammer/20120430C.py
1,368
4.09375
4
""" The prime HP reached starting from a number , concatenating its prime factors, and repeating until a prime is reached. If you have doubts, refer the article here [http://mathworld.wolfram.com/HomePrime.html] write a function to calculate the HP of a given number. Also write a function to compute the Euclid-Mullin...
9843b352194d21f8a67d7de52ba0b2c59c27bc2f
DayGitH/Python-Challenges
/DailyProgrammer/DP20160916C.py
2,259
4.25
4
""" [2016-09-16] Challenge #283 [Hard] Guarding the Coast https://www.reddit.com/r/dailyprogrammer/comments/5320ey/20160916_challenge_283_hard_guarding_the_coast/ # Description Imagine you're in charge of the coast guard for your island nation, but you're on a budget. You have to minimize how many boats, helicopters ...
78237d17e529cdd02fe42dd409c705b22e255eb8
DayGitH/Python-Challenges
/DailyProgrammer/20120403B.py
1,081
4.46875
4
""" Imagine you are given a function flip() that returns a random bit (0 or 1 with equal probability). Write a program that uses flip to generate a random number in the range 0...N-1 such that each of the N numbers is generated with equal probability. For instance, if your program is run with N = 6, then it will genera...
f050174939af3edb52e8fa2e13b61909a7f469aa
DayGitH/Python-Challenges
/DailyProgrammer/DP20160406B.py
2,394
3.84375
4
""" [2016-04-06] Challenge #261 [Intermediate] rearranged magic squares https://www.reddit.com/r/dailyprogrammer/comments/4dmm44/20160406_challenge_261_intermediate_rearranged/ # Description An NxN magic square is an NxN grid of the numbers 1 through N^2 such that each row, column, and major diagonal adds up to M = N...
e9e109a400f3da638ea1ba1e6a71e697f962ace3
DayGitH/Python-Challenges
/DailyProgrammer/DP20121120B.py
1,324
4.03125
4
""" [11/20/2012] Challenge #113 [Intermediate] Text Markup https://www.reddit.com/r/dailyprogrammer/comments/13hmz5/11202012_challenge_113_intermediate_text_markup/ **Description:** Many technologies, notably user-edited websites, take a source text with a special type of mark-up and output HTML code. As an example, ...
0b541c06a55954a41a1cf02de616696c28d9abf8
DayGitH/Python-Challenges
/DailyProgrammer/DP20121023B.py
1,571
4.1875
4
""" [10/23/2012] Challenge #106 [Intermediate] (Jugs) https://www.reddit.com/r/dailyprogrammer/comments/11xjfd/10232012_challenge_106_intermediate_jugs/ There exists a problem for which you must get exactly 4 gallons of liquid, using only a 3 gallon jug and a 5 gallon jug. You must fill, empty, and/or transfer liquid...
f4c2aa66b7f75d032477be09044bff09be73f24e
DayGitH/Python-Challenges
/DailyProgrammer/DP20150325B.py
4,693
3.546875
4
""" [2015-03-25] Challenge #207 [Intermediate] Bioinformatics 2: DNA Restriction Enzymes https://www.reddit.com/r/dailyprogrammer/comments/307m27/20150325_challenge_207_intermediate/ Continuing with our bioinformatics theme today. If you like these sorts of problems, I encourage you to check out Project Rosalind (the...
b268c2242ac7769abf8155f8299f3222452c706c
DayGitH/Python-Challenges
/DailyProgrammer/DP20120702A.py
1,509
4.28125
4
""" Before I get to today's problem, I'd just like to give a warm welcome to our two new moderators, nooodl and Steve132! We decided to appoint two new moderators instead of just one, because rya11111 has decided to a bit of a break for a while. I'd like to thank everyone who applied to be moderators, there were lots ...
612ed23619b17daf6df385d2f5eb9a363eadabdc
DayGitH/Python-Challenges
/DailyProgrammer/DP20140714A.py
1,387
4.09375
4
""" [7/14/2014] Challenge #171 [Easy] Hex to 8x8 Bitmap https://www.reddit.com/r/dailyprogrammer/comments/2ao99p/7142014_challenge_171_easy_hex_to_8x8_bitmap/ #Description: Today we will be making some simple 8x8 bitmap pictures. You will be given 8 hex values that can be 0-255 in decimal value (so 1 byte). Each valu...
08e590ff030b1b2a50b3a0caadd086f4def3630c
DayGitH/Python-Challenges
/DailyProgrammer/20120611B.py
2,005
4.40625
4
""" You can use the reverse(N, A) procedure defined in today's easy problem [20120611A] to completely sort a list. For instance, if we wanted to sort the list [2,5,4,3,1], you could execute the following series of reversals: A = [2, 5, 4, 3, 1] reverse(2, A) (A = [5, 2, 4, 3, 1]) reverse(5, A) (A = [1, 3,...
e1bbe5b69b0a21c4ab1cc925835b0167ef8dcbda
DayGitH/Python-Challenges
/DailyProgrammer/DP20170915C.py
3,041
3.890625
4
""" [2017-09-15] Challenge #331 [Hard] Interactive Interpreter https://www.reddit.com/r/dailyprogrammer/comments/7096nu/20170915_challenge_331_hard_interactive/ #Description Make an interactive interpreter with 2 different capabilities 1. It should be able to take a mathematical string (fx "5 + 2") and return the res...
8be851749005732519c82b72d3b7796187b59edc
DayGitH/Python-Challenges
/DailyProgrammer/DP20160408C.py
2,212
4.15625
4
""" [2016-04-08] Challenge #261 [Hard] magic square dominoes https://www.reddit.com/r/dailyprogrammer/comments/4dwk7b/20160408_challenge_261_hard_magic_square_dominoes/ # Description An NxN magic square is an NxN grid of the numbers 1 through N^2 such that each row, column, and major diagonal adds up to M = N(N^(2)+1...
ee03cfef4f096a1fd5b906914fdf0f20de7ca636
DayGitH/Python-Challenges
/DailyProgrammer/DP20140512A.py
4,159
3.515625
4
""" [5/12/2014] Challenge #162 [Easy] Novel Compression, pt. 1: Unpacking the Data https://www.reddit.com/r/dailyprogrammer/comments/25clki/5122014_challenge_162_easy_novel_compression_pt_1/ # [](#EasyIcon) _(Easy)_: Novel Compression, pt. 1: Unpacking the Data Welcome to this week's Theme Week. We're going to be cre...
d9e6142a29f8024d9e90061aa3adbe9348fe809d
DayGitH/Python-Challenges
/DailyProgrammer/DP20120927C.py
1,072
3.640625
4
""" [9/27/2012] Challenge #101 [difficult] (Boolean Minimization) https://www.reddit.com/r/dailyprogrammer/comments/10lbjo/9272012_challenge_101_difficult_boolean/ For difficult 101, I thought I'd do something with binary in it. Write a program that reads in a file containing 2^n 0s and 1s as ascii characters. You ...
245e17b2a3818b720d4b3add92f1a61fa6520148
DayGitH/Python-Challenges
/DailyProgrammer/DP20140905C.py
1,723
3.6875
4
""" [9/05/2014] Challenge #178 [Hard] Regular Expression Fractals https://www.reddit.com/r/dailyprogrammer/comments/2fkh8u/9052014_challenge_178_hard_regular_expression/ #Description: For today's challenge you will be generating fractal images from regular expressions. This album describes visually how it works: * [h...
0b0a585867ad3f4081fb6734d314797ad4dfe6e3
DayGitH/Python-Challenges
/DailyProgrammer/20120310A.py
363
4.1875
4
""" Write a program that will compare two lists, and append any elements in the second list that doesn't exist in the first. input: ["a","b","c",1,4,], ["a", "x", 34, "4"] output: ["a", "b", "c",1,4,"x",34, "4"] """ inp1 = ["a","b","c",1,4,] inp2 = ["a", "x", 34, "4"] final = inp1[:] for a in inp2: if a not in f...
9d08436fd87235a0f4682b3c1d62897fcd53bb30
DayGitH/Python-Challenges
/DailyProgrammer/DP20140602A.py
4,494
3.578125
4
""" [6/2/2014] Challenge #165 [Easy] ASCII Game of Life https://www.reddit.com/r/dailyprogrammer/comments/271xyp/622014_challenge_165_easy_ascii_game_of_life/ # [](#EasyIcon) _(Easy)_: ASCII Game of Life Hello people. Sorry for submitting this early, but I have exams this week and the next so I'll have to submit thes...
bec41056bd304f919fda37f71847a03c7e963d1a
DayGitH/Python-Challenges
/DailyProgrammer/20120509C.py
2,551
3.734375
4
""" T9 Spelling: The Latin alphabet contains 26 characters and telephones only have ten digits on the keypad. We would like to make it easier to write a message to your friend using a sequence of keypresses to indicate the desired characters. The letters are mapped onto the digits as 2=ABC, 3=DEF, 4=GHI, 5=JKL, 6=MNO, ...
6bfd5474c2198120894dafdbd17ee6ac8a063a51
DayGitH/Python-Challenges
/ProjectEuler/pr0025.py
582
3.75
4
""" The Fibonacci sequence is defined by the recurrence relation: F(n) = F(n−1) + F(n−2), where F(1) = 1 and F(2) = 1. Hence the first 12 terms will be: F(1) = 1 F(2) = 1 F(3) = 2 F(4) = 3 F(5) = 5 F(6) = 8 F(7) = 13 F(8) = 21 F(9) = 34 F(10) = 55 F(11) = 89 F(12) = 144 The 12th term, F(12), is the first term to cont...
280830e249c6aa473cc2e635872ced65a46b687b
DayGitH/Python-Challenges
/DailyProgrammer/DP20140606C.py
9,427
3.6875
4
""" [6/6/2014] Challenge #165 [Hard] Simulated Ecology - The Forest https://www.reddit.com/r/dailyprogrammer/comments/27h53e/662014_challenge_165_hard_simulated_ecology_the/ #Description: The study of balance is interesting. Take for example a forest. Forests are very complex eco-systems with lots of things happening...
a79267445937abe1983f1c084b700732ca840e21
DayGitH/Python-Challenges
/DailyProgrammer/DP20150803A.py
2,995
3.703125
4
""" [2015-08-03] Challenge #226 [Easy] Adding fractions https://www.reddit.com/r/dailyprogrammer/comments/3fmke1/20150803_challenge_226_easy_adding_fractions/ #Description Fractions are the bane of existence for many elementary and middle-schoolers. They're sort-of hard to get your head around (though thinking of th...
cedde37647701d970cc14b091dd084966a18d480
DayGitH/Python-Challenges
/DailyProgrammer/DP20120808A.py
1,026
4.1875
4
""" [8/8/2012] Challenge #86 [easy] (run-length encoding) https://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/ Run-Length encoding is a simple form of compression that detects 'runs' of repeated instances of a symbol in a string and compresses them to a list of pairs of...
e78435c9acf2b2a8331204b05a3c6c29dfebf685
DayGitH/Python-Challenges
/DailyProgrammer/DP20150116C.py
982
3.875
4
""" [2015-01-16] Challenge #197 [Hard] Crazy Professor https://www.reddit.com/r/dailyprogrammer/comments/2snhei/20150116_challenge_197_hard_crazy_professor/ #Description He's at it again, the professor at the department of Computer Science has posed a question to all his students knowing that they can't brute-force i...
9dbec4d1133da2b905f6a952f6df5f8248255947
DayGitH/Python-Challenges
/DailyProgrammer/DP20151102A.py
2,174
3.625
4
""" [2015-11-02] Challenge #239 [Easy] A Game of Threes https://www.reddit.com/r/dailyprogrammer/comments/3r7wxz/20151102_challenge_239_easy_a_game_of_threes/ # Background Back in middle school, I had a peculiar way of dealing with super boring classes. I would take my handy pocket calculator and play a "Game of Thre...
47d2c0703237402d0fd293c70078af9f4b3554b4
DayGitH/Python-Challenges
/DailyProgrammer/DP20150626C.py
3,776
3.8125
4
""" [2015-06-26] Challenge #220 [Hard] Substitution Cryptanalysis https://www.reddit.com/r/dailyprogrammer/comments/3b668g/20150626_challenge_220_hard_substitution/ # [](#HardIcon) _(Hard)_: Substitution Cryptanalysis A [substitution cipher](https://en.wikipedia.org/?title=Substitution_cipher) is one where each lette...
679d823627f1fc41e7027d234a4ae51b9ba3868d
DayGitH/Python-Challenges
/ProjectEuler/pr0019.py
1,393
4.15625
4
""" You are given the following information, but you may prefer to do some research for yourself. * 1 Jan 1900 was a Monday. * Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on le...
90235fc4d5cb7fb5095d8d21808a2166454234ef
DayGitH/Python-Challenges
/DailyProgrammer/DP20150415B.py
3,981
3.609375
4
""" [2015-04-15] Challenge #210 [Intermediate] Drawing a gradient https://www.reddit.com/r/dailyprogrammer/comments/32o5je/20150415_challenge_210_intermediate_drawing_a/ #Description One of the most basic tools in graphic design toolbox is the "gradient": a smooth transtion from one color to another. They are remarka...
af89dc719535ca89d2bd27e9ca476b048a376d03
DayGitH/Python-Challenges
/ProjectEuler/pr0007.py
547
3.734375
4
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? """ prime = [] for i in range(2,1000000): prime.append(i) p = 0 for i in range(10001): p_hold = prime prime = [] for j in range(len(p_hold)): i...
bdd280fdbe78f8e99334d500a57772cf37cfd0d5
DayGitH/Python-Challenges
/DailyProgrammer/DP20170911A.py
2,361
3.65625
4
""" [2017-09-11] Challenge #331 [Easy] The Adding Calculator https://www.reddit.com/r/dailyprogrammer/comments/6ze9z0/20170911_challenge_331_easy_the_adding_calculator/ #**Description** Make a calculator that lets the user add, subtract, multiply and divide integers. It should allow exponents too. The user can only e...
dca128ba4183ba191a980e31fbe857280b70450f
DayGitH/Python-Challenges
/DailyProgrammer/20120331A.py
502
4.125
4
""" A very basic challenge: In this challenge, the input is are : 3 numbers as arguments output: the sum of the squares of the two larger numbers. Your task is to write the indicated challenge. """ """ NOTE: This script requires three input arguments!!! """ import sys arguments = len(sys.argv) if arguments != 4: ...
3cb5639cb47499b5ccb10a6c81ef215d291f4cac
DayGitH/Python-Challenges
/DailyProgrammer/DP20161104C.py
2,292
3.625
4
""" [2016-11-04] Challenge #290 [Hard] Gophers and Robot Dogs https://www.reddit.com/r/dailyprogrammer/comments/5b5fc8/20161104_challenge_290_hard_gophers_and_robot_dogs/ # Description You're a farmer in the future. Due to some freak accident, all dogs were wiped out but gophers have multiplied and they're causing ha...
036b8b85dadb10cf663d178105c4b0415c1d2db3
DayGitH/Python-Challenges
/DailyProgrammer/DP20180129A.py
2,013
4.09375
4
""" [2018-01-29] Challenge #349 [Easy] Change Calculator https://www.reddit.com/r/dailyprogrammer/comments/7ttiq5/20180129_challenge_349_easy_change_calculator/ # Description You own a nice tiny mini-market that sells candies to children. You need to know if you'll be able to give the change back to those little cute...
7d6088c5b27834e9b49c1c7b3c9d3aa5da6b5830
DayGitH/Python-Challenges
/DailyProgrammer/DP20130510C.py
7,377
3.9375
4
""" [05/10/13] Challenge #123 [Hard] Robot Jousting https://www.reddit.com/r/dailyprogrammer/comments/1ej32w/051013_challenge_123_hard_robot_jousting/ # [](#HardIcon) *(Hard)*: Robot Jousting You are an expert in the new and exciting field of *Robot Jousting*! Yes, you read that right: robots that charge one another ...
ff0d12abcd0f3b346d1da0bb9b0ac5aa0c25f473
DayGitH/Python-Challenges
/DailyProgrammer/20120216C.py
975
4.125
4
''' Write a program that will take coordinates, and tell you the corresponding number in pascals triangle. For example: Input: 1, 1 output:1 input: 4, 2 output: 3 input: 1, 19 output: error/nonexistent/whatever the format should be "line number, integer number" for extra credit, add a function to simply print the trian...
cbba0ab3d131440d47fdef8f7d07547336af3907
DayGitH/Python-Challenges
/DailyProgrammer/DP20120725A.py
2,279
3.875
4
""" [7/25/2012] Challenge #81 [easy] (Numerical Calculus I) https://www.reddit.com/r/dailyprogrammer/comments/x538d/7252012_challenge_81_easy_numerical_calculus_i/ For a lot of the questions today we are going to be doing some simple numerical calculus. Don't worry, its not too terrifying. For the easy problem, writ...
da1c9b2309bcb28b19380e16562cc6d9fa61ac93
DayGitH/Python-Challenges
/DailyProgrammer/20120211A.py
838
4.03125
4
''' Welcome to cipher day! write a program that can encrypt texts with an alphabetical caesar cipher. This cipher can ignore numbers, symbols, and whitespace. for extra credit, add a "decrypt" function to your program! ''' import sys alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' print('Input the text for encryption,') inp...
bf074df36ff312a7b616a70d03d6582f6e163521
DayGitH/Python-Challenges
/DailyProgrammer/20120425C.py
2,160
3.921875
4
""" Write a function that takes two arguments a and b, and finds all primes that are between a and a + b (specifically, find all primes p such that a ? p < a + b). So for instance, for a = 1234 and b = 100, it should return the following 15 primes: 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307,...
68c014d313a049966da48f75f56b279e980bfb58
DayGitH/Python-Challenges
/DailyProgrammer/20120423B.py
3,851
4.03125
4
""" We have it easy nowadays when it comes to numbers. It's so simple to add them and subtract them that we don't even consider that it wasn't always so. Even multiplication is not that tough! And you can represent very large numbers very easily, if you want to write down a million, you just write "1000000". That's onl...
ec8b3baa135800c1fc1b0564018f824a3cd44540
DayGitH/Python-Challenges
/ProjectEuler/pr0024.py
972
3.640625
4
""" A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210 Wh...
b458bc61c6a7741fb6015238ce41c712897c544b
DayGitH/Python-Challenges
/DailyProgrammer/DP20160902C.py
2,163
3.515625
4
""" [2016-09-02] Challenge #281 [Hard] Minesweeper Solver https://www.reddit.com/r/dailyprogrammer/comments/50s3ax/20160902_challenge_281_hard_minesweeper_solver/ #Description In this challenge you will come up with an algorithm to solve the classic game of [Minesweeper](http://minesweeperonline.com/). The brute forc...
839e72987bf0d6d3c5a1682de13afc4ae40e6435
DayGitH/Python-Challenges
/DailyProgrammer/DP20130102C.py
3,989
3.75
4
""" [1/2/2013] Challenge #115 [Difficult] Pack-o-Tron 5000 https://www.reddit.com/r/dailyprogrammer/comments/15uohz/122013_challenge_115_difficult_packotron_5000/ **Description:** Overdrive Mega-Corporation is coming out with a new and brilliant commercial electronic device that packs your bags for you! It is named "...
155d9e1fae2d2739a92f65466b0596c7a0765285
DayGitH/Python-Challenges
/DailyProgrammer/DP20120718A.py
2,771
3.59375
4
""" This one is inspired by an actual problem my friend had to deal with recently. Unfortunately, its a little bit keyboard-locale specific, so if you don't happen to use a us-EN layout keyboard you might want to get a picture of one. The en-us keyboard layout pictured here [http://en.wikipedia.org/wiki/File:KB_United...
938569821ca0c1bc75975804d21afc968b709ca1
DayGitH/Python-Challenges
/DailyProgrammer/DP20140604B.py
4,215
3.765625
4
""" [6/4/2014] Challenge #165 [Intermediate] ASCII Maze Master https://www.reddit.com/r/dailyprogrammer/comments/278ptv/642014_challenge_165_intermediate_ascii_maze/ # [](#IntermediateIcon) _(Intermediate)_: ASCII Maze Master We're going to have a slightly more logical puzzle today. We're going to write a program tha...
ef7b5cbc0cd0523144d721544483329e68675b47
DayGitH/Python-Challenges
/DailyProgrammer/DP20140730B.py
2,960
3.984375
4
""" [7/30/2014] Challenge #173 [Intermediate] Advanced Langton's Ant https://www.reddit.com/r/dailyprogrammer/comments/2c4ka3/7302014_challenge_173_intermediate_advanced/ # [](#IntermediateIcon) _(Intermediate)_: Advanced Langton's Ant If you've done any work or research onto cellular automata, you may have heard of ...
e468767ef3ec92629303e5c294e393f29ae6ee83
DayGitH/Python-Challenges
/DailyProgrammer/20120218A.py
906
4.34375
4
''' The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized; both the area code and any white space between segments are optional. Thus, al...
b7a8823590f4459788d5d7d25cd8b4150e102b2a
DayGitH/Python-Challenges
/DailyProgrammer/20120602C.py
2,504
3.96875
4
""" Two strings A and B are said to have a common substring called C, if C is embedded somewhere in both A and B. For instance, "ble" is a common substring for "Double, double, toil and trouble" and "Fire burn and cauldron bubble" (because, as you can see, "ble" is part of both "Double" and "Bubble"). It is, however, n...
c07680eceb44d85d5f341a0fe68f9f522a6a723e
DayGitH/Python-Challenges
/DailyProgrammer/DP20161010W.py
1,065
3.96875
4
""" Weekly #26 - Mini Challenges https://www.reddit.com/r/dailyprogrammer/comments/56mfgz/weekly_26_mini_challenges/ So this week, let's do some mini challenges. Too small for an easy but great for a mini challenge. Here is your chance to post some good warm up mini challenges. How it works. Start a new main thread i...
f1d2f920c551650c468ce2db140b2a45bd44bbf7
DayGitH/Python-Challenges
/DailyProgrammer/DP20141231B.py
1,290
4.09375
4
""" [2014-12-31] Challenge #195 [Intermediate] Math Dice https://www.reddit.com/r/dailyprogrammer/comments/2qxrtk/20141231_challenge_195_intermediate_math_dice/ #Description: Math Dice is a game where you use dice and number combinations to score. It's a neat way for kids to get mathematical dexterity. In the game, y...
2634fb7abcbbe518b8e6687c1ce1537ff77603a2
DayGitH/Python-Challenges
/DailyProgrammer/DP20150306C.py
4,412
3.6875
4
""" [2015-03-06] Challenge #204 [Hard] Addition chains https://www.reddit.com/r/dailyprogrammer/comments/2y5ziw/20150306_challenge_204_hard_addition_chains/ #Description An "addition chain" is a sequence of numbers that starts with 1 and where each number is the sum of two previous numbers (or the same number taken t...
6f63d47fa84e4f61d0873976b9df8b40b1cbad9b
DayGitH/Python-Challenges
/DailyProgrammer/DP20171129B.py
3,286
3.65625
4
""" [2017-11-29] Challenge #342 [Intermediate] ASCII85 Encoding and Decoding https://www.reddit.com/r/dailyprogrammer/comments/7gdsy4/20171129_challenge_342_intermediate_ascii85/ # Description The basic need for a binary-to-text encoding comes from a need to communicate arbitrary binary data over preexisting communic...
e15d2492854c84deb355a3a6cdf689275604d114
DayGitH/Python-Challenges
/DailyProgrammer/DP20160511B.py
3,005
3.59375
4
""" [2016-05-11] Challenge #266 [Intermediate] Graph Radius and Diameter https://www.reddit.com/r/dailyprogrammer/comments/4iut1x/20160511_challenge_266_intermediate_graph_radius/ This week I'll be posting a series of challenges on graph theory. I picked a series of challenges that can help introduce you to the conce...
41f8ff8934bbb83431e4bfa998653ec20e00df3f
DayGitH/Python-Challenges
/DailyProgrammer/DP20150708B.py
1,553
3.671875
4
""" [2015-07-08] Challenge #222 [Intermediate] Simple Stream Cipher https://www.reddit.com/r/dailyprogrammer/comments/3chvxy/20150708_challenge_222_intermediate_simple_stream/ # Description Stream ciphers like [RC4](https://en.wikipedia.org/wiki/RC4) operate very simply: they have a strong psuedo-random number genera...
448674ed57d15065f2780c9596f4b25917a87644
DayGitH/Python-Challenges
/DailyProgrammer/DP20180110B.py
3,191
4.1875
4
""" [2018-01-10] Challenge #346 [Intermediate] Fermat's little theorem https://www.reddit.com/r/dailyprogrammer/comments/7pmt9c/20180110_challenge_346_intermediate_fermats/ #Description Most introductionary implementations for testing the primality of a number have a time complexity of`O(n**0.5)`. For large numbers t...
45f4274945cd2b65da5e58de856f9462a1b9c48a
DayGitH/Python-Challenges
/DailyProgrammer/DP20150311B.py
1,609
4.03125
4
""" [2015-03-11] Challenge #205 [Intermediate] RPN https://www.reddit.com/r/dailyprogrammer/comments/2yquvm/20150311_challenge_205_intermediate_rpn/ #Description: My father owned a very old HP calculator. It was in reverse polish notation (RPN). He would hand me his calculator and tell me "Go ahead and use it". Of co...
b66a7ce77896bee173702cfa36b244a059777a7d
DayGitH/Python-Challenges
/DailyProgrammer/DP20151019A.py
1,309
3.625
4
""" [2015-10-19] Challenge #237 [Easy] Broken Keyboard https://www.reddit.com/r/dailyprogrammer/comments/3pcb3i/20151019_challenge_237_easy_broken_keyboard/ # Description Help! My keyboard is broken, only a few keys work any more. If I tell you what keys work, can you tell me what words I can write? (You should use t...
f8ce35aa7a18e0b7a6febbd227e0b7a16f2fd832
DayGitH/Python-Challenges
/DailyProgrammer/DP20120629B.py
1,232
4.25
4
""" Implement the hyperoperator [http://en.wikipedia.org/wiki/Hyperoperation#Definition] as a function hyper(n, a, b), for non-negative integers n, a, b. hyper(1, a, b) = a + b, hyper(2, a, b) = a * b, hyper(3, a, b) = a ^ b, etc. Bonus points for efficient implementations. thanks to noodl for the challenge at /...
5d4844d3e48faf34857dca70c6dde00d9bc948c9
DayGitH/Python-Challenges
/DailyProgrammer/DP20170113C.py
6,250
3.65625
4
""" [2017-01-13] Challenge #299 [Hard] Functional Graph solving https://www.reddit.com/r/dailyprogrammer/comments/5nr86m/20170113_challenge_299_hard_functional_graph/ This is the same problem as [monday's](https://www.reddit.com/r/dailyprogrammer/comments/5mzr6x/20170109_challenge_298_hard_functional_maze/), except t...
8201a53e8222c3600ea8fdd966d6774386900de2
DayGitH/Python-Challenges
/DailyProgrammer/DP20140716W.py
647
3.734375
4
""" [Weekly #2] Pre-coding Work https://www.reddit.com/r/dailyprogrammer/comments/2ao9y3/weekly_2_precoding_work/ #Weekly Topic #2: What work do you do before coding your solution? What kind of planning or design work if any do you do? How do you do it? Paper and pencil? Draw a picture? Any online/web based tools? Gi...
681f48bac28f52729f440c3f2d54740d4ccac33a
DayGitH/Python-Challenges
/DailyProgrammer/DP20121018C.py
1,694
3.5
4
""" [10/18/2012] Challenge #104 [Hard] (Stack Attack) https://www.reddit.com/r/dailyprogrammer/comments/11pas4/10182012_challenge_104_hard_stack_attack/ **Description:** You are a devilish engineer designing a new programming language titled D++, which stands for a "Dijkstra++", named after your favorite computer sci...