Join us on Discord!
You can help CodeWalrus stay online by donating here.

CWick Contest #4: The Tau Problem

Started by Yuki, February 28, 2017, 05:03:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yuki

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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

gameblabla

Tau on the Colecovision :
1k of RAM just isn't enough for Tau...



I will send you the binaries and the sauce.
  • Calculators owned: None (used to own an Nspire and TI-89)

Yuki

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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

Unicorn

#3
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.
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

gameblabla

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
  • Calculators owned: None (used to own an Nspire and TI-89)

Yuki

#5
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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

Dream of Omnimaga

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:

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Yuki

#7
I should put both of those tips I added in the post above in the OP.

EDIT: Here's my entry:

https://www.youtube.com/watch?v=aOsbMWuVA-Y
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

JWinslow23

#8
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

c4ooo

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.

JWinslow23

#10
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!

c4ooo

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


JWinslow23

#13
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

kotu

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."
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony PlayStation 3
SUBSCRIBE TO THE FUTURERAVE.UK MAILING LIST
http://futurerave.uk

Powered by EzPortal