Let the number of sodas be s and the number of hotdogs be h
Since there are 172 sodas and hot dogs, then
Add s and h, then equate the sum by 172

Since the number of sodas is three times the number of hot dogs
That means s is equal to 3h

Now, substitute s in equation (1) by equation (2)

Divide both sides by 4

Substitute h in equation 2 by 43

The answer is
The number of sodas sold: 129
The number of hot dogs sold: 43