User:Matt Crypto/scratch2

From Wikipedia, the free encyclopedia

Inline tables[edit]

I don't suppose some Wikicode/HTML guru could help me with the following formatting? I'd like to be able to use a box like the following for bilingual conversations on the Swahili Wikipedia:

en: let's delete this article
sw: tufute makala hii

However, the above box always starts a new line. It would be most useful as an "inline" table. That is, if it could be used like this:

Here is some , all inline.

Of course, that's a nasty LaTeX hack. Could someone suggest a good way of doing this in normal mediawiki code?

Cheers! — Matt Crypto 10:21, 27 January 2006 (UTC)

You can, in principle, do it with the CSS display attribute, but browser support for it is somewhat variable. Giving the table a style of display: inline; display: inline-table; will do it in most browsers that support CSS at all, although I found some claims that this may break in some versions of IE. —Ilmari Karonen (talk) 22:46, 27 January 2006 (UTC)
Unfortunately, this won't work in general. W3C arbitrarily decided that <table> cannot be nested in <p>, so HTML Tidy will helpfully insert a </p> before <table> in normal, unindented paragraphs. Inline tables will work in indented paragraphs because they use <dd>. One solution might be to patch tidy; there should be no technical reason behind W3C's restriction. It's also possible to work around the restriction using CSS display attributes; for example, {{suþ}} can produce superscripts above subscripts, as so: 1
2
×3
4
. ᓛᖁ♀ 23:26, 27 January 2006 (UTC)
Maybe a modification of the code I use in my signature would achieve the look that you are requesting. —WAvegetarianCONTRIBUTIONSTALKEMAIL07:45, 28 January 2006 (UTC)
The {{suþ}} solution doesn't look right in Firefox 1.5: the bottom of the table lines up with the center of the surrounding text. This could be fixed by setting the vertical-align on the table, but that is easier said than done since it's an implicitly created anonymous table with no corresponding DOM node. Setting the display of the surrounding span to inline-table would work, if Firefox actually understood it, which it doesn't. As much as I like it in general, I'll have to say that, in this particular respect, Firefox sucks. And you can quote me on that. —Ilmari Karonen (talk) 13:55, 28 January 2006 (UTC)
Something like this, loosely based on WAvegetarian's code, might work: 12×34. Its main weakness is that the superscript can overlap the following text if it is wider than the subscript. Of course, putting the subscript first in the markup reverses the situation. —Ilmari Karonen (talk) 14:12, 28 January 2006 (UTC)
I've changed Template:Suþ to use this markup. —Ilmari Karonen (talk) 17:44, 28 January 2006 (UTC)
Hm, that's interesting. In Mozilla, the position trick doesn't always display the same way. The placement seems to depend on the line height somehow: on Template:Suþ {{{1}}} overlaps {{{2}}}; the example in front of my signature has a few pixels between the superscript and subscript; and two paragraphs above there is only one pixel between. It looks like the superscripts aren't being placed at the correct height. They had also disappeared when I came to this page, but are now visible again. How do the following look? ᓛᖁ♀ 18:36, 28 January 2006 (UTC)
12×34 4×1 12×34 4×1 12×34 4×1 12×34 4×1
The later ones are all mashed up. If you try stacking them like this:
12×34 4×1

12×34 4×1

12×34 4×1

12×34 4×1

then the first line is cropped slightly at the bottom but the later ones look fine. Maybe it's using multiple values of line-height on the same row? HTH HAND —Phil | Talk 11:52, 30 January 2006 (UTC)

Smarties lids[edit]

File:Smarties (Candy).jpg
Smarties. Good to eat, but how many tubes before I get the entire alphabet? Only Smarties know the answer

Before the new, horrendous "hexatube" packaging, tubes of Nestlé Smarties used to contain a letter of the alphabet under the cap. Assuming the cap letters are chosen uniformly at random, how many Smarties tubes would I expect to have to buy before I had collected the entire alphabet? — Matt Crypto 18:33, 17 January 2006 (UTC)

I believe we had an equivalent question some time ago. Ah, here it is. The probability of finding all the n = 26 letters of the alphabet in m tubes is
.
This is the number of surjections from M = {1 … m} to N = {1 … n} divided by the total number of functions from M to N (= nm). Using the Perl code on the page I linked to above, I find that 94 tubes is enough to give you just barely more than even odds of getting all the letters. I even made a graph of the probabilities for 0 ≤ m ≤ 200. —Ilmari Karonen (talk) 19:33, 17 January 2006 (UTC)
I am not sure about the wording of the problem. I think that the question is not how many tubes would guarantee (with some probability) that I have all 26 letters in them. You start buying the tubes, and in X-th tube you get the last needed letter (you have 25 letters in X-1 tubes and 26 in X tubes). What is expected value of such X?
Is this the right question?(Igny 22:11, 17 January 2006 (UTC))
(edit conflicted, but this relates nicely to Igny's posting)
So
(Estimation made with the nice Perl code) Rasmus (talk) 22:23, 17 January 2006 (UTC)
Thanks for the answers! I meant to ask the latter question as clarified by Igny, but both answered questions are interesting. I'd give you all a smartie if I could. — Matt Crypto 23:39, 17 January 2006 (UTC)
While I am not 100% convinced that formula for P(m,n) is correct, there is a recursive way to compute P(m,n). Introduce
.
Notice that
(Igny 13:55, 18 January 2006 (UTC))
Smarties? Isn't that just Communist for M&Ms?'--George 19:41, 17 January 2006 (UTC)

You get your first letter after an average of 26/26 packets, your second letter after an average of 26/25 packets, and your last letter after an average of 26/1 packets. Since all these are independent, the expected total number of packets is

Which is about 100.2, just as Rasmus calculated. Gdr 18:37, 18 January 2006 (UTC)

In other words, . (Note, by the way, that your top index is off by one.) Fredrik Johansson - talk - contribs 21:09, 18 January 2006 (UTC)
My congratulations, it is a very elegant solution. Indeed, all previous solutions were based on trying to find P(X=x) and EX without realizing that , such that and are easy to compute. And you don't even need independence, since even for not independent (Igny 13:17, 23 January 2006 (UTC))