You can
put this solution on YOUR website! .
Let think that the grid is 3 points vertically and 5 points horizontally.
Then there are THESE families of straight line segments satisfying imposed conditions
3 x 3 = 9 horizontal segments of the length 2
3 horizontal segments of the length 4
5 vertical segments of the length 2
1 sloped segment of the slope 2/4 = 1/2
3 sloped segments of the slope 1
3 sloped segments of the slope -1
1 sloped segment of the slope -2/4 = -1/2
Counting this way, there are 9 + 3 + 5 + 1 + 3 + 3 + 1 = 25 segments satisfying the posed condition.
Solved.