function peak_finder(array){
    let counter = 0
    let peak = 0
    let peak_index =0
    while (counter <= array.length){
      console.log(counter)
    if (counter === 0){
      if (a[0]>=a[1]){
        peak = a[0]
        peak_index = counter
        counter = array.length
        return `The ${counter-1} indexed number, ${peak} is a peak`
      }else{
        counter+=1
      }
    }else if(counter === array.length-1){
       if (a[array.length-1] >= a[array.length-2]){
       peak = a[array.length-1]
       peak_index = counter
       counter = array.length
       return `The ${counter-1} indexed number, ${peak} is a peak`
       }
     }else{
        if (a[counter]> a[counter+1] && a[counter]> a[counter-1]){
        peak = a[counter]
        peak_index = counter
        counter = array.length
        return `The ${counter-1} indexed number, ${peak} is a peak`
      }else{
        counter += 1
      }
    }
  }
  }
function peak_finder(array){
    // Check if the first element is a peak
    if (array[0] >= array[1]){
      return `The 0 indexed number, ${array[0]} is a peak`;
    }
  
    // Check if the last element is a peak
    if (array[array.length - 1] >= array[array.length - 2]){
      return `The ${array.length - 1} indexed number, ${array[array.length - 1]} is a peak`;
    }
  
    // Check the remaining elements for peaks
    for (let i = 1; i < array.length - 1; i++){
      if (array[i] >= array[i - 1] && array[i] >= array[i + 1]){
        return `The ${i} indexed number, ${array[i]} is a peak`;
      }
    }
  
    // If no peak is found, return null
    return null;
  }
  
def permute(data):
  if len(data) == 0:
    yield []
  else:
    for i in range(len(data)):
      for permutation in permute(data[:i] + data[i+1:]):
        yield [data[i]] + permutation

data = [1, 2, 3]
for permutation in permute(data):
    print(permutation)
[1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]