Programmatically calculate winning rows