O'Reilly logo

Digital Dice by Paul J. Nahin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Solutionimages

images

9. The Forgetful Burglar Problem

The code of fb.m simulates ten million paths of the burglar, with each path continuing until a previously visited house is revisited. Line 01 defines the row vector duration as having fifty elements, where duration(k) is the number of paths with length k steps (each step is a move of length 1 or 2). Lines 02 and 19 define the for/end loop that cycle fb.m through its ten million simulations. Each simulation will continue as long as the variable go is equal to 1, to which it is initially set in line 03. Line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required