|
-
Aug 25th, 2004, 08:54 PM
#1
Thread Starter
Frenzied Member
Need help in creating a simple algorithm, 'counting' duplicates *resolved*
heres my problem..
i have an array, with data in it being something like this
zipcode, city
zipcode, city
zipcode, city
ive got all zipcodes for cities in the US, along with their corresponding city.
however, i just need the zipcodes for the biggest, most populated cities.. i figure that to generate such a list, ill only store those zipcodes where there are more than 5 zipcodes for a particular city.
ill be working state by state, so the chance of choosing a zipcode for a small city and assigning it a 'big city' wont happen if the same city name appear in several states.
confused? heres an example
heres a list for NY (a much shortened list)
| 12404 ACCORD |
| 12405 ACRA |
| 13605 ADAMS |
| 14410 ADAMS BASIN |
| 13606 ADAMS CENTER |
| 14801 ADDISON |
| 12808 ADIRONDACK |
| 13730 AFTON |
| 14001 AKRON |
| 14003 ALABAMA |
| 12201 ALBANY |
| 12202 ALBANY |
| 12203 ALBANY |
| 12204 ALBANY |
| 12205 ALBANY |
| 12206 ALBANY |
| 12207 ALBANY |
| 12208 ALBANY |
| 12209 ALBANY |
| 12210 ALBANY |
| 12211 ALBANY |
| 12212 ALBANY |
| 12214 ALBANY |
| 12220 ALBANY |
| 12222 ALBANY |
| 12223 ALBANY |
| 12224 ALBANY |
| 12225 ALBANY |
| 12226 ALBANY |
| 12227 ALBANY |
| 12228 ALBANY |
| 12229 ALBANY |
| 12230 ALBANY |
| 12231 ALBANY |
| 12232 ALBANY |
| 12233 ALBANY |
| 12234 ALBANY |
| 12235 ALBANY |
| 12236 ALBANY |
| 12237 ALBANY |
| 12238 ALBANY |
| 12239 ALBANY |
| 12240 ALBANY |
| 12241 ALBANY |
| 12242 ALBANY |
| 12243 ALBANY |
| 12244 ALBANY |
| 12245 ALBANY |
| 12246 ALBANY |
| 12247 ALBANY |
| 12248 ALBANY |
| 12249 ALBANY |
| 12250 ALBANY |
| 12252 ALBANY |
| 12255 ALBANY |
| 12256 ALBANY |
| 12257 ALBANY |
| 12260 ALBANY |
| 12261 ALBANY |
| 12262 ALBANY |
| 12288 ALBANY |
| 11507 ALBERTSON |
| 14411 ALBION |
| 12007 ALCOVE |
| 14004 ALDEN |
| 13301 ALDER CREEK |
| 14005 ALEXANDER |
| 13607 ALEXANDRIA BAY |
| 14802 ALFRED |
| 14803 ALFRED STATION |
| 14706 ALLEGANY |
| 14707 ALLENTOWN |
| 14708 ALMA |
| 14804 ALMOND |
| 14805 ALPINE |
| 12008 ALPLAUS |
| 12009 ALTAMONT |
| 13302 ALTMAR |
| 14413 ALTON |
| 12910 ALTONA |
| 11930 AMAGANSETT |
| 10501 AMAWALK |
| 12501 AMENIA |
| 11701 AMITYVILLE |
| 11708 AMITYVILLE |
| 12010 AMSTERDAM |
| 12502 ANCRAM |
| 12503 ANCRAMDALE |
| 13731 ANDES |
| 14806 ANDOVER |
| 14709 ANGELICA |
| 14006 ANGOLA |
| 12504 ANNANDALE ON HUDSON |
| 13608 ANTWERP |
| 13732 APALACHIN |
| 14008 APPLETON |
| 13020 APULIA STATION |
| 11931 AQUEBOGUE |
| 14009 ARCADE |
| 10910 ARDEN |
| 10502 ARDSLEY |
| 10503 ARDSLEY ON HUDSON |
| 12809 ARGYLE |
| 14807 ARKPORT |
ill have an array with all these entries in the form zip, city.
now i just want to keep those zip codes that belong to major cities, if a city has more than 5 zipcodes, its a major city. in this list, albany has > 5, no other city does, so i just want to keep the zipcodes for that city.
how can i do it?
how can i make a new array and in that, have a new list (zipcode, city) for only 'big' cities?
Last edited by VaxoP; Aug 26th, 2004 at 12:59 AM.
-
Aug 25th, 2004, 10:50 PM
#2
Addicted Member
One way is to simply count the number of times a city is in ur list. If its greater than 5 then add to another array.
It may take a while to search through all the zip codes in this fashion but u should only have to do it once and then save the results.
-
Aug 25th, 2004, 11:57 PM
#3
is that good enough, or do you need more help?
-
Aug 26th, 2004, 12:59 AM
#4
Thread Starter
Frenzied Member
i got it figured out, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|