 |
Python
1.0
|
def main(argv=None)
main function for testing.
Definition: _05a_gcd.py:113
def gcdr(a, b)
GCD (Greatest Common Divisor) of two integers.
Definition: _05a_gcd.py:26
def main()
Definition: _01d_dec2bin.py:114
def main()
Definition: _06b_palindromas_mutuas.py:37
def condense(lst)
Condenses the list of prime factors of a number, so that each factor appears just once,...
Definition: _10_factorize2.py:187
def palindrome(str)
Checks whether a string is a palindrome.
Definition: _06a_palindroma.py:24
def matMultiply(m1, m2)
Multiplies two matrices.
Definition: _03e_multiply.py:64
def main()
Definition: _06a_palindroma.py:34
def main(argv=None)
Definition: _04b_intsqrt.py:58
def main()
Definition: _03e_multiply.py:128
def main()
Definition: _01a_fibo_rec.py:95
def main(argv=None)
Definition: _11_ncsub.py:70
def seq(k)
Finds the limit of the sequence:
Definition: seq.py:23
def reRoman(r)
Validates a roman numeral using regular expressions.
Definition: validateRoman.py:74
def P(n, a, r)
Calculates the sum of the first n terms of a Geometric Progression.
Definition: _02b_Geometric_Progression.py:30
def is_perfect(num)
Checks whether a given number is perfect.
Definition: _04c_perfect.py:47
def toString(lfactor)
Stringify a condensed list of factors.
Definition: _10_factorize2.py:218
def main()
Definition: _03a_roman2int_dict.py:54
def matMultiply3(m1, m2)
Multiplies two matrices.
Definition: _03e_multiply.py:112
def Sp(n, a1, d)
Calculates the sum of the first n terms of an Arithmetic Progression.
Definition: _02a_Arithmetic_Progression.py:41
def bubble_sort(v)
Sorts a list using bubble sort.
Definition: _04e_bubble.py:33
def isPrime(n)
Checks if a given integer is prime.
Definition: _10_factorize2.py:75
def main()
Main function for testing.
Definition: _08a_emoldura.py:38
def main()
Definition: trigonometry.py:43
input
Definition: _03f_interleave.py:14
def __init__(self, msg="")
Constructor.
Definition: _05a_gcd.py:92
def main()
Definition: _02d_interest.py:45
def pascal2(first_level, last_level, center=True)
Creates the pascal triangle between two levels, using the binomial array.
Definition: _03d_pascal.py:275
def isPrime2(n)
Using list comprehensions creates a list with all divisors of 'n'.
Definition: _04a_prime.py:87
def factorization(x, F)
Return the factors of x, given an array with the smallest number that divides each integer (0,...
Definition: _04d_sieve.py:186
def translate
A closure for mapping decimal digits to their utf8 counterparts.
Definition: _10_factorize2.py:64
def main()
Definition: seq.py:32
def int2roman(num)
Converts an integer number to its roman numeral representation.
Definition: _03c_int2roman.py:30
def main()
Definition: _03f_intercala_zip.py:54
def fibo(n, p=False)
Generates a Fibonacci number using a recursive algorithm that makes only n recursive calls.
Definition: _01a_fibo_rec.py:41
def main()
Definition: _02c_int2roman.py:79
def main()
Definition: _02a_Arithmetic_Progression.py:52
def gcdi(a, b)
GCD (Greatest Common Divisor) of two integers.
Definition: _05a_gcd.py:44
def main(argv=None)
Definition: _04a_prime.py:90
def alarme(h, m, fplayer, player, song)
Plays a given song at given time using a given player.
Definition: _07_alarme_windows.py:26
def main(argv=None)
Main program.
Definition: validateRoman.py:97
Definition: validateRoman.py:1
Exception class.
Definition: _05a_gcd.py:86
def fibonacci(num)
Fills a list with Fibonacci numbers.
Definition: _01a_fibo_list.py:17
def anagram(str1, str2)
Checks whether two words are anagrams.
Definition: _06d_anagrama.py:56
p
Definition: _02_matrix.py:46
def main()
Definition: _11_ncsub_rec.py:37
def main()
Definition: _01c_str2int.py:33
def main(argv=None)
Main program for testing.
Definition: _04d_sieve.py:244
def genWeightedList(l, weights)
Method 1 – given a list of of items and a list of probabilities, return a new list that contains int(...
Definition: weightedNumGenerator.py:22
def xis(n)
Prints an X using asterisks.
Definition: _08b_xis.py:23
def main()
Definition: _03b_int2roman_dict.py:39
def main(argv=None)
Main function for testing.
Definition: _07_alarme.py:41
def mergek(*lists)
Create a priority queue for merging a set of sorted lists.
Definition: mergeHeap.py:37
def rightTriangle(n, orientation=0)
Return a string representing the right triangle of height n in a given orientation.
Definition: _08c_rightTriangle.py:30
def modinv2(a, b, c)
Calculates the modular inverse of an integer.
Definition: _05d_rsa.py:81
def isqrt(n)
Python 3.8.
Definition: _04b_intsqrt.py:45
Progress bar.
Definition: progress_bar.py:1
def continuous_interest_rate(c, f, n)
Calculates the interest rate of a continuous compounding interest.
Definition: _02e_interest.py:31
Evaluating the limit of a sequence.
Definition: seq.py:1
def main()
Definition: _06d_anagrama.py:128
def getTime(dsec)
Return the time in the format: hr:min:sec:msec.
Definition: _04d_sieve.py:236
def main()
Definition: maxnc.py:64
def deep_compare(a, b, pointer='/')
Definition: deeper.py:22
def ncsub(seq, s=0)
Enumerates all non-continuous subsequences for a given sequence.
Definition: _11_ncsub_rec.py:27
def int2bin(n, count=24)
Converts an integer to a binary string representation with an specified number of bits.
Definition: _01d_dec2bin.py:111
input
Definition: _10_factorize.py:26
def int2roman(num)
Converts an integer number to its roman numeral representation.
Definition: _03b_int2roman.py:17
def main()
Main program for testing.
Definition: mergeHeap.py:57
def Binary2Denary(bStr)
Converts a binary string to a denary integer.
Definition: _01d_dec2bin.py:63
def exponent(val, type=False)
Return a superscript for the given digits, such as:
Definition: _10_factorize2.py:167
def arrayF(n)
Prepare an array for factorization.
Definition: _04d_sieve.py:146
def Hanoi(n, from_, to_, by_)
Hanoi Tower.
Definition: _09_hanoi.py:35
def main(argv=None)
Definition: _05b_cpf.py:102
def S(n, a1, d)
Calculates the sum of the first n terms of an Arithmetic Progression.
Definition: _02a_Arithmetic_Progression.py:29
def interest_rate(c, f, n)
Calculates the interest rate of a compounding interest.
Definition: _02e_interest.py:20
def main()
Definition: _01f_getDigit.py:20
def str2int(str)
Converts a string with characters from '0' to '9' to an integer.
Definition: _01c_str2int.py:19
def condense(L)
Condenses the list of prime factors of a number, so that each factor appears just once,...
Definition: _10_factorize.py:98
def dec2hex(n)
Converts a denary integer to hexadecimal.
Definition: _01d_dec2bin.py:83
def modinv(a, m)
Calculates the modular inverse of an integer.
Definition: _05d_rsa.py:65
def Product2(a, b, base=10)
Definition: _01e_multbin.py:47
input
Definition: _03f_intercala_zip.py:14
def getDigit(num, d)
Gets the n-th digit of an integer, from right to left.
Definition: _01f_getDigit.py:16
def deep_getsizeof(o, ids)
Definition: deeper.py:95
def Pp(n, a, r)
Calculates the sum of the first n terms of a Geometric Progression.
Definition: _02b_Geometric_Progression.py:42
def main(argv=None)
Definition: _03c_int2roman.py:66
def getArray(array)
Return the primes corresponding to a given array.
Definition: _04d_sieve.py:225
def main()
Definition: _03f_interleave.py:32
def main(argv=None)
Definition: func3.py:12
raw_input
Definition: validateRoman.py:17
def main()
Definition: _08b_xis_rec.py:31
msg
hold the error message.
Definition: _05a_gcd.py:96
def getAllTriangles(n)
Generates and interleaves all four orientations for printing.
Definition: _08c_rightTriangle.py:50
def Product(a, b)
Multiplies two integers by using only the + operation.
Definition: _01e_multbin.py:37
def nsubs(n)
The number of k-combinations.
Definition: _11_ncsub.py:31
def exponent(val, type=False)
Return a superscript string for the given value.
Definition: _03d_pascal.py:160
def xx_eq_sinx()
Solves the equation .
Definition: _04b_xx_eq_sinx.py:43
def int2roman(num)
Converts an integer number to its roman numeral representation.
Definition: _02c_int2roman.py:18
def intercala(*args)
Interleaves a variable number of lists.
Definition: _03f_intercala_zip.py:25
def main(argv=None)
Definition: func2.py:12
def matMultiply2(m1, m2)
Multiplies two matrices.
Definition: _03e_multiply.py:97
def interest(c, n, t)
Calculates the compounding interest and the continuous compounding interest.
Definition: _02d_interest.py:42
def isPhrasePalindrome(st)
Checks whether a phrase is a palindrome.
Definition: _06c_frase_palindroma.py:24
def addtoheap(h, i, it)
Push a tuple(item,index) to a given heap.
Definition: mergeHeap.py:24
def atan2d(y, x)
Computes the arc tangent (measured in degrees) of y/x.
Definition: trigonometry.py:27
def generateKeys(p, q)
Generates the public and private keys.
Definition: _05d_rsa.py:133
input
Definition: _08a_emoldura.py:12
def emoldura(l, max_n)
Frames text lines.
Definition: _08a_emoldura.py:29
def sieve(n)
Returns a list with all primes up to n.
Definition: _04d_sieve.py:66
def areValidDigits(cnpj, dv)
Validates a CNPJ using the verification digits (DV).
Definition: _05c_cnpj.py:83
def gcdf(x, y)
GCD (Greatest Common Divisor) of two integers.
Definition: _05a_gcd.py:63
Recursively find the maximum value in a list.
Definition: maximum.py:1
def factorize(n)
Factorizes an integer or long number.
Definition: _10_factorize2.py:129
def fact(n)
Factorial of n, non-recursive version.
Definition: _03d_pascal_rec.py:46
def power_mod_n(c, d, n)
Calculates c to the power of d mod n.
Definition: _05d_rsa.py:97
def fib(n)
Generates a Fibonacci number using a recursive algorithm that makes only n recursive calls.
Definition: _01a_fibo_rec.py:70
def alarm(h, m, fplayer, player, song)
Plays a given song at given time using a given player.
Definition: _07_alarme.py:27
def __str__(self)
Redefines the printing method.
Definition: _05a_gcd.py:105
def main(argv=None)
Definition: _01e_multbin.py:58
def interleave(*args)
Interleaves a variable number of lists.
Definition: _03f_interleave.py:23
def main(argv=None)
Definition: _04b_xx_eq_sinx.py:52
def roman2int(roman)
Converts a roman numeral to its decimal representation.
Definition: _03a_roman2int.py:36
def main(argv=None)
Definition: _03a_roman2int.py:76
def main()
Definition: _04e_bubble.py:49
xrange
Definition: _04a_prime.py:59
def weightedRandD(d)
Using a dictionary.
Definition: weightedNumGenerator.py:90
def __translate()
Map decimal digits to their utf8 subscript or superscript equivalents.
Definition: _10_factorize2.py:42
def main(argv=None)
main function for testing.
Definition: _10_factorize.py:114
def main(argv=None)
Definition: func.py:13
def continuous_compounding_interest(c, n, r)
Calculates the continuous compounding interest.
Definition: _02d_interest.py:31
def main()
Definition: _01a_fibo_list.py:23
def main()
Definition: _01a_fibo.py:66
def pascal(n, k)
The binomial coefficient, refered as row n, column k.
Definition: _03d_pascal_rec.py:73
def desenha_xis(k)
Desenha um xis de ordem k com deslocamento 0.
Definition: _08b_xis_rec.py:14
def compounding_interest(c, n, t)
Calculates the compounding interest.
Definition: _02d_interest.py:20
def factorize_rec(n)
Factorizes an integer or long number.
Definition: _10_factorize.py:38
xrange
Definition: validateRoman.py:16
def printArray(array)
Print the primes corresponding to a given array.
Definition: _04d_sieve.py:201
def progress_bar(value, max, barsize)
Displays a progress bar on the console made of '#'.
Definition: progress_bar.py:21
def main(argv=None)
Definition: func4.py:13
Maximum of two numbers without conditionals.
Definition: maxnc.py:1
def main()
Definition: _05d_rsa.py:144
input
Definition: _03a_roman2int.py:26
def isPrime(n)
Tests whether an integer is prime.
Definition: _04a_prime.py:67
def C(n, k)
Calculates the k-combination of an integer.
Definition: _11_ncsub.py:21
def int2roman(number)
Converts an integer number to its roman numeral representation.
Definition: _03b_int2roman_dict.py:17
def pascal(first_level, last_level, center=True)
Creates the pascal triangle between two levels.
Definition: _03d_pascal.py:247
def main()
Main program for testing.
Definition: weightedNumGenerator.py:108
def roman2int(roman)
Converts a roman numeral to its decimal representation.
Definition: _03a_roman2int_dict.py:18
input
Definition: _05c_cnpj.py:72
def setDebug(stat)
Set debugging on or off.
Definition: _04d_sieve.py:46
def intercala(l1, l2)
Interleaves two lists.
Definition: _03f_intercala.py:19
def intsqrt(n)
Calculates the integer part of the square root of a long.
Definition: _04b_intsqrt.py:32
def fib2(n, p0, p1)
Generates a Fibonacci number using a recursive algorithm that makes only n recursive calls.
Definition: _01a_fibo_rec.py:85
def main(argv=None)
main function for testing.
Definition: _10_factorize2.py:231
def Fibo(n)
Prints the first n Fibonacci numbers.
Definition: _01a_fibo.py:52
def binomial_expansion(e)
Compute the binomial expansion of .
Definition: _03d_pascal.py:183
def maximum(L)
Definition: maximum.py:11
def main()
Definition: _01b_eqn2.py:41
def compare(a, b)
Definition: deeper.py:88
def binomial_cumulative_distribution(p, n, x=None)
Compute the probability of getting at most successes in trials, which is the sum of the first term...
Definition: _03d_pascal.py:96
def weightedRand(seq)
Return a random element from seq (same of choice from random).
Definition: weightedNumGenerator.py:45
def perm(n, i)
The full permutation of list "n" can be solved by picking any element, placing it in the first,...
Definition: _12_perm.py:17
def maxnc(a, b)
Return the maximum of two numbers.
Definition: maxnc.py:59
def Denary2Binary(num)
Converts denary integer to a binary string.
Definition: _01d_dec2bin.py:41
def main(argv=None)
Definition: _05c_cnpj.py:107
def find_perfect(n)
Finds the first n perfect numbers.
Definition: _04c_perfect.py:71
def main()
Definition: _02b_Geometric_Progression.py:54
def main()
Definition: _06c_frase_palindroma.py:39
def main(argv=None)
Main function for testing.
Definition: _09_hanoi.py:47
def charEncode(f)
Encodes a character to utf8 in Python 2.
Definition: _10_factorize2.py:32
def interest(c, f, n)
Calculates the interest rate of a compounding interest and a continuous compounding interest.
Definition: _02e_interest.py:42
def getNextRow(curr_row)
Computes the next row of a Pascal triangle, given the current row.
Definition: _03d_pascal.py:215
def hex2dec(s)
Converts a string or number to a plain integer.
Definition: _01d_dec2bin.py:100
def areValidDigits(cpf, dv)
Validates a CPF using the verification digits (DV).
Definition: _05b_cpf.py:79
def perm(n, i)
The full permutation of list "n" can be solved by picking any element, placing it in the first,...
Definition: _12_perm2.py:17
def lcm(x, y)
Least Common Multiple, which returns the smallest number that can be divided by x and y without any r...
Definition: _05a_gcd.py:77
def binomial_coefficient(n, m, method=2)
Compute choose or Combination .
Definition: _03d_pascal.py:67
input
Definition: _01d_dec2bin.py:31
def showpascal(n)
Prints successive rows of Pascal's triangle, from 0 to n.
Definition: _03d_pascal_rec.py:81
def factr(n)
Factorial of n, recursive version.
Definition: _03d_pascal_rec.py:31
def transpose(m, pythonicWay=False)
Transpose a given matrix.
Definition: _03e_multiply.py:40
def main()
Definition: _03f_intercala.py:39
def isAnagram(a, b)
Checks whether two words or phrases are anagrams.
Definition: _06d_anagrama.py:78
def dotProd(a, b)
Dot product of two vectors.
Definition: _03e_multiply.py:30
def egcd(a, b)
The extended Euclidean algorithm for the Greatest Common Divisor of two integers.
Definition: _05d_rsa.py:43
def desenha_xis_rec(k, d)
Desenha xis com 2k+1 linhas e deslocamento d.
Definition: _08b_xis_rec.py:23
def areMutualPalindromes(str1, str2)
Checks whether two strings are mutual palindromes.
Definition: _06b_palindromas_mutuas.py:27
def main()
Definition: _03b_int2roman.py:54
def weightedRand2(l, weights)
Method 2 – given list of items and a list of probabilities, which sum up to one, for example,...
Definition: weightedNumGenerator.py:68
def containsHiddenWord(hiddenWord, word)
Determines whether the given hidden word can be obtained from the main word, by erasing some of its l...
Definition: _06d_anagrama.py:105
def fiboDumb(n)
This is a naive recursive version.
Definition: _01a_fibo_rec.py:24
def main(argv=None)
Main function for testing.
Definition: _07_alarme_windows.py:41
def factorize(n)
Factorizes an integer or long number.
Definition: _10_factorize.py:68
def ncsub(seq)
Enumerates all non-continuous subsequences for a given sequence.
Definition: _11_ncsub.py:50
def main()
Main function for testing.
Definition: _04c_perfect.py:105
def binomial_array(n)
Compute n lines of the binomial array.
Definition: _03d_pascal.py:46
def x(pointer, reason, extra)
Definition: deeper.py:83
def main()
Definition: _08b_xis.py:32
def main()
Definition: _03d_pascal_zip.py:52
def main()
Definition: _02e_interest.py:45
def kfact(n, k)
k factorial of n.
Definition: _03d_pascal_rec.py:58
def validateRoman(r)
Validates a roman numeral.
Definition: validateRoman.py:25
def pascal(nlines, line=[1])
A Pascal Triangle generator.
Definition: _03d_pascal_zip.py:46
def genWeightedListD(d)
Using a dictionary, instead of two lists.
Definition: weightedNumGenerator.py:35
def fmtRow(last_level, r, pad=True)
Formats a row of the Pascal triangle.
Definition: _03d_pascal.py:232
def eqn2(a, b, c)
Solves a second degree equation: .
Definition: _01b_eqn2.py:29
def main(argv=None)
Main function for testing.
Definition: _03d_pascal.py:309
def sieve2(n)
Memory efficient version, using bitarray.
Definition: _04d_sieve.py:110
def main()
Definition: progress_bar.py:33
def intercala3(*args)
Interleaves a variable number of lists.
Definition: _03f_intercala_zip.py:43