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
#!/usr/bin/env node | |
const start = new Date(2018, 5, 6); //TODO replace this with your first day | |
const today = new Date(new Date().setHours(0,0,0,0)); | |
const datediff = (x, y) => Math.round((y-x)/(1000*60*60*24)); | |
console.log(`Started on ${start}`); | |
console.log(`Today is ${today}`); | |
console.log(`You are on day ${datediff(start, today) + 1} of #100DaysOfCode`); |
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
############################################## | |
## Example 1 - play a note | |
play 60 | |
############################################## | |
## Example 2 - play 4 random notes | |
4.times do | |
play rrand_i(60, 90) | |
sleep 0.5 |
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
# from https://www.reddit.com/r/dailyprogrammer/comments/3ofsyb/20151012_challenge_236_easy_random_bag_system/ | |
import random | |
def new_bag(): | |
bag = list("OISZLJT") | |
random.shuffle(bag) | |
return bag | |
def next_piece(count): |
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
# from https://www.reddit.com/r/dailyprogrammer/comments/3moxid/20150928_challenge_234_easy_vampire_numbers/ | |
from functools import reduce | |
def is_vampire(nums): | |
prod = reduce(lambda x,y: x*y, nums) | |
prod_str = list(str(prod)) | |
num_str = list(reduce(lambda x,y: str(x) + str(y), nums)) |