MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: find missing numbers in a series

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119038] Re: find missing numbers in a series
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Fri, 20 May 2011 06:38:17 -0400 (EDT)
  • References: <ir2vma$h0r$1@smc.vnet.net>

On May 19, 4:42 am, shippee <slship... at gmail.com> 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?
>
> Thanks in advance,
>
> Steven Shippee
> Olympia, Washington

data = {"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"};

e = ToExpression @ StringDrop[#, 2]& /@ data

{445, 444, 442, 438, 437, 434, 432, 428, 424, 423, 420, 418, 417,
 416, 414, 412, 411, 410, 405, 404, 403, 400, 398, 397, 393, 386,
 383, 381, 377, 374, 352, 350, 348, 344, 339, 334, 332, 330, 328,
 326, 323, 284, 283, 281, 280, 279, 278, 277, 276, 275, 273, 270,
 269, 268, 267, 266, 265, 264, 263, 262, 261, 260}

"PE" <> StringTake["0000" <> ToString@#, -5]& /@
 Complement[Range[Min@e, Max@e], e]

{PE00271, PE00272, PE00274, PE00282, PE00285, PE00286, PE00287,
 PE00288, PE00289, PE00290, PE00291, PE00292, PE00293, PE00294,
 PE00295, PE00296, PE00297, PE00298, PE00299, PE00300, PE00301,
 PE00302, PE00303, PE00304, PE00305, PE00306, PE00307, PE00308,
 PE00309, PE00310, PE00311, PE00312, PE00313, PE00314, PE00315,
 PE00316, PE00317, PE00318, PE00319, PE00320, PE00321, PE00322,
 PE00324, PE00325, PE00327, PE00329, PE00331, PE00333, PE00335,
 PE00336, PE00337, PE00338, PE00340, PE00341, PE00342, PE00343,
 PE00345, PE00346, PE00347, PE00349, PE00351, PE00353, PE00354,
 PE00355, PE00356, PE00357, PE00358, PE00359, PE00360, PE00361,
 PE00362, PE00363, PE00364, PE00365, PE00366, PE00367, PE00368,
 PE00369, PE00370, PE00371, PE00372, PE00373, PE00375, PE00376,
 PE00378, PE00379, PE00380, PE00382, PE00384, PE00385, PE00387,
 PE00388, PE00389, PE00390, PE00391, PE00392, PE00394, PE00395,
 PE00396, PE00399, PE00401, PE00402, PE00406, PE00407, PE00408,
 PE00409, PE00413, PE00415, PE00419, PE00421, PE00422, PE00425,
 PE00426, PE00427, PE00429, PE00430, PE00431, PE00433, PE00435,
 PE00436, PE00439, PE00440, PE00441, PE00443}

With the real data you might want to change Range[Min@e,Max@e]
to Range[99999].


  • Prev by Date: Re: unable to import csv-Data
  • Next by Date: Re: Get["file.mx"] doesn't work
  • Previous by thread: Re: find missing numbers in a series
  • Next by thread: Request for Mathmark 8