Skip to content

Instantly share code, notes, and snippets.

@mick
Created March 27, 2012 22:46
Show Gist options
  • Select an option

  • Save mick/2221173 to your computer and use it in GitHub Desktop.

Select an option

Save mick/2221173 to your computer and use it in GitHub Desktop.
spark like steps for a given array
var list = [1,45,23,45,65,6,2];
var steps = 6;
var packed_list = [];
var min=0, max=0;
for(l in list){
if(min > list[l])
min = list[l];
if(max < list[l])
max = list[l];
}
for(l in list){
packed_list.push(Math.ceil((list[l]/max)*steps));
}
console.log(packed_list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment