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
# Merge multiple lists of distinct elements into a single list, maintaining the order within each list. | |
# The result is a list of distinct elements, consisting of the union of the elements in the constituent lists. | |
# If A precedes B in one of the input lists, then A must precede B in the result. | |
# If this is not possible, then None is returned. | |
from collections import defaultdict | |
# Class to represent a graph - adapted from http://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/ | |
class Graph: |
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
# Download a list of all 7-Eleven stores in the United States. | |
# WARNING: The source data is inaccurate! | |
# Presented at PyMNtos, 2017-11-30 | |
import requests | |
import csv | |
import time | |
import bs4 | |
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
10 PRINT "1" | |
20 PRINT "2" | |
30 PRINT "Fizz" | |
40 PRINT "4" | |
50 PRINT "Buzz" | |
60 PRINT "Fizz" | |
70 PRINT "7" | |
80 PRINT "8" | |
90 PRINT "Fizz" | |
100 PRINT "Buzz" |
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
""" | |
Author: David Radcliffe (2018-02-02) | |
I am interested in numbers that are sums of two successive primes: | |
5, 8, 12, 18, 24, 30, 36, 42, 52, 60, 68, 78, 84, 90, 100, ... | |
Note that 2+3=5, 3+5=8, 5+7=12, 7+11=18, and so on. | |
This is sequence A001043 in the On-Line Encyclopedia of Integer Sequences. |
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
#!/bin/bash | |
# This script moves files from the Download directory to the current directory. | |
# Usage examples: | |
# pop - move the most recently downloaded file. | |
# pop 3 - move the three most recently downloaded files. | |
downloads=$HOME/Downloads | |
n=1 | |
if [ "$1" != "" ]; then | |
n=$1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
-module(multiply). | |
-export([mul/2]). | |
mul(_, 0) -> 0; | |
mul(A, B) -> mul(A, B-1) + A. |
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
-module(multiply). | |
-export([mul/2]). | |
mul(A, B) -> mul(A, B, 0). | |
mul(_, 0, C) -> C; | |
mul(A, B, C) -> mul(A, B-1, A+C). |
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
-module(multiply). | |
-export([mul/2]). | |
mul(A, B) -> mul(A, B, 0). | |
mul(_, 0, C) -> C; | |
mul(A, B, C) when B rem 2 == 1 -> mul(A, B-1, A+C); | |
mul(A, B, C) -> mul(A + A, B div 2, C). |
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
-module(power). | |
-export([pow/2]). | |
pow(A, B) -> pow(A, B, 1). | |
pow(_, 0, C) -> C; | |
pow(A, B, C) when B rem 2 == 1 -> pow(A, B-1, A*C); | |
pow(A, B, C) -> pow(A*A, B div 2, C). |