You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

CWick Contest #4: The Tau Problem

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/Contests publicado por u/Yuki February 28, 2017, 05:03:02 AM
Wait what? It's back? Well, then. Today I ask you the 1000 first digits of tau. I think @JWinslow23 will love this one. So if you remember how it's done, I ask you a program that have this output exactly (or more):

6.283185307179586476925286766559005768394338798750211641949889184615632812572417997256069650684234135964296173026564613294187689219101164463450718816256962234900568205403877042211119289245897909860763928857621951331866892256951296467573566330542403818291297133846920697220908653296426787214520498282547449174013212631176349763041841925658508183430728735785180720022661061097640933042768293903883023218866114540731519183906184372234763865223586210237096148924759925499134703771505449782455876366023898259667346724881313286172042789892790449474381404359721887405541078434352586353504769349636935338810264001136254290527121655571542685515579218347274357442936881802449906860293099170742101584559378517847084039912224258043921728068836319627259549542619921037414422699999996745956099902119463465632192637190048918910693816605285044616506689370070523862376342020006275677505773175066416762841234355338294607196506980857510937462319125727764707575187503915563715561064342453613226003855753222391818432840398

You're allowed mostly everything, a calc (scrolling or output to a Str variable might be needed), a PC, a Google Home that speaks the output, whatever. This is also a code golf contest: smaller is better, but it will also be judged on how original the method to produce or to show the output is, be it an algorithm, compression or whatever, and also how fast it is. You need not to have that output exactly, variations are allowed, as long as it shows more or less these digits. Standard code golf pitfalls from Stack Overflow applies.

