5 kyu

Connected blocks (second part)

Description:

This is the second part of Connected bloks kata.

We want to generalize the solution in such a way that the grid can have m dimensions and each dimension with n values (from 0 to n-1)

Examples:

solution({dimensions: [10, 10], cells: '18,00,95,40,36,26,57,48,54,65,76,87,97,47,00'}) === 3 // two dimensions (x from 0 to 9, and y from 0 to 9)
 
solution({dimensions: [20, 10], cells: '018,000,095,040,036,026,057,048,054,065,076,087,097,047,000'}) === 3 // two dimensions (x from 0 to 19, and y from 0 to 9)
 
solution({dimensions: [10, 10, 100], cells: '1800,0000,9500,4000,3600,2600,5700,4800,5400,6500,7600,8700,9700,4700,0000'}) === 3 // three dimensions (x from 0 to 9, y from 0 to 9 and z from 0 to 99)

Notice that the format of a cell is calculated taking into account the number of digits needed for each dimension.

For example, with [20, 10, 1000] dimension values, the 113012 cell value means:

  • x coord: 11
  • y coord: 3
  • z coord: 012

In addition, two cells are connected if they have the same value in all the existing dimensions except in one and in this one they are different in a unit.

For example, with [20, 10, 1000] dimension values:

  • 113012 and 113013 cells are connected.
  • 113012 and 113014 are not connected.
  • 113012 and 123013 are not connected.
Algorithms

Stats:

CreatedDec 13, 2017
PublishedDec 13, 2017
Warriors Trained627
Total Skips278
Total Code Submissions155
Total Times Completed28
JavaScript Completions28
Total Stars13
% of votes with a positive feedback rating100% of 13
Total "Very Satisfied" Votes13
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments4
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • surtich Avatar
  • Voile Avatar
Ad