March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,25 @@
Msgbox % format(pascalstriangle())
Return
format(o) ; converts object to string
{
For k, v in o
s .= IsObject(v) ? format(v) "`n" : v " "
Return s
}
pascalstriangle(n=7) ; n rows of Pascal's triangle
{
p := Object(), z:=Object()
Loop, % n
Loop, % row := A_Index
col := A_Index
, p[row, col] := row = 1 and col = 1
? 1
: (p[row-1, col-1] = "" ; math operations on blanks return blanks; I want to assume zero
? 0
: p[row-1, col-1])
+ (p[row-1, col] = ""
? 0
: p[row-1, col])
Return p
}

View file

@ -0,0 +1,17 @@
PROGRAM:PASCALTR
:Lbl IN
:ClrHome
:Disp "NUMBER OF ROWS"
:Input N
:If N < 1:Goto IN
:{N,N}→dim([A])
:"CHEATING TO MAKE IT FASTER"
:For(I,1,N)
:1→[A](1,1)
:End
:For(I,2,N)
:For(J,2,I)
:[A](I-1,J-1)+[A](I-1,J)→[A](I,J)
:End
:End
:[A]

View file

@ -0,0 +1,13 @@
PROGRAM:PASCALTR
:Lbl IN
:ClrHome
:Disp "NUMBER OF ROWS"
:Input N
:If N < 1:Goto IN
:{N,N}→dim([A])
:For(I,2,N)
:For(J,2,I)
:(I-1) nCr (J-1)→[A](I,J)
:End
:End
:[A]