i have a function in solidity ,i want return length of new random array generated

95 Views Asked by At

please can any one help me to get a new length of arandom array generated from this function What happens now is that the array length is returned to zero

 function randomArray(uint[] memory  population ) public view   returns(uint[] memory){
        uint  a = population.length; 
       uint   b = population.length; 
        for(uint i = 0; i< b ; i++){
            uint randNumber =(uint(keccak256      
            (abi.encodePacked(block.timestamp,population[i]))) % a)+1;
            uint interim = population[randNumber - 1];
            population[randNumber-1]= population[a-1];
            population[a-1] = interim;
            a = a-1;
        }
        
        result = population; 
             
        return result;  
        len = result.length;      
    

}

0

There are 0 best solutions below