I am trying to solve a magic square problem with some modification. I have an array of 25 non-consecutive integers, and I have to arrange them in 5x5 2D array so that this array forms a magic square. I have tried brute force algorithm but it is consuming too much time. I tried searching on the net for modifications of magic square problem but I found nothing for random non-consecutive numbers. Please let me know if there is any better way to solve this problem.
Thanks,