Re: find missing numbers in a series
- To: mathgroup at smc.vnet.net
- Subject: [mg119045] Re: find missing numbers in a series
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 20 May 2011 06:39:33 -0400 (EDT)
On 5/19/11 at 7:42 AM, slshippee at gmail.com (shippee) wrote: >I have a series of numbers ranging from PE00001 to PE99999. >Sample/Snippet below (descending order): PE00445 PE00444 PE00442 >PE00438 PE00437 PE00434 PE00432 PE00428 PE00424 PE00423 PE00420 >PE00418 PE00417 PE00416 PE00414 PE00412 PE00411 PE00410 PE00405 >PE00404 PE00403 PE00400 PE00398 PE00397 PE00393 PE00386 PE00383 >PE00381 PE00377 PE00374 PE00352 PE00350 PE00348 PE00344 PE00339 >PE00334 PE00332 PE00330 PE00328 PE00326 PE00323 PE00284 PE00283 >PE00281 PE00280 PE00279 PE00278 PE00277 PE00276 PE00275 PE00273 >PE00270 PE00269 PE00268 PE00267 PE00266 PE00265 PE00264 PE00263 >PE00262 PE00261 PE00260 >What would be the best approach to have mathematica show me what >STRINGS are missing from this series? Here is how I would do it: In[1]:= data = {"PE00444", "PE00442", "PE00438", "PE00437", "PE00434", "PE00432", "PE00428", "PE00424", "PE00423", "PE00420", "PE00418", "PE00417", "PE00416", "PE00414", "PE00412", "PE00411", "PE00410", "PE00405"}; In[2]:= x = ToExpression[StringDrop[#, 2] & /@ data]; In[3]:= missing = "PE" <> ToString[NumberForm[#, 4, NumberPadding -> {"0", "0"}]] & /@ Complement[Range[Min[x], Max[x]], x] Out[3]= {PE00406,PE00407,PE00408,PE00409,PE00413,PE00415,PE00419,PE00421,= PE00422,PE00425,PE00426,PE00427,PE00429,PE00430,PE00431,PE00433,PE00435,PE0= 0436,PE00439,PE00440,PE00441,PE00443}