function solution(bridge_length, weight, truck_weights) {
let answer = 1;
let trucks = [...truck_weights];
let ing = [[trucks.shift(), 0]];
while (ing.length > 0) {
for (let i=0; i<ing.length; i++) {
ing[i][1]++;
}
if (ing[0][1] >= bridge_length) ing.shift();
const sum = ing.reduce((a, b) => a + b[0], 0);
if (trucks.length > 0 && sum + trucks[0] <= weight) ing.push([trucks.shift(), 0]);
answer++;
}
return answer;
}