Arduino Sketch - Blink a random number of LEDs
I put this material together from various sources. No guarantees are made.
// =======================================================================
// Blink (turn on and off) a random number of LEDs
// =======================================================================

// ---- array of GIOs and LEDs

#define GIOLEN = 4;
int GIO[GIOLEN]  = { 13,5,6,7 };    // GIO pins to use
int LED[GIOLEN];                    // led status (on/off)

// ---- setup function - runs once when you press reset or power the board

void setup()
{
  // initialize GIOs to "output"
  for(int i=0; i < GIOLEN; i++)
  {
    pinMode(GIO[i], OUTPUT);
  }
  
  // Initialize the serial port - Use one of these rates:
  // 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800,
  // 38400, 57600, or 115200.
  Serial.begin(14400);
}

// ---- turn a LED on

void led_on(int led)
{
  digitalWrite(led, HIGH);     // turn a LED on
}

// ---- turn a LED off

void led_off(int led)
{
  digitalWrite(led, LOW);     // turn a LED on
}

// ---- main loop - run forever

void loop()
{
  // ---- turn on random LEDs
  for(int i = 0; i < GIOLEN; i++)
  {
    int r = random(2);
    if (r)
    {
      led_on(GIO[i]);
      LED[i] = 1;
    }
    else
    {
       LED[i] = 0;
    }
  }

  // ---- pause with LEDs on
  delay(500);

  // ---- turn off LEDs
  for(int i = 0; i < GIOLEN; i++)
  {
    if (LED[i] == 1) { led_off(GIO[i]); }
  }

  // ---- pause between blinking LEDs  
  delay(1000);
}