Here's a free format hidden variable example where a variable called "HdSegment1_CODE" is created and takes the Q1 response and adds 3 to it. You can perform all mathematical functions. Pop this in the HTML box ...
<input name="HdSegment1_CODE" type="hidden" value="
Begin Unverified Perl
Create a number of segment variables in free format hidden variables as Keith mentioned. Once you have all variables calculating correctly, you can pop them into another free format hidden question and use conditional script to determine the highest segment value or sort them in an array using Perl.