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
import string | |
# initialise a "zeroed" frequency count dict for the upper case chars | |
empty_freq_counts = dict.fromkeys(string.ascii_uppercase, 0) | |
def freq_count(word): | |
# precondition: word is upper and lowercase ascii characters only | |
# Setup loop invariant. Making a copy of an existing dict | |
# is faster than creating a new dict. |
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
from operator import mul | |
# indices 0 - 64 are non-word characters | |
# followed by indices corrolating to capital letters | |
# followed by 6 non-word characters | |
# followed by indices corrolating to lower-case letters | |
primes = [1] * 65 \ | |
+ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101] \ | |
+ [1] * 6 \ | |
+ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101] |
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
// https://www.youtube.com/watch?v=wOhY-O0UqbI | |
ArrayList<Particle> particles; | |
PImage[] bullets; | |
PImage red_bullet; | |
PImage green_bullet; | |
PImage blue_bullet; | |
final float GRAVITY = 200; |
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
[person for person in world_population | |
if is_nice(person) and is_nice(person)] |
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
(require 2htdp/image) | |
(define-struct spiro (minor-radius | |
major-radius | |
minor-turn-rate | |
major-turn-rate)) | |
(define (major-turns | |
minor-turns | |
this-spiro) |
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
(require 2htdp/image) | |
(define FUR_COLOR (make-color 130 130 130)) | |
(define FUR_COLOR_DARK (make-color 80 85 90)) | |
(define FUR_COLOR_LIGHT (make-color 160 160 155)) | |
(define FUR_COLOR_LIGHTEST (make-color 190 190 180)) | |
(define EYE_COLOR_DARK (make-color 20 160 20)) | |
(define EYE_COLOR_LIGHT (make-color 50 200 50)) |