Last active
November 8, 2017 01:02
-
-
Save 45413/55762024dc139cbaca0ff6269e3c5a46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Genereate Dummy array of numbers (does not matter that they are sequental) | |
$array = 1..20 | |
# Get group size | |
$size = (($array.Count / 5 )) | |
# Create empty array to populate with multidemensional array | |
$rules = @() | |
# For 0 to count of array. | |
for ($currentIndex = 0; $currentIndex -lt $array.Count;) { | |
# set next counter by adding size to current | |
$nextIndex = $currentIndex + $size | |
# check if we are going past the end of the array | |
if ($nextIndex > $array.count) { | |
# set to end of the array | |
$nextIndex = $array.count | |
} | |
# append next array of values to rules | |
$rules += @($array[$currentIndex], $array[($nextIndex)] ) | |
# So we dont repeat the last index add 1 | |
$currentIndex = $nextIndex + 1 | |
} | |
# Print rules | |
$rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment