Problem Statement
You have built an above-ground pool and you want to know how much water it will hold. The pool structure is built out of stacks of cubes aligned on a grid. layout gives an overhead view showing the height of the cubes in each position of the grid. Here is an example pool:
16661 61116 16661
This pool can hold a total of 15 units of water: 5 units on each of the 3 middle grid locations. After that, any water added to the middle would flow out over the walls (the grid locations of height 6), and any water added to the walls or corners would flow out onto the surrounding ground. When it can, water will always flow to areas of lower height, and no water will "stand" on surfaces such as the pool walls shown here. Water cannot flow through diagonals, so it won't leak out of the middle via the corners. The ground surrounding the pool is at height 0 and can absorb an infinite amount of water. Return the total number of water units that can be held by the pool.
Definition
- Class:
- PoolFiller
- Method:
- getCapacity
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int getCapacity(String[] layout)
- (be sure your method is public)
Constraints
- layout will contain between 1 and 50 elements, inclusive.
- Each element of layout will contain between 1 and 50 characters, inclusive.
- Each element of layout will be the same length.
- Each character in each element of layout will be a digit between '1' and '9', inclusive.
Examples
{ "16661", "61116", "16661" }
Returns: 15
The example from the problem statement.
{ "999999", "955119", "955119", "999999" }
Returns: 48
This pool has high walls, with a shallow end on the left and a deeper end on the right. The shallow end has a capacity of 4*4=16, and the deep end has a capacity of 8*4=32.
{ "111111111", "115111611", "131516161", "115111611", "111111111" }
Returns: 7
In this case, we have two separate mini-pools. The one on the right holds 5 units, and the one on the left holds 2 (any more than 2 would leak out of the left side).
{ "1111111111111", "1555555555551", "1511111111151", "1511199911151", "1511192911151", "1511199911151", "1511111111151", "1555555555551", "1111111111111" }
Returns: 151
Now we have a small, tall pool in the middle of a larger pool. The main pool holds 36*4=144 units. The pool in the middle holds 9-2=7 units.
{ "1987349827", "2983792837", "1785617617", "2876251155", "9287928718" }
Returns: 26
{ "99999999999999999999999999999999999999999999999999", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "99999999999999999999999999999999999999999999999999" }
Returns: 18432
8*48*48=18432
{ "99999999999999999999999999999999999999999999999999", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111411111111111111111111111119", "99999999999999999999999699999999999999999999999999" }
Returns: 11517
There's a 4 and 6 on the bottom. 48*48*5-5+2=11517
{ "99999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "99999999999999999999999999999999999999999999999999" }
Returns: 7672
A long channel.
{ "99999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143211", "99999999999999999999999999999999999999999999999999" }
Returns: 1788
A long channel with drain at bottom right.
{ "99999999999999999999999999999999999999999999999999", "11234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "99999999999999999999999999999999999999999999999999" }
Returns: 1791
Drain at top left.
{ "99999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "91999999999999999999999999999999999999999999999999", "91234123412341234123412341234123412341234123412349", "99999999999999999999999999999999999999999999999919", "94321432143214321432143214321432143214321432143219", "99999999999999999999999995999999999999999999999999" }
Returns: 2972
Drain at bottom-middle, level 5.
{ "99999999999999999999999999999999999999999999999999", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919191919191919191", "91919191919191919191919191919191919192939495969791", "91919191919191919191919191959697989191919191919191", "91919191919191919191919194919191919191949596919191", "91919191919191919191929391919191919191919191919191", "91929394959697989191919191919191919191919194939291" }
Returns: 2176
{"25431352852463256168787377833827329497862273586255","53362163678613121442262479342772264385666678168234","34555185789887397233386786423923421867888621214344","67663414355453741475326897883635864723337393833565","48738155686126338887471723937886972543898185818449","36483653553795897639358192611357912265391753255357","33872748397758594637933358523319467387884132836538","41978837226193533479913569179568977448434782865338","92546728393342366861262754534332228241842786376919","35217686599327461246888887428545735947566826234445","77522366664623949628623286424372268414828438594953","24793516298273672523459668258822573834575335181337","86568771468465575784356584384567643642615923883792","88296325944631712667531536838321772562569412526564","43544816516732392486458132357672568788126559729788","62293318885288936295833984216853743791274647766518","13392664658678679655611364145525618438258349684885","56298467424736863658552278172231758836964233475734","88878864869361826923878285756332343744758727334636","79994446638935452233733589662761334158519666674543","74386226266885777795389228289738468228323457635848","54568486583584464262323566176373652487373789544349","81497754823325119588781615245356897488729755265814","42776544175342525837274765835231346474194454767888","33359568928759877373743422294588287464828228642254","63587654435386563335477294655855733935481684856353","73433625378584157775857843118525998277216365369816","43583311578278972259635476833597437927625388245945","93498442315454898594263937736979642466877654491942","51527553442939893563388777769866596525847793211963","76628595388221513473174511675286912224861683282458","64238637768268272232118537221134857623567349583158","57287693549931723752677152272278388354336563535612","86679666347466247118431357821758855654235992673164","35471538426896198741456565763523254419737556922185","11852888274776526644422574827641582863359824374839","66153458156836723496174483445741243515968247563488","72876892678223356849399564849131567878977754834799","33565616382717126417214527559886661183367789478846","53963264364688337772152233787777488585274928881513","39824362674892792286399355369583876535924442698336","26252899819751297881574337868375256424843385234612","92462586548476646214733368858523538286774513882298","14863123723365569925635355585861386227492877266486","41227954952757856544131277478875878598267695542616","78346582294473276323673754539843948525358374244584","24937944557712687276564797843852755688353558513375","55152412382784213574888556186887552792774438831244","22841886234513232252264321264227288278642133244476","44945329372462365296255172824327383288758529228854"}
Returns: 2522
Straight random..
{"55482558529258861359778617619252177473456667327413","59548678469863774795843766266622322754434576275736","22654895482242897828828172664964774883886782555125","63382733681756237761622265553844644724768754287558","46313785353924759222622273768224431844496888626522","47358954462844339427816712458472872584832267871831","76861413634475765275614724466423691882971253833818","22712175418267341793138913296286752655216173988764","32335563578852366977567613432746781246148825443434","83325772844397284691759767983973468446847879155342","65598562553327138122232317336633678555225265322748","43511844365826676471324435278718839875457116358245","44485355585536294345324328767788475733435797398553","35587562747355757524327651567754385556565535354834","43884848654126647847659464681342688637567452466557","19824546277712171535324872934639233816787137593884","25768872128443255889318775135924282772224453449175","33483984643746825244628448512671314257754182383322","26834356323457877642137687645794445415332524785972","42885765822745662652514736663315461728518337473951","86664853752184785166832578396436837674324658664721","25284264152494539464432445718571888742659831447856","64579882638844953555673739274457222786357311935882","64638579833314472287725792498494466318183355419711","55352548489727434212548585523854133233962214643582","89645346746233346528343337887485886564723242879864","32188385414756942728132126172341978575825697565256","59236625457722755193535513885512568464856766128256","38831446573131773267755772269654662742553374497515","65224586613542975384232948284738684229147227512624","19978113643786261553256222622424376157185494619348","83254863546472857294558727535382227626827888914892","22645958567298781112539652252718755352774414125682","47878665335856863647452846442222223219935692145728","68396595562773672326563482424337518473938634689289","87384877275486539646557218633891938527789574811128","68896936777472925474615485765429229197547544625592","34534322473152882325537763284429848244262277838452","48835145591892773596899343151732353494873448382383","91363554682451353813457785251222962986683325426465","68834837336167666231265895217195646656267535626845","43443556733397837267334582686442577785616437444742","39251564873366837737426843632974526677789726924271","82533417567493992536582484373924689543586543341362","64839645518336817332257787642856731473125226555567","96534523456542452789633445581454821248215589346559","76795965542653821627644741463525882343118864384487","52549155782729654275871386844213238666617245883537","41325284211288595332363462364538313753969258855445","23687718684317382266153118466537533782482356443717"}
Returns: 2253
More random...
{"96329434962495569463954593539356964395639232966595","42395349662946393439445946592429454965392539356946","53965395549564934693449424945595239633936394359325","39536954694359523954394639665943594669635924395249","94269644954394459435954494339335963593439464945695","54594669434953593349255933595329554956392539345933","44955295259352965395639543933595649353955493429535","49544933694669323945293659456955393639443953494559","95569535953492539253965593329352933594349424944692","44393469342954393229244963493359354934595559645942","54943592549462942293349635925695639543943394549553","49465946393259344955293459353925595459353954596349","95669235924295359225925394559543924493539565965394","44494569453955495339245942493329634923593239563923","56955492439534954593639555935696459364955693439333","59333936393549654945492259244946496549345954392339","95559264953595549245925395539642934395259354935392","33696649553935394249553944493449355945693539254935","34925594339435922694549525944395329354955593439324","39664923395359344935593329566953592639266933295669","94459445955595459465924594239336926492639254935394","54696239356925592559635925493349265933493339454944","53954394439455945694469343935294659542923596659554","39464923292259564934392639355933696539635942392529","92439644923495659334942595369562943493349266944492","54493359664936395359265944593559234956694659542943","53943393549546932295359346963392449543964492649246","49556946593639655953392559254946493329335935494449","95629255954393239262953596329633955395349652933394","53494439244923495549644935494459342956595449544946","26933396439624954494349533964693649553944593439332","39445943392329545934693629344955492359432955395539","93449332946393429545945492439233965493459523933393","34593329343954495349425924696529533945293459523923","26956694459554964394639643955394449243954493349236","39336953395669565922294459325953495229346934495569","95549353935394669436935396559345944292649344935395","63393469522966594469533936594549434955694659434924","46924396439655946392639555945494259432963596639553","39443922693629333945396549246962593649523966593569","95549526953493259353952394339335944393349344945494","52495459434933593329443923592549336935492449423956","53954392239536955296629224926395459652943496569534","29625953595459433942396539525946394469645945393439","92439655944596449444942496349335954392569653945396","36694539533956396539343955493429544953595549335934","42955396639525942493339534952393629353945293359545","49252945494339455935292359356943493359456955495449","92439555935492349554943596639625945294239334935593","34394439433954593649532954494229663953494239434965"}
Returns: 2689
Diagonal lines through data.
{"95249533933492239552933294229555925594449334924495","38594839385968393869286958596859383958495859586958","63922596629463923694329343936294459432945296549643","29683948395849384938493859584938592869583958695849","93549452935392459322944595629524945494459444943493","58395839483938392859386948396869284948595829583958","34946293359435935295639642945496449434952695539532","69383968593859285968495859583958495859583948494849","92439442956593329334953393649345936393359253936494","48394849282958695839383938695839583948493829286958","45944594659625954393549525943396649236955295349433","29685968593839385938693829584938692859485948493829","94239325924493559265944694449255955494529465934394","58395829385928296849284948596849384948295849485938","23944394229223924694559343953493569353945593439524","59683968293839584938296849584968595869683928594869","96549526935396359445944496369533933395429543953494","68493829585928693839383958596849384948394849683958","44945394659343953595539233945693549355963293369653","49385948395849485948492849385968594849385948593849","94349326923594449235924594239434963394429434942593","68293859485958693839586958493849384968495839584948","43944493249543932396369535934592329645933294459443","59385928395869583948393859585948694839683928593849","93539555936395649435942592329355936594349563944595","48496869382968694859283928394839284958492839485968","64934394339624935592539342935392529535964494449343","29586958392849483958594869384948494869285948396829","92539553933396449463953593249453953493649352933494","48692829485948395859586928295829284928594839384958","24945595249263935396639632925693559433946292549533","39384968595829583958392839285928596829684958594859","94369343964493439464953695269436945595669445943596","68395839286948596849682928395869586948494849482948","52934694359332964494339655955592359434955494669434","39484938495839686948596869484938594859483968295839","95369534963296559454956596559665963495439443954595","28695839386958693859483958494859383928494839385958","42962496539443933593549442925294439443944494259544","39682958395839486968694829284958394859683968594859","95639342932695339553935395559453965495459552963593","28393839385928493869585958394849484938493859585938","56944495669552933493559524933594249335926595349645","69484938696849584948396869583968595849585958496859","93569245924395569233933293549534932292539546965596","68296869382948695849385958495869383958494869485958","64953395549343943596559655952395539252936392439454","29685948692839386948594859585938492869685938494839","94369623926594249365935495329442933493459256935595","38595859385948693829686948293849286968592849683938"}
Returns: 5334
Diagonal lines both ways.
{"94592593694294594392694394694394493695693393393395","44932932945964925925943954922943943935933955944964","29449669429539539359249239249239529559339239329429","93695493392695494694593693392293592394493396693396","44934955964946965922963942953926926925942963944954","59359349349249549539259339349649459639629559549529","95392593495693395594595496395396393595494593293295","42944935954935932963942935946925945956953935946954","29569439429359539369559449469469339539629459529659","95496695496393393693594292492395593394595395496694","52954952934945932953935942943933955962922946934935","29539339359359359459249229259669249529669559539339","93593492494492595596294394592294296395294295294495","53956955946923952922962923956934944923944964943932","69459539259539369269569539659459529659549349339259","95492295395394493395493694296594394593596294395493","45943935953946955934933925944953935924933936955943","59539359439639559459539369559649229269539549359259","95395596593493493593393694496292494292596594494294","42924943963952954926946955934935945942942924963924","39429429249469559339439249649339529439629329239459","93394592293593492494493293395395392495494494295694","56934935955955953932944963926942934944925955925962","29659349639639549539349569449649539449239659559549","93295594496595396493394495294494696395392295596695","54953935936943963933925962933943942934956956952926","39339449369259359439339349659459359539439559369659","96595393392495595692494593594595293596592594595293","23966955945953935944923963935965943933952936936934","29259439639359449439439339469549339349469359539449","93392293393595594394696493595494392696595294595494","36932925954935965935934923932925924934942936953934","49449529229449369429359639449459529559259269529429","93392396595393593295692594596296593593393393293393","25943936944933924953923964953933935924953943946946","39449439529329649359249649559349649229539349469529","95296395293596493392394492493695395292495393496493","55932955936942955946953953926934954953944945933924","49559349359259349459639629459439459339449359359649","95496393495592393596492495495693593394593494393593","36942966932953955946966943936935966932942953935933","29639539659339549249569259669449539449439369439569","93492595494492593595593594395495594595592694595694","53946932932934925945946932935964964956943943924945","49429549229259559549429329339329539449239629549359","92696693495494492494594494495296493693593295393594","43955955934926932955965926943945936946964944925932","49359269539359539669359359549439469349359669329349","95294492493295693493393493593593296494395592495494","44953964952945943934954933944943934956925926942935"}
Returns: 2627
Now just the other way.
{"18888888888188888888881888888888818888888888188888","86448552851483358645814584548465145483638431832586","82648333815683558434134484458341864583548413855383","86328444144382448551846585568515836384348152865285","88888881888888888818888888888188888888881888888888","83358413844682238133844482231252843483518344855584","85228145833682431355843583318653842584168464823381","85441544855583318462856684148454843381458442854313","88818888888888188888888881888888888818888888888188","86158545853681458425836514468455833184328256851384","81248553836316558253854183358645831483338465814382","15328635834185648633831385338236815483558664134682","88888888881888888888818888888888188888888881888888","83238355815285428243153285338441854683338413844282","85348333134384558521832284548516844485338135853586","86448441855486258413832584348133853483321223823584","88888818888888888188888888881888888888818888888888","85228134856283341636855483418542854683148335833381","82341545844584418354855385158244852581358332843516","86518654845582168564855581348665854312638532834182","88188888888881888888888818888888888188888888881888","81348442833313568454854185458546861586458365814385","14328245844183468654851484238465812684458343153382","85538432851584548365815683568446132383358341852385","88888888818888888888188888888881888888888818888888","86448335133486268641865583458613822482638132852585","83238431853685358416865584548135833683461332863483","84668512852284338133855385231656854584418642864383","88888188888888881888888888818888888888188888888881","85431553844583218354864583138444832481348455853216","86418365854384148666866581528326855513638543835183","86148434833581458543855414328555835182338526861383","81888888888818888888888188888888881888888888818888","14648365825183628323841686338636813385648526135386","83448633841384468463815486458524145484528441843285","85368235813482338564154483358431833584558315856485","88888888188888888881888888888818888888888188888888","85238531844383638212854585548143865484631366825484","85368512823485558144842385231564855484318664842382","86558163865583541524855384318455862385138553832281","88881888888888818888888888188888888881888888888818","82318255834483128423854481448353846515528646856184","85158542825481448353825414458666835185338463821682","81428452823516458525853185548454841483658463815283","18888888888188888888881888888888818888888888188888","83568364831583548322815483248335144385268341844483","85428344815486548545124482558341865285358514852583","82558456146485258531863382528516864483348133846486","88888881888888888818888888888188888888881888888888","84258215855685628152832482531365846686218465835483"}
Returns: 4019
Chambers, with a few cuts diagonal.
{ "99999999999999999999999999999999999999999999999999", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "99999999999999999999999999999999999999999999999999"}
Returns: 18432
{"9999", "9119", "9199" }
Returns: 0
{"1151511111111", "1555555555551", "1511111115151", "1511199911151", "1518192911151", "1511199911151", "1511112111151", "1515555555551", "1111111111111" }
Returns: 7
{"212", "321", "973", "395", "955", "592", "492", "111", "232", "323", "321", "293", "492", "318", "341", "234", "531", "453", "345", "353", "534", "533", "554", "341", "234", "234", "253", "234", "919", "421", "212", "345", "214", "414", "432", "432", "341", "431", "545", "465", "432", "341", "345", "542", "492", "419", "435", "453", "345", "245" }
Returns: 10
{"121116", "511114", "712341", "311134", "214233", "613313", "111119" }
Returns: 0
{"777777", "722226", "729227", "722127", "777777" }
Returns: 45
{"1111111111111", "1555555555551", "1511111111151", "1511199911151", "1511192911151", "1511199911151", "1511111111151", "1555555553551", "1111111111111" }
Returns: 79
{"1111111111111", "1555555555551", "1511111111151", "1511199911151", "1511192911151", "1511199911151", "1511111111151", "1555555552551", "1111111111111" }
Returns: 43
{"1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551", "1511111111151151111111115115111111111111111151", "1511199911151151119991115115111999111199911151", "1511192911151151119291115115111929111192911151", "1511199911151151119991115115111999111199911151", "1511111111151151111111115115111111111111111151", "1555555555551155555555555115555555515555555551", "1111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111", "1555555555551155555555555555555555515555555551", "1511111111151151111111115115111111111111111151", "1511199911151151119991115115111999111199911151", "1511192911151151119291115115111929111192911151", "1511199911151151119991115115111999111199911151", "1511111111151151111111115115111111111111111151", "1555555555551155555555555555555555515555555551", "1111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551", "1511111111151151111111115115111111111111111151", "1511199911151151119991115115111999111199911151", "1511192911151151119291115115111929111192911151", "1511199911151151119991115115111999111199911151", "1511111111151151111111115115111111111111111151", "1555555555551155555555555115555555515555555551", "1111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551", "1511111111151151111111115115111111111111111151", "1511199911151151119991115115111999111199911151", "1511192911151151119291115115111929111192911151", "1511199911151151119991115115111999111199911151", "1511111111151151111111115115111111111111111151", "1555555555551155555555555115555555515555555551", "1111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551", "1511111111151151111111115115111111111111111151", "1511199911151151119991115115111999111199911151", "1511192911151151119291115115111929111192911151", "1511199911151151119991115115111999111199911151", "1511111111151151111111115115111111111111111151", "1555555555551155555555555115555555515555555551", "1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551", "1111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111", "1555555555551155555555555115555555515555555551" }
Returns: 1620
{"999999999999999999999999999999999999999999999999", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "911111111111111111111111111111111111111111111119", "999999999999999999999999999999999999999999999999" }
Returns: 16928
{"99999999999999999999999999999999999999999999999", "91122394449999999999999899999999999999999333339", "99999399999999999999999799999999999999999999999", "99999999999999999999999499999999999999999999999", "93656543645734645634564564536345634564356456469", "99999999999999999999999499999999999999999999999", "99999999999999999999999499999999999999999999999", "99999999999999999999999299999999999999999999999", "99999999999999999999999399999999999999999999999", "99999999999999999999999399999999999999999999999", "99999999999999999999999899999999999999999999999", "99999999999999999999999899999999999999999999999", "99999999999999999999999399999999999999999999999", "99999999999999999999999299999999999999999999999", "99999999999999999999999499999999999999999999999" }
Returns: 267
{"1111111111111", "1555555555551", "1511111111151", "1511199911151", "1511192911151", "1511199911151", "1511111111151", "1555555555551", "1111111111111" }
Returns: 151
{"999999999999", "911111211114", "911111211119", "911111211119", "911111211119", "911111211119", "911111211119", "999399999599" }
Returns: 114
{"1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1987652371126534213551234127681235112394521123523", "1111111112312343658246529845982734958723945823494", "2139312113423723287346187348193498121384719328411", "1237329823743822837413941827364981726398741629837", "8128981276398176238122374687137455123412975616364" }
Returns: 43
{"99999999999999999999999999999999999999999999999999", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111119", "91111111111111111111111111111111111111111111111111", "99999999999999999999999999999999999999999999999999" }
Returns: 0
{"19999991", "92792989", "97181351", "99345951", "26886593", "93997119", "92693219", "19919991" }
Returns: 51
{"1111111111111111111111112222222222222222221111111", "1111111333332222111111112111111111111111121111111", "1111111311121112111222223222111111111111121111111", "1111111311121112111222224334322222111111121111111", "1111111311121112111111112112222223222222221111111", "1222223533343333222221112112211112111111221111111", "1211112322232333222232223223322223111111221111111", "1212223421121322111132223223321113111111221111111", "1323223543343532222242234323332224222211221111111", "1312112332232421222242233323332224222322321111111", "1312112342233532222242232223321113111211211111111", "1312123452233532233352243445764446333433433222221", "1312122352222421121141131112421114111211212111121", "1312122241112421121141131112421114111211212111121", "2434344463334632232252242223532214111211212111121", "2212122241112411122241131112421214111211212111121", "2223233364445522232352242223532325211211212111121", "3223233241112211132341131223521214211211212111121", "3112345363345554465663242323743435322322323222231", "3111223152233232244665464545832323211211212111131", "3222334252233232233543131212511212211211212111131", "3212334364444343344644241223511212211211212111131", "3212333242222121244645351112633433211211212111131", "3222333242232121232423252234733433322322323221131", "3221222131133232343534364345743444433433322121131", "3221222131133121243534353234643444433433332221131", "3221222132244343354656576565753333322211121111131", "3232333244354332243433232132431122211111121111131", "3231233233243332243443232132442233322222232222231", "3231124233243332243432232132331122211111121111121", "3242224233244443354443343243453344322222232222221", "3131113122122221132121232132231122111111121111111", "3353334233233332242121232132231122111111121111111", "1131112122122221131121232132231122111111121111111", "1132223233222221131121232243353332111111121111111", "1121112122112221131121231132131111111111121111111", "1121112122112332243343342243231111111111121111111", "1122223233222332232221131132121111111111121111111", "1111112123333432233333342243221111111111121111111", "1111112111111211111111121132111111111111121111111", "1111112111111222222222232232111111111111121111111", "1111112111111111111111121122111111111111121111111", "1111111111111111111111121122111111111111121111111", "1111111111111111111111122222222222222222221111111", "1111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111" }
Returns: 764
{"999999", "955119", "955119", "999999" }
Returns: 48
{"1111111111", "1555555511", "1111111111", "1333113331", "1313113131", "1313333131", "1311111131", "1921111291", "1333333331", "8888888888" }
Returns: 30
{"11111", "11111", "11111" }
Returns: 0
{"11111111199898425", "11511161124432166", "13151616143611266", "11511161113461346", "11111111134612466" }
Returns: 11
{"9919399", "9192249", "9122933", "9199999", "2929999" }
Returns: 10
{"2552236", "4353155", "4324512" }
Returns: 1
{"1111111111111111123221397293719273971172937912739", "1555553141341343432134134199999934134155555511111", "1555553141341343432134134141994134199155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111", "1555553141341343432134134141334134134155555511111" }
Returns: 0
{"1111111111", "1111999991", "5555922295", "5111999991", "5111111155", "5555555555" }
Returns: 61