-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCS1101S Q2.js
72 lines (54 loc) · 1.98 KB
/
CS1101S Q2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {random_color,from_url, stack_frac, stack, nova, beside_frac, heart, beside, quarter_turn_right,quarter_turn_left, make_cross, rcross, stackn, show} from "rune";
function colorbesiden(n, rune) {
return n === 1
? rune
: beside_frac(1/n,random_color(rune),
colorbesiden(n-1,random_color(rune)));
}
function repeat(counter,row_count,column_count,rune,thing_to_repeat){
return counter === row_count
? thing_to_repeat
: repeat(counter+1,row_count,column_count,rune,colorstack(counter,colorbesiden(column_count,rune),thing_to_repeat));
}
function colorstack(n,rune1,rune2){
return stack_frac(1/n,rune1,rune2);
}
function randomly_colored_carpet(row_count,column_count,rune){
return repeat(1,row_count+1,column_count,rune,colorbesiden(column_count,rune));
}
show(randomly_colored_carpet(4,5,heart));
/*
function besiden(n, rune) {
return n === 1
? rune
: beside_frac(1/n,rune,
besiden(n-1,rune));
}
function besiden1(n,rune)
{
return quarter_turn_right(colorstackn(n,quarter_turn_left(rune)));
}
function carpet(n, m, rune) {
return stackn(m,(besiden(n,rune)));
}
function colorstackn(n, rune) {
return n === 1
? rune
: stack_frac(1/n,random_color(rune),
colorstackn(n-1,random_color(rune)));
}
show(randomly_colored_carpet(4,5,heart));
show(repeat(1,4,4,heart,colorbesiden(4,heart)));
//show(stackn(4,colorbesiden(4,heart)));
//show(colorstack(3,colorbesiden(4,heart),colorstack(2,colorbesiden(4,heart),colorstack(1,colorbesiden(4,heart),heart))));
function fuckthisshit(n,m,rune){
for (i > 0,i = n,i++){
for (j>0, j=m, j++){
print(random_color(heart));
}
}
}
fuckthisshit(3,4,heart)
//show(stack_frac(1/4,colorbesiden(4,heart),stack_frac(1/3,colorbesiden(4,heart),stack_frac(1/2,colorbesiden(4,heart),colorbesiden(4,heart)))));
//stack_frac(1/n+1,colorbesiden(4,heart),stack_frac(1/n+1,colorbesiden(4,heart),stack_frac(1/n+1,colorbesiden(4,heart),x)));
*/