total = donated + gave away + left
gave away → 1 - 3/8 - 4/7 = 1 - 21/56 - 32/56 = 1 - 53/56 = 3/56
3/56 books → 24 56/56 (total) books → 24 ÷ 3 x 56 = 448
books packed 20 boxes (or left) → 448 x 4/7 = 256
"Some boxes contained 10 books while the rest contained 18 books. "
assumption concept
step 1: assume all boxes are 10 books
assumed total books → 20 x 10 = 200
step 2: difference
difference in total → actual total - assumed total = 256 - 200 = 56
difference in 2 values → 18 books - 10 books = 8 books
step 3: divide
number of boxes contained 18 books → difference in total ÷ difference in 2 values = 56 ÷ 8 = 7