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
// How many different ways can we make change of $1.00, given half-dollars, | |
// quarters, dimes, nickels, and pennies? | |
// -- from SICP 1.2.2 | |
package main | |
import "fmt" | |
func coin2() int { | |
cnt := 0 |
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
// Problem: Find all integer values of X (1 <= X <= 100) that satisfy the | |
// following statement: It is impossible to make $1 using exactly X U.S. coins. | |
// Consider only coins with these denominations: 1¢, 5¢, 10¢, 25¢, 50¢, and $1. | |
package main | |
import "fmt" | |
type results struct { | |
coins int |
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
const readable = process.stdin; | |
const chunks = []; | |
readable.on('readable', () => { | |
let chunk; | |
while (null !== (chunk = readable.read())) { | |
chunks.push(chunk); | |
} | |
}); |
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
const crypto = require('crypto'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const walk = require('walkdir'); | |
let tree = []; | |
//hash and rename a file | |
async function hashFile(filepath) { | |
const file = fs.createReadStream(filepath); |
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
const https = require('https'); | |
const { Transform } = require('stream'); | |
//each package listed as depending on another is in its own <section> | |
const breakIntoSections = () => new Transform({ | |
transform(ch, _, cb) { | |
const rows = ((this.partialRow || '') + ch.toString()).split(/<\/section>/); | |
this.partialRow = rows.pop(); | |
for (const row of rows) { | |
this.push(`${row}\n`); |
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
const countries = [ | |
{ code: "AF", country: "Afghanistan" }, | |
{ code: "AL", country: "Albania" }, | |
{ code: "DZ", country: "Algeria" }, | |
{ code: "AS", country: "American Samoa" }, | |
{ code: "AD", country: "Andorra" }, | |
{ code: "AO", country: "Angola" }, | |
{ code: "AG", country: "Antigua and Barbuda" }, | |
{ code: "AR", country: "Argentina" }, | |
{ code: "AM", country: "Armenia" }, |