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: [mg119037] Re: find missing numbers in a series
  • From: Sseziwa Mukasa <mukasa at gmail.com>
  • Date: Fri, 20 May 2011 06:38:06 -0400 (EDT)

On May 19, 2011, at 7:42 AM, 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?

Do you really want all missing values, or just the ones between PExxxxx and=
 PEyyyyy where xxxxx and yyyyy are the smallest and largest values in the l=
ist?

At any rate you can do:

Complement["PE"<>IntegerString[#,10,5]&/@Range[99999],lst]

for the first case and

Block[{l == Sort[lst]},
 Complement[
  "PE" <> IntegerString[#, 10, 2] & /@
   Range[FromDigits[StringDrop[First[l], 2]],
    FromDigits[StringDrop[Last[l], 2]]], lst]]

for the second, where lst is the list of values you are examining.

Regards,
Ssezi


  • Prev by Date: Re: Count Ouccrence of words in a long text
  • Next by Date: Re: find missing numbers in a series
  • Previous by thread: Re: find missing numbers in a series
  • Next by thread: Re: find missing numbers in a series