This file contains 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
/** | |
* Coding challenge : Armstrong Numbers | |
* | |
* Write a program using any language or technique that can accept two positive | |
* integers defining a range (such as 0 and 100 for the range 0 <= x <= 100) and | |
* will print all Armstrong Numbers in that range. | |
* | |
* An Armstrong Number is fully defined at | |
* http://en.wikipedia.org/wiki/Narcissistic_number | |
* |
This file contains 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
#!/usr/bin/env ruby | |
# Consider the following algorithm to generate a sequence of numbers. Start | |
# with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and | |
# add 1. Repeat this process with the new value of n, terminating when n = 1. | |
# For example, the following sequence of numbers will be generated for n = 22: | |
# | |
# 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 | |
# | |
# It is conjectured (but not yet proven) that this algorithm will terminate at |
This file contains 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
(ns bowling.core) | |
(defn spare? [rolls] | |
(= 10 (reduce + (take 2 rolls)))) | |
(defn strike? [rolls] | |
(= 10 (first rolls))) | |
(defn take-how-many [rolls] | |
(if (or (spare? rolls) (strike? rolls)) 3 2)) |
This file contains 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
(defadvice delete-file (before purge-from-projectile-cache (filename &optional trash)) | |
(if (and (projectile-project-p) projectile-enable-caching) | |
(let* ((project-root (projectile-project-root)) | |
(true-filename (file-truename filename)) | |
(relative-filename (file-relative-name true-filename project-root))) | |
(if (projectile-file-cached-p relative-filename project-root) | |
(projectile-purge-file-from-cache relative-filename))))) |
This file contains 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
function vote { | |
curl --silent https://alex.github.io/nyt-2020-election-scraper/battleground-state-changes.csv | \ | |
awk -v red="$(tput setaf 1)" \ | |
-v blue="$(tput setaf 4)" \ | |
-v reset="$(tput sgr0)" \ | |
-F "," ' | |
NR==1 { next } | |
matches[$1] == 1 { next } | |
{ | |
matches[$1]=1 |