MathGroup Archive 2002

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

Search the Archive

Re: Position within a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32929] Re: Position within a list
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Wed, 20 Feb 2002 01:26:08 -0500 (EST)
  • References: <a4t08v$igf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Dana,
Here is a way  that does use Split:

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

Sort[Split[
      Transpose[{rdp,
          Range[Length[
              rdp]]}],#1[[1]] == #2[[1]]&],(Length[#1]<= Length[#2])&]//Last

{{9,763},{9,764},{9,765},{9,766},{9,767},{9,768}}

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Dana DeLouis" <ng_only at hotmail.com> wrote in message
news:a4t08v$igf$1 at smc.vnet.net...
> 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: Numerical Differentiation using Fourier Transform
  • Next by Date: Re: Position within a list
  • Previous by thread: Re: Position within a list
  • Next by thread: Re: Position within a list