Re: find missing numbers in a series
- To: mathgroup at smc.vnet.net
- Subject: [mg119041] Re: find missing numbers in a series
- From: Armand Tamzarian <mike.honeychurch at gmail.com>
- Date: Fri, 20 May 2011 06:38:50 -0400 (EDT)
- References: <ir2vma$h0r$1@smc.vnet.net>
On May 19, 9:42 pm, 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 This works but could probably be improved with some more time to think about it: list = your list above. partialList = ToExpression[StringDrop[#, 2] & /@ list] fullList = Range[260, 445] missing = ToString /@ Complement[fullList, partialList] Switch[StringLength[#], 1, "PE0000" <> #, 2, "PE000" <> #, 3, "PE00" <> #, 4, "PE0" <> #, 5, "PE" <> #] & /@ missing Mike