Ripple Effect

Ed Pegg Jr

Sudoku, today’s most well-known grid-solving puzzle, was originally invented by Howard Garns in 1978. NIKOLI Co., Ltd., a magazine publisher, introduced the puzzle in Japan during the 1980s. Almost 30 years later, its popularity suddenly exploded. Bookstores now carry dozens of Sudoku books. 

Eventually, other puzzle types will explode in popularity. This new column presents obscure logic puzzles of various sorts and challenges the readers to solve the puzzles in two ways: by hand and with Mathematica. For the latter, solvers are invited to send their code to edp@wolfram.com. The person submitting the most elegant solution will receive a prize.

Instructions

Ripple Effect was first published in Puzzle Communication Nikoli in May 1998 []. In these puzzles, a grid is divided into polyomino-shaped rooms.

Each room contains consecutive numbers starting from 1. Thus, a domino will always have 1 and 2. A triomino will always have 1, 2, and 3. And so on.

If a number is duplicated in a row or a column, the space between the duplicated numbers must be equal to or larger than the value of the number. Thus, there will always be at least one digit between 1s, at least two digits between 2s, and so on.

Here is a solved example puzzle. The first grid is the puzzle itself. In the second, some preliminary logic has been done. To start, all single squares need a 1. Ones cannot be adjacent, which forces a few more placements. The square marked “A” cannot be a 2, since the domino above it could not be filled. With further logic, the entire puzzle is solved.

Example

Show[GraphicsArray[Map[Graphics[Riplines[#],AspectRatio->Automatic]&,{RippleEffectPuz01,RippleEffectPuz01a,RippleEffectPuz01b}]/. 9 -> "A"]]

Puzzles

Here are two warm-up puzzles to solve, both from the Puzzle Cyclopedia []. See the Puzzle Source section for the puzzle entry code and the Code section for the graphics.

Show[GraphicsArray[Map[Graphics[Riplines[#],AspectRatio->Automatic]&,{RippleEffectPuz02,RippleEffectPuz03}]]]

Here are some intermediate puzzles from Puzzle Communication Nikoli [].

Show[GraphicsArray[Map[Graphics[Riplines[#],AspectRatio->Automatic]&,{RippleEffectPuz04,RippleEffectPuz05,RippleEffectPuz06}]]]

Finally, here is a challenge puzzle from Puzzle Communication Nikoli [].

Show[Graphics[Riplines[RippleEffectPuz07],AspectRatio->Automatic]]

Do let us know what you think of this new column. Send your comments to edp@wolfram.com.

Puzzle Source

RippleEffectPuz01 = {{7,7},{4454,8518,10370,5281,1711,1039,10277},{0,0,6000,4000,1000,0,0}};

RippleEffectPuz01a = {{7,7},{4454,8518,10370,5281,1711,1039,10277},{1200121,2100010,1306100,4001,1000,0,9000121}};

RippleEffectPuz01b = {{7,7},{4454,8518,10370,5281,1711,1039,10277},{1213121,2142312,1326143,3214521,1431214,2152432,1213121}};

RippleEffectPuz02 = {{7,7},{9569,8489,8736,8544,5361,9268,10992},{0,0,3,0,3000000,0,0}};

RippleEffectPuz03 = {{7,7},{1105,5153,8291,11107,11055,775,981},{0,10,0,1000,0,100000,0}};

RippleEffectPuz04 = {{10,10},{332800,435607,984244,269044,670208,438746,327930,615680,27801,305173},{0,0,4000003,0,5000,2,500100000,0,0,50000000}};

RippleEffectPuz05 = {{10,10},{5384,177960,342948,592661,664832,142117,23141,547917,656394,329066},{0,0,0,0,0,0,0,0,0,0}};

RippleEffectPuz06 = {{10,10},{589994,666178,610565,32842,102747,742507,774167,525443,611999,3606},{0,0,0,0,0,0,0,0,0,0}};

RippleEffectPuz07 = {{17,17},{5727850576,11335128144,8651428956,2511352415,384843266,441456262,374822582,5907107862,2688544789,269963280,374822588,10105820847,1526366396,721065200,353359509,11125387926,11386421910},{1000007010000010,30000100000300003,20009210001000,205000000060500,40020001003000,6000000000000070,3000000050000,10100000000000402,00200000000000200,50300000000000503,3000000040000,4000000000000030,20030004006000,601000000030200,50004820002000,10000300000100001,4000005040000010}};

Code

Riplines[Rip_List] := {GrayLevel[.8],
Table[Line[{{n,0},{n,Rip[[1,2]]}}],{n,1,Rip[[1,1]]}],
Table[Line[{{0,m},{Rip[[1,1]],m}}],{m,1,Rip[[1,2]]}],GrayLevel[0],
DeleteCases[{With[{A = Reverse[PadLeft[Map[
IntegerDigits[#,4,Rip[[1,1]]]&,Rip[[2]]],Rip[[1]]+2,5,1]]},
Table[{
If[A[[m,n]]≠A[[m,n+1]],Line[{{n,m-1},{n,m}}-1] ],If[A[[m,n]]≠A[[m+1,n]],Line[{{n,m},{n-1,m}}-1] ]},
{m,1,Rip[[1,1]]+1},{n,1,Rip[[1,2]]+1}]],
With[{A=Reverse[Map[IntegerDigits[#,10,Rip[[1,1]]]&,Rip[[3]]]]},
Table[If[A[[m,n]]≠ 0,Text[A[[m,n]],{n,m}-{.5,.5}]],{n,1,Rip[[1,1]]},{m,1,Rip[[1,2]]}]]},Null,4]}

References

Puzzle Communication Nikoli, 73, ISBN 4890724060, Tokyo, Japan: NIKOLI Co., Ltd., May 1998. www.nikoli.co.jp/howtoget-e.htm.

Puzzle Cyclopedia, ISBN 489072060, Tokyo, Japan: NIKOLI Co., Ltd., 2004. www.nikoli.co.jp/howtoget-e.htm.

Puzzle Communication Nikoli, 107, ISBN 4890726071, Tokyo, Japan: NIKOLI Co., Ltd., Summer Issue. www.nikoli.co.jp/howtoget-e.htm.