This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pig(word): | |
| lower_word = original_word.lower() | |
| if lower_word[1] == "a" or lower_word[1] == "e" or lower_word[1] == "i" or lower_word[1] == "o" or lower_word[1] == "u": | |
| stem = lower_word[1:] | |
| first = lower_word[0] | |
| new_word = (stem + first+ "ay") | |
| else: | |
| stem2 = lower_word[2:] | |
| first2 = lower_word[0] + lower_word[1] | |
| new_word = (stem2 + first2 + "ay") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pyg_sentence(sentence): | |
| new_sentence = "" | |
| for word in sentence: | |
| new_sentence += pyg(word) | |
| return new_sentence | |
| def pyg(x): | |
| if x[0] == 'a' or x[0] == 'e' or x[0] == 'i' or x[0] == 'o' or x[0] == 'u': | |
| new_word = ' ' + x + "ay" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| grid = ( | |
| (8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8), | |
| (49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0), | |
| (81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65), | |
| (52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91), | |
| (22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80), | |
| (24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50), | |
| (32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| def ben_primes(limit, with_nones=False, bools=False): | |
| """ | |
| Find prime numbers from 2 to the specified limit, return a list. | |
| Keyword arguments: | |
| with_nones -- if True, will return a list like [2, 3, None, 5, None, 7, None, None, None, 11]; Nones are otherwise omitted | |
| bools -- if True, ignores with_nones and returns a list like [True, True, False, True, False, True] where a number n's prime status can be found at list[n+2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| class Cell: | |
| def __init__(self): | |
| self.left = None | |
| self.right = None | |
| self.value = 0 | |
| def increment(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def main(): | |
| print("I'm gonna generate a brainfuck program to print your text. It will be horribly inefficient, but it's faster", | |
| "than writing it yourself…") | |
| my_string = input('Enter the output string: ') | |
| print(encode_string_to_brainfuck(my_string)) | |
| def encode_string_to_brainfuck(my_string): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.HashMap; | |
| public class Euler014 { | |
| private HashMap<Integer, Integer> solvedCollatz = new HashMap<>(); | |
| private Integer collatzLength(Integer start) { | |
| Integer len = 1; | |
| Integer num = start; | |
| while (num != 1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import sqrt, erf, erfc | |
| from scipy.special import erfinv, erfcinv | |
| class Table: | |
| def __init__(self, precision=4): | |
| self.precision = precision | |
| def below(self, z_score): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BubbleSort: | |
| def __init__(self, items): | |
| self.items = items | |
| self.operations = 0 | |
| def sort(self): | |
| while not self.sorted(): | |
| for i in range(1, len(self.items)): | |
| self.operations += 1 | |
| a, b = self.items[i - 1:i + 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import time | |
| class Cell: | |
| def __init__(self): | |
| self.left = None | |
| self.right = None | |
| self.value = 0 |
OlderNewer