The 3-1 weighting
UPC-A is a 12-digit number: an 11-digit body and a check digit. Weights alternate 3 and 1 from the left, the reverse of the EAN-13 pattern, because the payload has an odd length.
Both are the same rule underneath. Weights always alternate 3 and 1 counting leftwards from the check digit, and only the parity of the payload decides which weight lands first.
UPC-E
A UPC-E is a compressed 8-digit form of a UPC-A. Its check digit belongs to the expanded 12-digit number, not the compressed one, so an 8-digit UPC-E will not validate here. Expand it first, then check.