A list of puns related to "Spigot algorithm"
so my code is
with ada.integer_text_io; use ada.integer_text_io;
with Ada.Text_IO; use Ada.Text_IO;
procedure Spigot is
n : constant Integer := 1000;
length : constant Integer := 10*n/3+1;
x,q,nines,predigit :Integer :=0;
a: array (0..length) of Integer;
begin
nines:=0;
predigit:=0;
for j in 0..length loop
a(j):=2;
end loop;
for j in 1..n loop
q:=0;
for i in reverse 1..length loop
x:=10*a(i) + q*i;
a(i):= x mod (2*i-1);
q:= x/(2*i-1);
end loop;
a(1):= q mod 10;
q:=q/10;
if q = 9 then
nines:=nines+1;
elsif q = 10 then
put(predigit+1);
for k in 0..nines loop
put("0");
end loop;
predigit:=0;
nines:=0;
else
put(predigit);
predigit:=q;
if nines/=0 then
for k in 0..nines loop
put("9");
end loop;
nines:=0;
end if;
end if;
end loop;
put(predigit);
end Spigot;
it should be outputting the digits of pi, 1 digit at a time but it's messing up and going 0 3 1 4 1 599 and then just messes up from there, and I can't figure out why
Hello, /r/math.
I have recently stumbled upon the fact that individual hexadecimal digits of Pi can be generated using an algorithm.
This got me thinking: how on earth can some sequence be random if there's an algorithm for finding every member of it?! I thought Pi's digits were completely random...help me out on this I don't know what to do
Shuffling algorithms have been on my mind for a while. Specifically, I've been thinking about spigot-style algorithms: I want to calculate the next card in a shuffled deck, without calculating the rest of the deck.
For example, suppose I had a deck of 10 cards. I could rearrange them by setting new_card_position = old_card_position*3 mod 11:
This: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Becomes: 3, 6, 9, 1, 4, 7, 10, 2, 5, 8
This works because 3 and 11 are coprime, which means 3 has an inverse mod 11 (i.e., multiply by 4), which means there's a one-to-one mapping -- and ta-da, you've defined a permutation! It's easy to do, and it kind of looks like a random shuffle (though you can see patterns if you look closely).
Here's a different permutation: new_card_position = 6^old_card_position mod 11:
This: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Becomes: 6, 3, 7, 9, 10, 5, 8, 4, 2, 1
This works because 11 is prime, and 6 is a generator for the multiplicative group of integers mod 11, and mumble foo hah blibbity I can't do the explanation justice right now. But it works! And the pattern is a bit better hidden! Downsides: it only works for certain sizes of decks, and finding generators is a trial-and-error process.
Putting all practical concerns aside, I've discovered that I really enjoy thinking about these kinds of algorithms. I'm also aware of the limits of my own knowledge: it's really useful to talk to people who have studied different things!
So if you happen to have any suggested permutations, areas/topics for further study, or suggested reading/study material, I would be delighted to hear about them. My foray into discrete math has been mostly self-study, so I don't have a lot of context regarding where-to-look/what-to-read.
Thank you!
I don't want to step on anybody's toes here, but the amount of non-dad jokes here in this subreddit really annoys me. First of all, dad jokes CAN be NSFW, it clearly says so in the sub rules. Secondly, it doesn't automatically make it a dad joke if it's from a conversation between you and your child. Most importantly, the jokes that your CHILDREN tell YOU are not dad jokes. The point of a dad joke is that it's so cheesy only a dad who's trying to be funny would make such a joke. That's it. They are stupid plays on words, lame puns and so on. There has to be a clever pun or wordplay for it to be considered a dad joke.
Again, to all the fellow dads, I apologise if I'm sounding too harsh. But I just needed to get it off my chest.
Do your worst!
They were cooked in Greece.
I'm surprised it hasn't decade.
Don't you know a good pun is its own reword?
Two muffins are in an oven, one muffin looks at the other and says "is it just me, or is it hot in here?"
Then the other muffin says "AHH, TALKING MUFFIN!!!"
For context I'm a Refuse Driver (Garbage man) & today I was on food waste. After I'd tipped I was checking the wagon for any defects when I spotted a lone pea balanced on the lifts.
I said "hey look, an escaPEA"
No one near me but it didn't half make me laugh for a good hour or so!
Edit: I can't believe how much this has blown up. Thank you everyone I've had a blast reading through the replies π
It really does, I swear!
Because she wanted to see the task manager.
But thatβs comparing apples to oranges
Heard they've been doing some shady business.
but then I remembered it was ground this morning.
Edit: Thank you guys for the awards, they're much nicer than the cardboard sleeve I've been using and reassures me that my jokes aren't stale
Edit 2: I have already been made aware that Men In Black 3 has told a version of this joke before. If the joke is not new to you, please enjoy any of the single origin puns in the comments
BamBOO!
Theyβre on standbi
A play on words.
My daughter, Chewbecca, not so much.
Pilot on me!!
Christopher Walken
And boy are my arms legs.
Nothing, he was gladiator.
Or would that be too forward thinking?
Dad jokes are supposed to be jokes you can tell a kid and they will understand it and find it funny.
This sub is mostly just NSFW puns now.
If it needs a NSFW tag it's not a dad joke. There should just be a NSFW puns subreddit for that.
Edit* I'm not replying any longer and turning off notifications but to all those that say "no one cares", there sure are a lot of you arguing about it. Maybe I'm wrong but you people don't need to be rude about it. If you really don't care, don't comment.
What did 0 say to 8 ?
" Nice Belt "
So What did 3 say to 8 ?
" Hey, you two stop making out "
When I got home, they were still there.
Hindus, on the other hand, never had any beef.
I won't be doing that today!
This morning, my 4 year old daughter.
Daughter: I'm hungry
Me: nerves building, smile widening
Me: Hi hungry, I'm dad.
She had no idea what was going on but I finally did it.
Thank you all for listening.
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.