I can point you to a post from 2018 that Zachary kindly assisted with ...
https://legacy.sawtoothsoftware.com/forum/18529/assign-respondents-group-based-response-numeric-question?show=18529#q18529
This is similar to what you are seeking.
The Perl Script contains hashes - which are paired variables (e.g. zip code and distance from a certain location). From this script, you would just need something like this to insert in to your question script ...
The distance is: [%Begin Unverified Perl
my $zipCodeQuestion = 'ZipCodeQ';
my %zipCodes = (
12345 => 1,
23456 => 1,
34567 => 2,
45678 => 2,
56789 => 3
);
return $zipCodes{GETVALUE($zipCodeQuestion)};
End Unverified%]
Note I have removed the "exists" function as this is just checking to see if the zip code exists within the array (it returns a 1 if true and a 0 if false). As Zachary has mentioned, replace 'ZipCodeQ' with your zip code question, and also insert (using a suitable text editor), all the zip codes with their corresponding distances in the format of zip code => distance.
One matter I cannot determine is the speed of this on your server. The hash array approach is meant to be quick, but I can't say for sure how well performed this will be for your situation on your server. Zachary does mention this as a warning to test the speed / performance.
May I suggest you test this approach out with maybe 50-100 zip codes, to ensure it is working. Once you are confident it works, add your full list of zip codes in to the script and test the speed / performance.
If you feel the speed / performance is lacking, I can only suggest you reach out to Sawtooth Software directly at Support@SawtoothSoftware.com for an alternative.