Can you store the result of solve in a string?
For median(), if you just have one list, say [1,2,3,4,5], it will give you the median, 3 in this case. If you have a frequency list to go with the main list, say [4,2,1,1,3], it will expand the list to [1,1,1,1,2,2,3,4,5,5,5], and compute the median of that; it is like having a histogram, with the main list being the numbers along the bottom, and the freqlist being the values on the bars.