Send the sources of your entries to [email protected]. Contest ends Monday March 13th 23:59:59 EST. (Two weeks this time, because it's a big one.)

Note that the schedule is now whenever I feel like. Feel free to send ideas for future contests like this.
Last Edit: February 28, 2017, 05:09:46 AM by Juju
Inicia sesión o crea una cuenta para dejar un comentario
u/gameblabla February 28, 2017, 06:53:09 AM
Tau on the Colecovision :
1k of RAM just isn't enough for Tau...



I will send you the binaries and the sauce.
u/Yuki February 28, 2017, 07:14:42 AM
Oooh, that nice. On that note, 1000 digits is not a hard limit if the system you're coding for don't allow for it, although there's algorithms that lets you calculate tau digit by digit, you might get around by throwing away the digit once it's displayed on screen.
u/Unicorn February 28, 2017, 07:41:43 AM
This reminds me... Did i ever get my Hello World walrii points? :P

Oh yes, and now i have an interesting idea.. not sure if i could pull it off tho.
Last Edit: February 28, 2017, 07:44:19 AM by Unicorn
u/gameblabla February 28, 2017, 07:45:36 AM
Ok juju, i found a workaround for the small memory. (just do it in several parts)
Tau fits on two-screen !
I will send you the new version
u/Yuki February 28, 2017, 08:18:25 AM
Quote from: Unicorn on February 28, 2017, 07:41:43 AM
This reminds me... Did i ever get my Hello World walrii points? :P
Ah yeah, the WalriiPoints. I'll look at this later.

EDIT: Also, just a tip, you shouldn't merely store the output in the program and print it, some transformation or generation should be done.
EDIT2: Tip #2: If the language you picked only allows for a limited number of decimals, you should find an algorithm that can go over that limit. There's some algos that can print arbitrary digits.
Last Edit: February 28, 2017, 08:24:25 AM by Juju
u/Dream of Omnimaga February 28, 2017, 05:13:07 PM
Woah nice @gameblabla . Also @Juju if 1000 is not an hard limit, then does it mean that the following code would have been acceptable in TI-83 Plus BASIC (at the cost of being nearly guaranteed to lose)? :trollface:

u/Yuki February 28, 2017, 08:08:37 PM
I should put both of those tips I added in the post above in the OP.

EDIT: Here's my entry:

Last Edit: February 28, 2017, 08:22:59 PM by Juju
u/JWinslow23 March 01, 2017, 01:33:56 AM
I just now noticed this.

I suppose I have to come up with something. TI-BASIC would be my target platform if I get this done, let's see if I can encode 1000 digits in less than 1KB. :P

EDIT: I already did this in <1KB, actually. For this specific problem, I optimized the previously-done (therefore invalid :P ) solution to 879 bytes, though it may not finish in the lifespan of your battery.

Goto 0
Lbl 1
If min(L₁)>0 and ᴇ10≥max(L₁
End
0→PMT
For([recursiven],1,dim(L₁
PMT+L₁([recursiven]→|N
int(|Nᴇ⁻10→PMT
|N-PMTᴇ10→L₁([recursiven]
End
If not(PMT
End
[recursiven]→dim(L₂
Ans→dim(ʟQ
Ans→dim(ʟR
Ans→dim(ʟT
PMT→L₁(Ans
End
Lbl 2
1+dim(L₁→|N
Repeat Ans or |N=1
|N-1→|N
L₁(|N)-L₂(|N
End
End
Lbl 0
SetUpEditor T,R,Q
{30→T
6Ans→R
{1→Q
ClrHome
"?→Str1
2→I%
Lbl 3
If 1<length(Str1
Then
"             
If not(fPart((length(Str1)-2)/16
Output(6+C,1,sub(Ans+Ans,1,16
2+16int((length(Str1)-114)/16)(130≤length(Str1
Output(1,1,sub(Str1,Ans,1-Ans+length(Str1
End
5ʟT→L₁
For(θ,⁻1,0
If θ
Goto 1
End
L₁→L₂
(9I%-4)ʟQ→L₁
For(θ,⁻1,0
If θ
Goto 1
End
3L₁+5ʟR→L₁
For(θ,⁻1,0
If θ
Goto 1
End
0→PV
For(θ,⁻1,0
If θ
Goto 2
End
While Ans≥0
PV+1→PV
L₁-L₂→L₁
For(θ,⁻2,0
If θ=⁻2
Goto 1
If θ
Goto 2
End
End
sub("0123456789",PV+1,1
If I%=2
Ans+".
Str1+Ans→Str1
(5I%-2)ʟQ+ʟR-PVʟT→L₁
For(θ,⁻1,0
If θ
Goto 1
End
30L₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
If I%<33
Then
9I%²+9I%+2
Else
(3I%+1)L₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
3I%+2
End
AnsL₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
L₁→ʟR
10I%ʟQ→L₁
For(θ,⁻1,0
If θ
Goto 1
End
(2I%-1)L₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
L₁→ʟQ
3ʟT→L₁
For(θ,⁻1,0
If θ
Goto 1
End
If I%<33
Then
9I%²+9I%+2
Else
(3I%+1)L₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
3I%+2
End
AnsL₁→L₁
For(θ,⁻1,0
If θ
Goto 1
End
L₁→ʟT
I%+1→I%
If getKey≠45 and 1003>length(Str1
Goto 3
If 1003=length(Str1
Pause
ClrHome
Last Edit: March 01, 2017, 01:53:18 AM by JWinslow23
u/c4ooo March 01, 2017, 03:21:41 AM
If someone could post an algorithm to find all the terms of tao in succession i would be willing to golf something up in axe.
u/JWinslow23 March 01, 2017, 03:55:39 AM
Quote from: c4ooo on March 01, 2017, 03:21:41 AM
If someone could post an algorithm to find all the terms of tao in succession i would be willing to golf something up in axe.
*tau

And I just posted one. :P

Also, I'm working on my TI-BASIC version, and right now, it's 505 digits in 428 bytes (including the 6. at the beginning). That's about 1.18 digits per byte!
Last Edit: March 01, 2017, 04:22:58 AM by JWinslow23
u/c4ooo March 01, 2017, 09:00:42 PM
Quote from: JWinslow23 on March 01, 2017, 03:55:39 AM
Quote from: c4ooo on March 01, 2017, 03:21:41 AM
If someone could post an algorithm to find all the terms of tao in succession i would be willing to golf something up in axe.
*tau

And I just posted one. :P
One that isn't in TI-BASIC :P
u/JWinslow23 March 01, 2017, 09:04:16 PM
This paper has some in Haskell for pi. Adapting them to tau shouldn't be hard.
u/JWinslow23 March 02, 2017, 06:33:37 PM
Bump.

I've been working on the spigot, and if I let it go infinitely and display one digit at a time, I can get it down to 383 bytes.
{30→T
6Ans→R
{1→Q
ClrHome
For(I,2,ᴇ4
⁻1→V
5ʟT
For(θ,V,0
If θ
Goto 1
End
ʟA→B
Ans+3(9I-4)ʟQ+5ʟR→A
Repeat Ans<0
IS>(V,9
ʟA-ʟB
For(θ,⁻1,0
If θ
Goto 1
End
End
Disp V
(5I-2)ʟQ+ʟR-VʟT
For(W,0,1
For(Z,1,2
If W
(3I+Z)ʟA
For(θ,⁻1,0
If θ
Goto 1
End
30ʟA
End
End
ʟA→R
10IʟQ
For(W,⁻1,0
For(Z,1,2
If not(W
(3I+Z)ʟA
For(θ,⁻1,0
If θ
Goto 1
End
(2I-1)ʟA
End
If W
ʟA→Q
If W
3ʟT→A
End
ʟA→T
End
Lbl 1
DelVar PAns→A
For(M,1,dim(ʟA
P+ʟA(M→N
int(Ansᴇ⁻9→P
N-Ansᴇ9→ʟA(M
End
If P
P→ʟA(M
dim(ʟA→dim(ʟB
Ans→dim(ʟQ
Ans→dim(ʟR
Ans→dim(ʟT
Ans→N
Repeat Ans or not(N
ʟA(N)-ʟB(N
DS<(N,0
End
End
Last Edit: March 02, 2017, 11:08:34 PM by JWinslow23
u/kotu March 03, 2017, 04:22:34 AM
I'm not joining in because it looks too hard but I found this.....

"Are you trying compute ALL the digits from the first to the Nth? Or are you just trying to get a few digits around the Nth binary digit? There is no reason to use the BBP formula if you want all the digits as there are MUCH faster formulas out there for Pi."
Start a Discussion

b/Contests

Sub-forum to discuss past, present and future CodeWalrus competitions and challenges.

63
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal