slightly better solution for 19
20 and 21
21 with buffer optimization
22
23