generate an array from an array with conditions
Posted
by
Aman
on Stack Overflow
See other posts from Stack Overflow
or by Aman
Published on 2012-06-09T10:17:49Z
Indexed on
2012/06/09
10:40 UTC
Read the original article
Hit count: 216
Suppose i have an array $x = (31,12,13,25,18,10); I want to reduce this array in such a way that the value of each array element is 32. so after work my array will become $newx = (32,32,32,13); I have to generate this array in such a way the sum of array values is never greater than 32. so to create first value, i will reduce 1 from second index value i.e. 12, so the second value will become 11 and first index value will become 31+1 =32. This process should continue so that each array value becomes equal to 32.
© Stack Overflow or respective owner