we gotta know the conversion between cups and gallons
We know
1 cup (US) = 0.0625 gallons
So, 2 gallon would be 2/0.0625 = 32 cups
So, the problem in cups is:
32 cups = $23.36
17 cups = $20.06
Definitely 32 cups for 23.36 is better buy
2 gallons for $23.36 is the better buy
Note:
23.36/32 = $0.73 per cup
20.06/17 = $1.18 per cup