toy algorithm implementations