various algorithm implementations in scala or java