Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Position within a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32930] Re: Position within a list
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 20 Feb 2002 01:26:09 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <a4t08v$igf$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,


lst = RealDigits[Pi, 10, 10000][[1]];


pp = Position[
              Split[lst],   
             First[
                 Sort[
                    Select[Split[lst],
                        Length[#] > 2 &],
                   Length[#1] > Length[#2] &
            ]
          ]
        ];
pos = pp[[1, 1]];
i = k = 0;
lstpos=
  Catch[
   Scan[
      (i++; k += Length[#]; If[i === pos, Throw[k]]) &, Split[lst]
    ]
  ]

the position if the last 9 in the list of digits is lstpos and 
should be 768 for six 9 digits.

Regards
  Jens

Dana DeLouis wrote:
> 
> Hello.  A long time ago someone posted an elegant solution, but I can not
> find it in the Archives.
> Given a list that may have repeating data, this returned the character that
> was repeated the most, and its position..
> 
> The example given was a list of the first 10,000 digits of Pi.  I believe
> the answer was that the number 9 was repeated 6 times around position
> 700 or 800.
> The function was very short and elegant.
> I don't believe the Split function was used, but I might be wrong.
> 
> Does anyone know how to do this?  Thank you.
> 
> lst = RealDigits[Pi,10,10000][[1]];
> 
> The list would have...
> {3, 1, 4, 1, 5, 9, 2, 6, etc)
> 
> --
> Dana DeLouis
> Windows XP  & Mathematica 4.1
> = = = = = = = = = = = = = = = = =


  • Prev by Date: Re: Position within a list
  • Next by Date: Re: Solve/Reduce and assumptions
  • Previous by thread: Re: Position within a list
  • Next by thread: RE: Position within a list