Programming Methods & Algorithms scripts - Top 4 Download

Programming Methods & Algorithms script downloads

Sieve of Eratosthenes

This script computes an infinite sequence of primes using simple generators. A Python dictionary is used to mark multiples of the generated primes, according to the Sieve of Eratosthenes. ...
Python

Permutation

This script contains a small but efficient recursive function for printing the permutation of characters in a given string. ...
Python

Loop over and descend into sequences

This is a function to iterate over a container and its elements that checks for recursive traps. The condition for descending into elements is highly configurable (a list of type() results, or a callable). ...
Python

Credit card validation

This script implements in python an industry standard algorithm for credit card validation. It works on all major credit cards. You pass in the credit card number as a string and it returns 1 for a valid card or 0 for an invalid card ...
Python

Splitting iterators

This script shows an implementation of isplit, a function that splits iterators into two equal ones, which return similar values, but are exact copies of one another. ...
Python

Dicts from lists

This script is a simple oneliner to built a dictionary from a list. ...
Python

Deque collection class

This script is a pure python drop in replacement for collections.deque(). It uses a dictionary as the underlying data structure for the deque (pronounced "deck", short for "double-ended queue", a generalization of stacks and queues) which provides O(1) performance for appends and pops from either end.   ...
Python

Implementing Future s with decorators

This script shows you how to kick off a slow process without waiting around for the result. The process is run in the background until the value is actually needed at which time it blocks until the value is ready. ...
Python

Bag collection class

Bag collection class script implements Smalltalk's bag class. ...
Python

Transposing a List of Lists

This script allows you to transpose a list of lists of different lengths. ...
Python

Grouping objects into disjoint sets

This class provides a lightweight way to group arbitrary objects together into disjoint sets when a full-blown graph data structure would be overkill. Objects can be joined using .join(), tested for connectedness using joined(), and all disjoint sets can be retreived using get(). The objects being joined must be hashable. ...
Python

Poker hand primitives

This script handles logic for detecting straights and groups of repeats in the presence of wildcards and hands with more than five cards. ...
Python

Easy binary2decimal and decimal2binary

This script allows you to convert binary numbers to decimal and vice-versa in the most straightforward way. ...
Python

Encrypting A String

The main purpose of these functions are to encrypt and decrypt a string (or change the string from one "language" into another). The code is simple, but it provides a simple solution to a well-known encryption scheme. As a recommendation, this may be better when used in conjunction with an encoding ...
Python

Constellation Finder

The script demonstrates the use of SETs in Python. There is a key object that has constellations already identified and a stars object that contains the stars in the sky. Keys are used to unlocks the stars and the results are printed out for the user of the program. ...
Python