People respond differently to fasting, some are never able to do focused knowledge work during a fast, others can’t at first but can once their bodies get used to fasting. Others can immediately focus better right from the beginning. There is a lot of individual variation.

I literally cannot sleep if hungry. I wake up in the middle of the night if I had dinner and went to bed at midnight. My trick is to eat one apple right before sleep, then I wake up not hungry and can sleep well.