ASSOCIATE WITH THE WISE
Sace labetha nipakam sahayam saddhim caram sadhu vihari dhiram
Abhibhuyya sabbani parissayani careyya ten' attamano satima.
If you get a prudent companion (who is fit) to live with you, who behaves well and is wise,
you should live with him joyfully and mindfully, overcoming all dangers. 
WANDER ALONE IF THERE IS NO SUITABLE COMPANION
No ce labetha nipakam sahayam saddhim caram sadhu vihari dhiram
Raja' va rattham vijitam pahaya eko care matangarann' eva nago.
If you don't get a prudent companion who (is fit) to live with you, who behaves well and is wise,
then like a king who leaves a conquered kingdom, you should live alone as an elephant does in the elephant forest. 
ASSOCIATE WITH THE WISE
Ekassa caritam seyyo natthi balesahayata1
Eko care na ca papani kayira appossukko matangarann' eva nago.
Better it is to live alone. There is no fellowship with the ignorant.
Let one live alone doing no evil, care-free, like an elephant in the elephant forest. 
A trivial incident led to an unfortunate dispute amongst the bhikkhus in the city of Kosambi. The quarrelsome bhikkhus did not listen even to the advice of the Buddha. So he left them and spent the vassa all alone in the forest, where the elephant Parileyyaka waited on him. Owing to pressure brought on them by the devotees, the bhikkhus realising their mistakes requested Venerable Ananda to invite the Enlightened One to return to the monastery.
At the end of vassa, Ananda went into the forest, accompanied by five hundred bhikkhus. Leaving the bhikkhus at some distance, Ananda approached the Buddha alone. Then he told Ananda to send for the other bhikkhus. All of them came, paid obeisance to the Buddha and said, 'Venerable Sir! You must have had a hard time spending the vassa all alone in this forest.' To this, the Buddha replied, 'Bhikkhus, don't say so. The elephant Parileyyaka looked after me all this time. He was indeed a very good friend, a true friend. If one has such a good friend one should stick to him. But if one cannot find a good friend it is better to stay alone.'
- Sahayata. By this term are meant morality, austere practices, insight, Paths, Fruits and Nibbana. (Commentary) According to the commentary this term connotes higher morality, insight, Paths, and Fruits of Sainthood. No such virtues are found in the foolish.