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
console.log("hello"); | |
function LazySeq(head, tail) { | |
this.head = head; // value | |
this.tail = tail; // thunk || null | |
} | |
function ints(n) { | |
return new LazySeq(n, function() { return ints(n+1); }); | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>-=( magic maths )=-</title> | |
<link rel="stylesheet" href="" /> | |
</head> | |
<body bgcolor="#040404"> | |
<canvas id="canvas" width=960 height=700> | |
</canvas> | |
<script src="magic_maths.js"></script> |
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
var canvas = document.getElementById("exercises"), | |
context = canvas.getContext("2d"), | |
width = canvas.width, | |
height = canvas.height; | |
// midpoints | |
var midX = canvas.width/2, midY = canvas.height/2; | |
// trigonometry | |
var TAU = Math.PI * 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
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<meta http-equiv="encoding" content="utf-8"> | |
</head> | |
<canvas id="canvas" width="1490" height="512" style="border:1px dashed"> | |
CA canvas | |
</canvas> | |
<script type="text/javascript"> | |
var canvas = document.getElementById("canvas"); |
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
# proccc | |
def one proccc, x | |
proccc.(x) | |
end | |
def two proccc, x | |
proccc.(proccc.(x)) | |
end |
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
class Celery | |
def initialize(grid) | |
@grid = grid | |
@height = grid.length | |
@width = grid[0].length | |
end | |
def self.mini | |
[[ 0, 1, 2, 3, 4], | |
[10,11,12,13,14], | |
[20,21,22,23,24], |
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
# Find the greatest product of five consecutive digits in the 1000-digit number. | |
madness=7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315 |
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
def modulo_3?(number) | |
# (number % 3).zero? | |
number.modulo(3).zero? # i guess this is more idiomatic Ruby, though I like the previous better | |
end | |
def commify(number) | |
reversed = number.to_s.reverse | |
number_size = number.to_s.size | |
result = "" |
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
# goal: get a number like 25164150 | |
# and transform it to: 25,164,150 | |
# =begin | |
# 1) number.to_s.split("").length | |
# 2) start from end, count multiples of 3 | |
# 3) insert comma | |
# 4) turn array back into a string | |
# .join(",") | |
# x.unshift(",")unless (x % 3 != 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
# Euclid's formula yields Pythagorean triples for integers m and n with m < n: | |
# a = m**2 - n**2 ; b = 2*m*n ; c = m**2 + n**2 | |
x = 1000 | |
def euclids upto | |
result = [] | |
(2..upto).each do |m| # Start at 2 as 1 results nothing anyway | |
(1...m).each do |n| # Euclid's formula only works for m > n | |
result << [m**2 - n**2, 2*m*n, m**2 + n**2] |