To solve this problem, we can use the technique of generating functions.
We can represent the number of candies in each goodie bag as a sequence of 0s and 1s, where 0 represents a bag with one fewer candy than the previous bag and 1 represents a bag with the same number of candies as the previous bag. For example, the sequence 0101010 represents the following distribution of candies: 3, 2, 3, 2, 3, 2.
The total number of candies in the goodie bags is equal to the sum of the elements in the sequence, which is equal to the number of 1s. Therefore, we want to count the number of sequences of 0s and 1s such that the sum of the elements is equal to 2019 and each element is at least 1.
We can use generating functions to count the number of such sequences. Let f(x) be the generating function for the number of sequences of 0s and 1s such that the sum of the elements is equal to 2019. Then we have the following:
f(x) = x + x^2 + x^3 + x^4 + ...
This generating function counts the number of sequences of 0s and 1s such that the sum of the elements is at least 1.
To enforce the condition that each element is at least 1, we can multiply f(x) by x:
f(x) = x * (x + x^2 + x^3 + x^4 + ...)
= x / (1 - x)
To find the coefficient of x^2019 in the expansion of f(x), we can use the formula for the coefficient of a power of a geometric series:
[x^2019] f(x) = [x^2019] (x / (1 - x))
= [x^2018] (1 / (1 - x))
= [x^2018] (1 + x + x^2 + x^3 + ...)
= 1
Therefore, there is only 1 way to fill the goodie bags with candy such that the number of candies in any two goodie bags is either the same or differs by only 1, and each bag has at least one piece of candy.