## Archive for library

## banned books week

Posted in Statistics with tags American Library Association, banned books, censorship, Ender's Game, Huckleberry Finn, Hunger Games, library, National Coalition Against Censorship, Persepolis, The Curious Incident of the Dog in the Night-Time, The Handmaid's Tale, To Kill a Mockingbird on September 28, 2020 by xi'an## Le Monde puzzle [#1076]

Posted in Books, Kids, R, Travel with tags Brexit, brute-force solution, Gruyère, int2bits, Le Monde, library, mathematical puzzle, pizza, R, University of Warwick on December 27, 2018 by xi'an**A **cheezy Le Monde mathematical puzzle : (which took me much longer to find [in the sense of locating] than to solve, as Warwick U does not get a daily delivery of the newspaper [and this is pre-Brexit!]):

Take a round pizza (or a wheel of Gruyère) cut into seven identical slices and turn one slice upside down. If the only possibly moves are to turn three connected slices to their reverse side, how many moves at least are needed to recover the original configuration? What is the starting configuration that requires the largest number of moves?

Since there are ony N=2⁷ possible configurations, a brute force exploration is achievable, starting from the perfect configuration requiring zero move and adding all configurations found by one additional move at a time… Until all configurations have been visited and all associated numbers of steps are stable. Here is my R implementation

nztr=lengz=rep(-1,N) #length & ancestor nztr[0+1]=lengz[0+1]=0 fundz=matrix(0,Z,Z) #Z=7 for (i in 1:Z){ #only possible moves fundz[i,c(i,(i+1)%%Z+Z*(i==(Z-1)),(i+2)%%Z+Z*(i==(Z-2)))]=1 lengz[bit2int(fundz[i,])+1]=1 nztr[bit2int(fundz[i,])+1]=0} while (min(lengz)==-1){ #second loop omitted for (j in (1:N)[lengz>-1]) for (k in 1:Z){ m=bit2int((int2bit(j-1)+fundz[k,])%%2)+1 if ((lengz[m]==-1)|(lengz[m]>lengz[j]+1)){ lengz[m]=lengz[j]+1;nztr[m]=j} }}

Which produces a path of length five returning (1,0,0,0,0,0,0) to the original state:

> nztry(2) [1] 1 0 0 0 0 0 0 [1] 0 1 1 0 0 0 0 [1] 0 1 0 1 1 0 0 [1] 0 1 0 0 0 1 0 [1] 1 1 0 0 0 0 1 [1] 0 0 0 0 0 0 0

and a path of length seven in the worst case:

> nztry(2^7) [1] 1 1 1 1 1 1 1 [1] 1 1 1 1 0 0 0 [1] 1 0 0 0 0 0 0 [1] 0 1 1 0 0 0 0 [1] 0 1 0 1 1 0 0 [1] 0 1 0 0 0 1 0 [1] 1 1 0 0 0 0 1 [1] 0 0 0 0 0 0 0

Since the R code was written for an arbitrary number Z of slices, I checked that there is no solution for Z being a multiple of 3.

## Bacon in the Library [jatp]

Posted in Books, Kids, pictures, Travel, University life with tags books, Dublin, Eire, Francis Bacon, Ireland, jatp, library, Trinity College Dublin on May 23, 2017 by xi'an## Oxford snapshot [jatp]

Posted in Books, Kids, pictures, Travel, University life with tags architecture, England, jatp, library, Radcliffe Science Library, South Park, University of Oxford on February 9, 2017 by xi'an## Difficulty with mcsm?

Posted in Books, R, Statistics with tags Introducing Monte Carlo Methods with R, library, mcsm, R package on May 5, 2010 by xi'an**A**n email from Keith I got this morning:

Professor Robert,

I have loaded the mcsm package to windows.

The following messages appear in the R console:`trying URL 'http://cran.stat.ucla.edu/bin/windows/contrib/2.9/mcsm_1.0.zip' Content type 'application/zip' length 193590 bytes (189 Kb) opened URL downloaded 189 Kb package 'mcsm' successfully unpacked and MD5 sums checked`

But when I use the demo command as on page 37 from

, I get:Introducing Monte Carlo Methods with R`demo (Chapter.1) Error in demo (Chapter.1): No demo found for topic 'Chapter.1'`

How do I fix this?

**I** think the fix is in loading the package by library(mcsm) [each time one needs it] after installing it [only once]…