A function to write several digital outputs at once (C++ level)

Feel free to use this code using the random function:

// 8 LEDs are connected to a non-ordered set of pins 
int pins[8] = {2,7,8,9,3,4,5,6};

void setup() {
  // put your setup code here, to run once:
  for(int i=0; i<8;i++){
    pinMode(pins[i], OUTPUT);
  }
}

// LEDS contains an 8-sequence pattern similar to https://www.youtube.com/watch?v=8lS-VvMhDus or to another side turn sequential leds

void loop() {
  // put your main code here, to run repeatedly:
  int LEDS[8] = {1,2,4,8,16,32,64, 128};

  for(int i=0; i<8;i++){
       emitPinsRandom(LEDS[i], pins, 0, 7);
       delay(1000);
  }
}

// Emitting for non-ordered pins
void emitPinsRandom(int val2emit, int pins[], int pinIni, int pinFinal)
{
  int nPins = pinFinal - pinIni + 1;
  int pin2emit = pinIni;

  for(int i=0; i <nPins; i++){
    if(bitRead(val2emit, i) == 1)
      digitalWrite(pins[pin2emit], HIGH);
    else
      digitalWrite(pins[pin2emit], LOW);
    pin2emit ++;
  }

}