Is it written anywhere in Halacha that one is not allowed to swim alone? I recall once seeing it in the Rambam but can't seem to find it. Thank you
I do not recall seeing anything about swimming alone; besides for the standard Mitzva to protect your health/life.
However it is mentioned that one should not sleep alone in a room and that one should not walk alone (on deserted road) at night. (Kitzur Shulchan Aruch 33:7 and 71:2)