March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
25
Task/Pascals-triangle/AutoHotkey/pascals-triangle-2.ahk
Normal file
25
Task/Pascals-triangle/AutoHotkey/pascals-triangle-2.ahk
Normal 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
|
||||
}
|
||||
17
Task/Pascals-triangle/TI-83-BASIC/pascals-triangle-1.ti-83
Normal file
17
Task/Pascals-triangle/TI-83-BASIC/pascals-triangle-1.ti-83
Normal 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]
|
||||
13
Task/Pascals-triangle/TI-83-BASIC/pascals-triangle-2.ti-83
Normal file
13
Task/Pascals-triangle/TI-83-BASIC/pascals-triangle-2.ti-83
Normal 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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue