Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Oh, and please omit the "Mr". That makes me feel like I'm my dad!

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Hi Bobby,

Yes, I had fun with that. I didn't know the iteration trick until the dice roll problem, but the thought sprang up in my mind and I came up with the trigger idea (B2*0 in cell B2) to utilize circular referencing. No doubt there's a proper way to do that, but mine worked and I haven't looked further.

The mathematics way I haven't got the first clue about...but, as you say, I'm sure it's a little nasty.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**Raito****Member**- Registered: 2012-04-27
- Posts: 50

I am sorry,phrontister

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Hi phrontister;

Good to see you. Your a clever guy even if you aren't a little person.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Hi Bobby,

Sorry to deflate your balloon (which all little people possess), but little people aren't at all clever. Wrong forum for this clue, I know...I'll copy it over to the right one.

Can't continue with that puzzle tonight, though, cos it's actually this morning...well, what's left of it!

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

I know they are also doomed. Have a pleasant night.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Oh...I can't do that! "Topic closed". What now?

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Sorry, it is closed pending MIF's review of it. I can do nothing right now about that. Please hold on to the clue and post tomorrow.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Ok. G'night.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Okay, see you later.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

In my posts #14 & #17 I've now included animated gifs of calculation results so you can see the effect of the iterations.

I increased column B's font size for a more vivid display...which slowed down the animations significantly.

*Last edited by phrontister (2017-02-26 00:17:51)*

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Hi Bobby,

Re the coin-flipping puzzle mentioned in post #17, could you please help me with my M code? I've done two versions of it, and version A works but version B's got a snag I haven't been able to fix.

Version A:

```
c = 0;
For[i = 0, i < 10000, i++,
If[StringCount[ToString[FromDigits[RandomInteger[1, 10]]], "1111"] > 0, c = c + 1]]; N[c/i*100 "%"]
```

Version B:

`N[Total[StringCount[Table[ToString[FromDigits[RandomInteger[1, 10]]], {10000}], "1111"]]/10000*100 "%"]`

The problem with version B is that it counts multiple occurrences of "1111" in an element: eg, "1111011110" scores 2 wins instead of 1, which incorrectly inflates the result.

Also, is there a function (something like StringCount) that can test the RandomInteger lists to see if they contain four consecutive elements that are all "1", so that I can eliminate "[ToString[FromDigits"? StringCount only works on strings (I think), and the only way I could get it to look at RandomInteger's lists was to convert the lists to numbers with FromDigits and then to strings with ToString...which seems to be two steps too many. But I couldn't find anything better (briefer).

Version A takes about 50% longer than version B.

*Last edited by phrontister (2013-05-02 21:19:11)*

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

This problem is also in another thread. I have not gone into it because the OP over there is not ready for a better idea. You unfortunately are.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 4,571

Yes, I saw that thread and I agree with you, which is why I posted here.

*Last edited by phrontister (2013-05-02 21:30:01)*

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Are you attempting to solve this with a simulation?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,037

Have you tried using

`If[StringFreeQ[...,"1111"],0,1]`

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

The right way is not to simulate but to enumerate. I am getting 251 / 1024. The stupidity of the question is monumental! Why would they want to do a simulation of 10000 trials when there are only 1024 possibilities?

Try this:

```
s = Tuples[{0, 1}, 10];
(Cases[s, {___, 1, 1, 1, 1, ___}] // Length)/1024
```

B) Can be adjusted like this,

```
(Select[StringCount[
Table[ToString[FromDigits[RandomInteger[1, 10]]], {10000}],
"1111"], # > 0 &] // Length)/10000.
```

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,037

Instead of Cases[...]//Length you can just use Count[...].

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Hi;

Yes, you can. the important thing is the difference in the method of solution. The enumeration gives the exact answer, something the simulation can never give.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,037

Yes, but if we wanted a simulation, phro's way is a good way to go.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Not exactly, string operations are not necessary. It is more convenient to work with the preferred container of M. Lists!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,037

I meant, in the sense of idea, bot in te sense of implementation.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

The first bit of code does run a good simulation.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,037

Here is my own code with no strings:

`Count[Table[RandomInteger[], {10000}, {10}], {___, 1, 1, 1, 1, ___}]/10000 // N`

*Last edited by anonimnystefy (2013-05-02 23:37:32)*

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

You will find this to be faster:

```
Count[Table[
RandomVariate[DiscreteUniformDistribution[{0, 1}],
10], {10000}], {___, 1, 1, 1, 1, ___}]
```

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline