Question: how did vyasa wrote mahabharata?
Answer: The Mahabharata Vyasa set a counter-condition that Ganesha understand the verses first before transcribing them. Thus Vyasa narrated the entire Mahābhārata and all the Upanishads and the 18 Puranas, while Lord Ganesha wrote.