Explanation
The core of this formula is SUMIF, which is used to lookup the correct values for F and H. Using SUMIF to lookup values is a more advanced technique that works well when the values are numeric, and there are no duplicates in the "lookup table".
The trick in this case is that the criteria for SUMIF is not a single value, but rather an array of values in the range C5:G5:
=SUMPRODUCT(SUMIF(codes,C5:G5,values))
Because we are giving SUMIF more than one criteria, SUMIF will return more than one result. In the example shown, the result of SUMIF is the following array:
{1,0.5,0,0,0}
Note that we correctly get 1 for each "F" and 0.5 for each "H"., and blank values in the week generate zero.
Finally, we use SUMPRODUCT to add up the values in the array returned by SUMIF. Because there is only a single array, SUMPRODUCT simply returns the sum of all values.