JWinslow23 wrote:
mr womp womp wrote:
ln(√( )
i/Ans/(e^(-πiA

τ. Razz

I even took a look at the Lanczos approximation, the actual place that first guy got the gamma function formula, and guess what it consists of?


where


One more image from the Mathworld page on it:


All 2πs. No πs.


Oh god...
KermMartian wrote:
Post 'em up here, like this:

[Bunch of routines...]

Thank you, I didn't realize most of these, and i feel stupid, but I not use these every time!

+1 satisfied customer.

Edit by PT_, please don't have HUUGGEE quotes Smile
JWinslow23 wrote:


I made my own version a long time ago.


Code:
ClrHome
"?
Disp "NUMBER:","",Ans,Ans,Ans,Ans
Output(8,1,"RED: 0  WHITE: 0
DelVar TDelVar GDelVar Rint(10rand(4→L1
4→dim(L2
Repeat T=14 or K=45 or R=4
Repeat Ans
getKey
End
Ans(102≠Ans)-13int(Ans/13(2>abs(5-abs(5-abs(Ans-83→K
If Ans=105 and G=4
Then
For(X,1,4
Output(2+X,3+T,L2(X
End
DelVar GT+1→T
sum(L1=L2→R
Output(8,6,Ans
Output(8,16,‾Ans+sum(seq(min(sum(L1=X),sum(L2=X)),X,0,9
Output(1,9,"    //4 spaces
Else
If Ans≤9 and G≠4
Then
G+1→G
K→L2(Ans
End
If Ans=24 and G
Then
G-1→G
Output(1,Ans+9," //1 space
End
End
For(X,0,G
If X
Output(1,8+X,L2(X
End
End
For(X,1,4
Output(2+X,1,L1(X
End
If K≠45
Then
Output(1,1,"YOU "+sub("WIN!   LOSE...",8-7(R=4),7
Pause
End
DelVar GDelVar KDelVar RDelVar TDelVar XDelVar L1DelVar L2ClrHome



Mine's shorter. *mike drop*
min(, without zeroes
Returns the smallest number in a list, besides zeroes.

Code:
min(Ans+not(Ans)max(Ans
Flip a string/ reverse it
Takes a string, Str1, reverses it and returns the output in Str2
There may be others like this, but this isn't very optimized because I came up with this on my own.


Code:
Input Str1
" "->Str2
For(A,length(Str1),1,~­1
Str2+sub(Str1,A,1->Str2
End
sub(Str2,2,length(Str2)-1->Str2
Pause Str2
That is a very cool trick. Can you do that to a PHYSICAL TI-84 Plus?
Graphing Calculator TI-84+
tnn wrote:
That is a very cool trick. Can you do that to a PHYSICAL TI-84 Plus?
Graphing Calculator TI-84+

You can pick up a real ti-84 calculator and type it into the program editor if that's what you mean...
For the flip a string thing?? Basically, if you input "ABC TI-SUX", it would output "XUS-IT CBA"
Find and Replace Text in String
Replaces all occurrences of a specific search text in a string with desired replacement text.
This has no doubt been attempted before, but here is my take on it.

Inputs:
Str1- main string
Str2- search string
Str3- replacement string


Outputs:
Str1- the string that gets modified


Code:
length(Str2->J
While inString(Str1,Str2
   inString(Str1,Str2->I
   Str3
   If I>1
   sub(Str1,1,I-1)+Ans
   If I+J<1+length(Str1
   Ans+sub(Str1,I+J,1+length(Str1)-(I+J
   Ans->Str1
End
I made some further optimizations (also, "length" is spelled wrong Smile)


Code:
length(Str2->J
1->I
While I
   inString(Str1,Str2->I
   Str3
   If I>1
   sub(Str1,1,I-1)+Ans
   If I+J<1+length(Str1
   Ans+sub(Str1,I+J,1-J-I+length(Str1
   Ans->Str1
End
_iPhoenix_ wrote:
I made some further optimizations (also, "length" is spelled wrong Smile)


Code:
length(Str2->J
1->I
While I
   inString(Str1,Str2->I
   Str3
   If I>1
   sub(Str1,1,I-1)+Ans
   If I+J<1+length(Str1
   Ans+sub(Str1,I+J,1-J-I+length(Str1
   Ans->Str1
End

Length was never spelled wrong.

Also, that code won’t even work since variable I has a chance of being 0 within the loop, which would cause problems. The loop is not even supposed to run at all unless an occurrence of the search string was found.
Michael2_3B wrote:
Find and Replace Text in String
Replaces all occurrences of a specific search text in a string with desired replacement text.
This has no doubt been attempted before, but here is my take on it.

Inputs:
Str1- main string
Str2- search string
Str3- replacement string


Outputs:
Str1- the string that gets modified


Code:
length(Str2->J
While inString(Str1,Str2
   inString(Str1,Str2->I
   Str3
   If I>1
   sub(Str1,1,I-1)+Ans
   If I+J<1+length(Str1
   Ans+sub(Str1,I+J,1+length(Str1)-(I+J
   Ans->Str1
End


Here's my attempt at an optimized version. Only saves 5 bytes, but I think behavior is preserved:

Code:
length(Str2→J
While inString(Str1,Str2
   inString(Str1,Str2→I
   Str3
   If ln(I
   sub(Str1,1,I-1)+Ans
   If I+J≤length(Str1
   Ans+sub(Str1,I+J,1-I-J+length(Str1
   Ans→Str1
End
I have found a problem with this routine. If your replacement string contains the character(s) in your find string, such as if I was wanting to replace "A" in the string "ABCA" with the characters "DA", you'd expect the output of "DABCDA". However, this is not the output. The program actually runs forever since "A" is still in the main string.

I am working on a solution and will edit this when I find one. Unless someone finds a solution faster than me!

EDIT: This should work

Code:
length(Str2->J
1->I
While inString(Str1,Str2,I
inString(Str1,Str2,I->I
Str3
If ln(I
sub(Str1,1,I-1)+Ans
If I+J<=length(Str1
Ans+sub(Str1,I+J,1-I-J+length(Str1
Ans->Str1
I+length(Str3->I
End
Expanding Quadratics
Inputs:
Y1 = Expression in X with quadratic behavior
Outputs:
L1 = Coefficients of the standard form of Y1 (descending)


:i→X
:Y1(0
:real({Ans-Y1,imag(Y1),Ans→L1

I posted this as a marginal note six years ago and thought it deserved some fresh air. You can use it to sum, multiply, and divide any combination of polynomials for which the result is expected to be quadratic. It can also convert away from vertex form, or anything else indicative of the quadratic function. Note that adjusting the 0 is convenient for approaching limits.
Find and Replace any element in a string
The variables you need are
1. T, which is the number of the element inside the string to be replaced.
2. str1, which is the original string you're searching through.
3. str2, which is the thing you're replacing T element with... to make it an int you could use toString(variable) instead.

Code:

sub(sub(Str1,1,T-(T!=1))+str2+sub(Str1,T+(T!=length(str1))),length(Str1)-T+(T=length(str1))),2(T=1)+(T!=1),length(Str1) -> Str1


(I don't know if someone already posted something similar in this thread somewhere or not... I didn't look through) Smile Smile

OH,and forgot to mention this, but you could make this a thing to search the string for something and replace it by just making the variable T =

Code:
inString(str1,"string to be searched for")
I was golfing recently and here are a few of the results of that golfing:

First A natural numbers in a list in 7 bytes
Inputs: A = A number
Output: Ans = list of A natural numbers
Destroys: Ans


Code:
:cumSum(not(0rand(A

Also, The first A+1 natural numbers in a list in 7 bytes

Code:
:cumSum(binomcdf(A,0


Find the last occurrence of a number in a list in 13 bytes
Inputs:
A = A number
L1 = A list
Output: Ans = the position of the last occurrence of A in L1
Destroys: Ans


Code:
:max((A=L1)cumSum(not(0L1
Saves seven byte over Ed H's snippet


Find the last occurrence of a number in a reversed list in 7 bytes
Note: Only works if 1=sum(A=L1
Inputs:
A = A number
L1 = A list
Output: Ans = Location
Destroys: Ans


Code:
:sum(cumSum(A=L1
For example, A=3 & L1={1,2,3,4 will output 2.


Reverse a list in Ans in 16 bytes
Inputs: Ans = A list
Output: Ans = The reversed list
Destroys: Ans


Code:
:seq(Ans(A),A,dim(Ans),1,-1
I golfed one piece of code forever only to find out this was still smaller… Any ideas?


Reverse L1 in 15 bytes
Inputs: L1 = A list
Output: L1 = The reversed list
Destroys: L1, |LZ


Code:
cumSum(not(0L1->Z
SortD(|LZ,L1


I didn't see this one anywhere, so here is my attempt at it:
Number of times A evenly divides B
(The Greatest n such that A^n evenly divides B)
in 17 bytes
Inputs: A, B
Output: Ans=n
Destroys: Ans


Code:
:gcd(B,A^int(round(log(B,A
:log(Ans,A


Edit1: Fixed up the last snippet including kg583's edits.
Edit2: Added "The first A+1 natural numbers in a list"
Edit3: Changed 1+s to not(s Credit to PT_.
Edit4: Added "Destroys:" and updated snippet 2 (replaced rand(dim(L1 with L1) More credit to PT_
Edit5: Added "Reverse L1"
Edit6: Fixed spacing
Edit7: Added Edit6 entry
Edit8: Updated last snippet
22 -> 16 bytes
Edit9: Added round( to last snippet
(+1 byte)
LogicalJoe wrote:
I didn't see this one anywhere, so here is my attempt at it:
Number of times A divides B in 16/31 bytes
Inputs:
A = A number
B = Another number (that is not a power of A due to a mistake in the algorithm I couldn't fix without creating a special case)
Output: Ans


Code:
:int(round(A^^-1gcd(B,A^int(logBASE(B,A

// Special case :(
:If not(fPart(logBASE(B,A
:logBASE(B,A
If B's maximum possible value is known, replace int(logBASE(B,A with the value of int(logBASE(Bmax,A.


Maybe I'm misunderstanding you, but is iPart(A/B not valid for some reason?
_iPhoenix_ wrote:
LogicalJoe wrote:
I didn't see this one anywhere, so here is my attempt at it:
Number of times A divides B in 16/31 bytes
Inputs:
A = A number
B = Another number (that is not a power of A due to a mistake in the algorithm I couldn't fix without creating a special case)
Output: Ans


Code:
:int(round(A^^-1gcd(B,A^int(logBASE(B,A

// Special case :(
:If not(fPart(logBASE(B,A
:logBASE(B,A
If B's maximum possible value is known, replace int(logBASE(B,A with the value of int(logBASE(Bmax,A.


Maybe I'm misunderstanding you, but is iPart(A/B not valid for some reason?

The routine Provides the number of times one number is divisible by another, so if A=4 and B=40, it will output 1 because 4 only goes into 40 once. While int(40/4 will output 10.

another example: A=2 B=20:
20/2=10, 10/2=5, so it outputs 2.

I don't know how else to describe it? Confused

Edit: Clarified title.
Is there a way to find the gamma function of a complex number on a TI-84 Plus CE?
Find the last occurrence of a number in a list in 12 bytes
Inputs:
A = A number
L1 = A list
Output: Ans = the position of the last occurrence of A in L1


Code:
A=L1
max(AnscumSum(not(0Ans
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3 ... 12, 13, 14, 15  Next
» View previous topic :: View next topic  
Page 13 of 15
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement