Codelock with three buttons

I am making a codelock with three buttons. I am planning for it to be able to use the same button twice. Since i am using a counting system to verify if the code was put in the right way it counts that button twice. I need the code to be able know if the button is used twice in the code or not.

School project.

Here is my code. The "combination" can be defined by the user by changing the code in int code_1 - int code_6 and code_length is there cause the code does not know the length. x is an input i added to fill the blanks

const int a = 4;
const int b = 3;
const int c = 2;
const int a2 = 4;
const int b2 = 3;
const int c2 = 2;
const int x = 8;
const int green = 6;
const int red = 5;
const int blue = 7;
int Counter = 0;
int val = 0;

int button_1 = 0;
int button_1_pre = 0;
int button_2 = 0;
int button_2_pre = 0;
int button_3 = 0;
int button_3_pre = 0;
int button_4 = 0;
int button_4_pre = 0;
int button_5 = 0;
int button_5_pre = 0;
int button_6 = 0;
int button_6_pre = 0;
int a_state = 0;
int a_state_pre = 0;
int b_state = 0;
int b_state_pre = 0;
int c_state = 0;
int c_state_pre = 0;

int code_1 = a;
int code_2 = c;
int code_3 = b;
int code_4 = x;
int code_5 = x;
int code_6 = x;

int code_length = 3;

void Counting() { if (code_1 or code_2 or code_3 or code_4 or code_5 or code_6 != a and a2) {
Counter = Counter + 1;
Serial.println("two A");
delay(100);
}
else {
Counter = Counter + 2;
Serial.println("not two A");
delay(100);
}

}

void setup() {

pinMode(a, INPUT);
pinMode(b, INPUT);
pinMode(c, INPUT);
pinMode(a2, INPUT);
pinMode(b2, INPUT);
pinMode(c2, INPUT);
pinMode(x, INPUT);
pinMode(green, OUTPUT);
pinMode(red, OUTPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(red, HIGH);
static int Counter = 0;
button_1 = digitalRead(code_1);
button_2 = digitalRead(code_2);
button_3 = digitalRead(code_3);
button_4 = digitalRead(code_4);
button_5 = digitalRead(code_5);
button_6 = digitalRead(code_6);
a_state = digitalRead(a);
b_state = digitalRead(b);
c_state = digitalRead(c);

if (button_1 != button_1_pre) {
if (button_1 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 0) {
val = 1;
}
}
}
button_1_pre = button_1;

if (button_2 != button_2_pre) {
if (button_2 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 1) {
val = 2;
}
}
}
button_2_pre = button_2;

if (button_3 != button_3_pre) {
if (button_3 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 2) {
val = 3;
}
}
}
button_3_pre = button_3;
if (button_4 != button_4_pre) {
if (button_4 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 3) {
val = 4;
}
}
}
button_4_pre = button_4;
if (button_5 != button_5_pre) {
if (button_5 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 4) {
val = 5;
}
}
}
button_5_pre = button_5;
if (button_6 != button_6_pre) {
if (button_6 == HIGH) {
Counting();
Serial.println(Counter);
if (val == 5) {
val = 6;
}
}
}
button_6_pre = button_6;
if (code_1 or code_2 or code_3 or code_4 or code_5 or code_6 != b or b2) {
if (b_state != b_state_pre) {
if (b_state == HIGH) {
Counter = Counter + 1;
Serial.println(Counter);
digitalWrite(blue, HIGH);
delay(100);
digitalWrite(blue, LOW);
}
}
}

b_state_pre = b_state;
if (code_1 or code_2 or code_3 or code_4 or code_5 or code_6 != a or a2) {
if (a_state != a_state_pre) {
if (a_state == HIGH) {
Counter = Counter + 1;
Serial.println(Counter);
digitalWrite(blue, HIGH);
delay(100);
digitalWrite(blue, LOW);
}
}
}
a_state_pre = a_state;

if (code_1 or code_2 or code_3 or code_4 or code_5 or code_6 != c or c2) {
if (c_state != c_state_pre) {
if (c_state == HIGH) {
Counter = Counter + 1;
Serial.println(Counter);
digitalWrite(blue, HIGH);
delay(100);
digitalWrite(blue, LOW);
}
}
}
c_state_pre = c_state;

if (val == code_length and Counter >= code_length * 2) {
digitalWrite(green, HIGH);
digitalWrite(red, LOW);
delay(5000);
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
val = 0;
Counter = 0;
}
else if (val != code_length and Counter >= code_length * 2)
{
digitalWrite(red, HIGH);
delay(200);
digitalWrite(red, LOW);
delay(200);
digitalWrite(red, HIGH);
delay(200);
digitalWrite(red, LOW);
delay(200);
digitalWrite(red, HIGH);
delay(200);
digitalWrite(red, LOW);
delay(200);
digitalWrite(red, HIGH);
delay(200);
digitalWrite(red, LOW);
delay(200);
digitalWrite(red, HIGH);
val = 0;
Counter = 0;
}
}

Avoid forum wrath and encourage responses by enclosing your code in code tags.

code tags.PNG

code tags.PNG