Skip to content

Instantly share code, notes, and snippets.

@moski
Created January 20, 2012 17:40
Show Gist options
  • Select an option

  • Save moski/1648616 to your computer and use it in GitHub Desktop.

Select an option

Save moski/1648616 to your computer and use it in GitHub Desktop.
Array problem Code - All
sectionWidth = 5
length = array.length
if (index < sectionWidth)
startIndex = 0
endIndex = 2 * sectionWidth
else if (index + sectionWidth) > (length + 1)
startIndex = (length - 1) - (2 * sectionWidth)
endIndex = (length - 1)
else
startIndex = index - sectionWidth
endIndex = index + sectionWidth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment