Re: List of integers & L.I.S.

2005-09-26 Thread antonmuhin
Hellom n00m! I beg your pardon for not having replied for such long time---I was really busy. Yes, the posted code doesn't solve the supernumbers problem, but solves the problem you posted first as I understood it :) --- for each number find a position of this number in the longest sequence it be

Re: List of integers & L.I.S.

2005-09-16 Thread n00m
Anton, it simply does not work! Try supernumbers([2,1,4,5,3]). -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S.

2005-09-15 Thread antonmuhin
I hope nobody have posted similar solution (it's tested, but I didn't submit it to contest): from bisect import bisect_right as find def supernumbers(ls): indices = [0]*len(ls) for i, e in enumerate(ls): indices[e - 1] = i result = [None]*len(ls) borders = [] for i in indices:

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread n00m
Thank you both for your replies. And my personal "Thank you!" to Mr. Hettinger for all his tremendous work! > Perhaps because you are not using a real Usenet client? Yes! And I don't even know what is the beast - Usenet client. I just keep in Favorites of my browser (IE 6.0) this link: http://grou

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread Reinhold Birkenfeld
n00m wrote: > Got it! He is a kind of pythonic monsters. > > Btw, why it's impossible to reply to old threads? > Namely, there're no more "Reply" link in them. > Only "Reply to author" etc. Perhaps because you are not using a real Usenet client? Reinhold -- http://mail.python.org/mailman/listin

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread Terry Reedy
"n00m" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Who is Raymond Hettinger? The Python developer who, in the last few years, has perhaps been the most active in coding or recoding library modules, such as itertools and sets, in C. He also partipates in development discussio

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread n00m
Got it! He is a kind of pythonic monsters. Btw, why it's impossible to reply to old threads? Namely, there're no more "Reply" link in them. Only "Reply to author" etc. -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread Reinhold Birkenfeld
n00m wrote: > Tim Peters wrote: >> The chance that Raymond Hettinger is going to recode _your_ >> functions in C is approximately 0 ;-) > Who is Raymond Hettinger? See python-dev and, wrt this thread, http://docs.python.org/whatsnew/node12.html. Reinhold -- http://mail.python.org/mailman/listin

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread n00m
Tim Peters wrote: > The chance that Raymond Hettinger is going to recode _your_ > functions in C is approximately 0 ;-) Who is Raymond Hettinger? -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread Tim Peters
[Tim Peters, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] >> Oh, it's not that bad . I took a stab at a Python program for >> this, and it passed (3.44 seconds). >> ... >> I didn't make any effort to speed this, beyond picking a reasonable >> algorithm, so maybe someone else can

Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread Bryan Olson
Tim Peters wrote: > [Bryan Olson, on the problem at > http://spoj.sphere.pl/problems/SUPPER/ > ] > >>I never intended to submit this program for competition. The >>contest ranks in speed order, and there is no way Python can >>compete with truly-compiled languages on such low-level code.

Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread Tim Peters
[Tim Peters, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] >> ... [EMAIL PROTECTED] > INCREDIBLE~ > 241433 2005-09-11 04:23:40 Tim Peters accepted 3.44 7096 PYTH > BRAVO! It's different now ;-) I added the two lines import psyco psyco.full() and time dropped to 2.29, while

Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread n00m
Tim Peters; INCREDIBLE~ > 241433 2005-09-11 04:23:40 Tim Peters accepted 3.44 7096 PYTH BRAVO! I just wonder have I grey cells enough for to understand how your algo works... and hopefully it's not your last solved problem on the contester. > I'm pretty sure they're using > slower HW than mine

Re: List of integers & L.I.S. (SPOILER)

2005-09-10 Thread Tim Peters
[Bryan Olson, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] > I never intended to submit this program for competition. The > contest ranks in speed order, and there is no way Python can > compete with truly-compiled languages on such low-level code. > I'd bet money that the algorit

Re: List of integers & L.I.S. (SPOILER)

2005-09-10 Thread n00m
Bryan; My own version also timed out. And now I can tell: it's incredibly SLOW. Nevertheless it would be interesting to compare speed of my code against yours. I can't do it myself because my Python is of 2.3.4 version. Just uncomment "your" part. import bisect def oops(w,a,b): for m in w:

Re: List of integers & L.I.S. (SPOILER)

2005-09-10 Thread n00m
Bryan Olson wrote: > Could be. Yet you did write: >> It's incredibly fast! I just was obliged to exclaim "It's incredibly fast!" because I THOUGHT your first version handled ALL TEN testcases from the input. But the code read from the *20-lines* input *ONLY 2* its first lines. Usually they pl

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > It also timed out:( Could be. Yet you did write: > It's incredibly fast! I never intended to submit this program for competition. The contest ranks in speed order, and there is no way Python can compete with truly-compiled languages on such low-level code. I'd bet money that t

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
PS: ALL problems in problems.PDF file (weekly updated): http://spoj.sphere.pl/problems.pdf The friendliest online contester I've ever seen! JUST A NON-SUCH. -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
It also timed out:( 241056 2005-09-09 20:11:19 ZZZ time limit exceeded - 7064 PYTH Btw, have a look at this nicest problem: http://spoj.sphere.pl/problems/COINS/ My py solution takes #64 place among its best solutions: http://spoj.sphere.pl/ranks/COINS/start=60 -- http://mail.python.org/m

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > Oh! > Seems you misunderstand me! > See how the last block in your code should look: > > for tc in range(10): > _ = stdin.readline() > sequence = [int(ch) for ch in stdin.readline().split()] > supers = supernumbers(sequence) > print len(supers) > for i in

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
Oh! Seems you misunderstand me! See how the last block in your code should look: for tc in range(10): _ = stdin.readline() sequence = [int(ch) for ch in stdin.readline().split()] supers = supernumbers(sequence) print len(supers) for i in supers: print i, When I submi

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > Oops Bryan... I've removed my reply that you refer to... > See my previous - CORRECT - reply. The code just times > out... In some sense it doesn't matter right or wrong is > its output. If my code times out, then they are using an archaic platform. With respect to my code, you n

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
> nor even what submission is yours and your latest. Oops.. my UserName there is ZZZ. Submissions in the html table are ordered by date DESC. -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
Oops Bryan... I've removed my reply that you refer to... See my previous - CORRECT - reply. The code just times out... In some sense it doesn't matter right or wrong is its output. Btw, what is the complexity of your algorithm? Currently I'm at work and it's not easy for me to concentrate on our su

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > Bravo, Bryan! > It's incredibly fast! Not compared to a good implementation for a compiled, low-level language. > But your code got WA (wrong answer). > See my latest submission: http://spoj.sphere.pl/status/SUPPER/ > Maybe you slipped a kind of typo in it? Silly boundary cases

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
Bravo, Bryan! Looks very neat! (pity I can't give it a try in my Py 2.3.4 because of reversed() and sorted() functions) And I've submitted it but got ... TLEs: http://spoj.sphere.pl/status/SUPPER/ Funnily, the exec.time of the best C solution is only 0.06s! PS In my 1st submission I overlooked tha

Re: List of integers & L.I.S. (SPOILER)

2005-09-08 Thread n00m
Bravo, Bryan! It's incredibly fast! But your code got WA (wrong answer). See my latest submission: http://spoj.sphere.pl/status/SUPPER/ Maybe you slipped a kind of typo in it? Silly boundary cases? -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S. (SPOILER)

2005-09-08 Thread Bryan Olson
n00m wrote: > Firstly I find ordering numbers when moving from left to the right; > then I find ord. numbers for backward direction AND for DECREASING > subsequences: Sounds good. > Btw, I did it in Pascal. Honestly, I don't believe it can > be done in Python (of course I mean only the impo

Re: List of integers & L.I.S.

2005-09-08 Thread n00m
> 4 5 1 2 3 6 7 8 << the list itself > 1 2 1 2 3 4 5 6 << ordering numbers for forward direction > 2 1 6 5 4 3 2 1 << ordering numbers for backward direction > === > 3 3 7 7 7 7 7 7 << sums of the pairs of ord. numbers Oops! Sorry for miscounting in backward direction. Should be (anyway the

Re: List of integers & L.I.S.

2005-09-08 Thread n00m
PS: I've still not read 2 new posts. -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S.

2005-09-08 Thread n00m
[EMAIL PROTECTED] wrote: > So, this has no real world use, aside from posting it on a website. I don't think you're quite right. We never know where we gain and where we lose. > So clearly it served a very useful purpose! ;) Thanks, Manuel! > your question is different than the question on this

Re: List of integers & L.I.S.

2005-09-08 Thread [EMAIL PROTECTED]
> That's easy to follow, although their use of a Van Emde-Boas set as a > given hides the most challenging part (the "efficient data structure" > part). The "efficient data structure" is the easy part. Obviously, it is a dict of lists. ...or is it a list of dicts?... ...or is it a tuple of gene

Re: List of integers & L.I.S.

2005-09-08 Thread Tim Peters
[EMAIL PROTECTED] > So, this has no real world use, aside from posting it on a website. > Thanks for wasting our time. You are making up an arbitrary problem and > asking for a solution, simply because you want to look at the > solutions, not because your problem needs to be solved. Clearly, this >

Re: List of integers & L.I.S.

2005-09-08 Thread [EMAIL PROTECTED]
Working on this allowed me to avoid some _real_ (boring) work at my job. So clearly it served a very useful purpose! ;) Manuel -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S.

2005-09-08 Thread [EMAIL PROTECTED]
So, this has no real world use, aside from posting it on a website. Thanks for wasting our time. You are making up an arbitrary problem and asking for a solution, simply because you want to look at the solutions, not because your problem needs to be solved. Clearly, this is a waste of time. -- ht

Re: List of integers & L.I.S.

2005-09-08 Thread [EMAIL PROTECTED]
> ... and let me reveal the secret: > http://spoj.sphere.pl/problems /SUPPER/ your question is different than the question on this website. also, what do you consider to be the correct output for this permutation? (according to your original question) [4, 5, 1, 2, 3, 6, 7, 8] Manuel -- http:/

Re: List of integers & L.I.S.

2005-09-07 Thread n00m
Thanks guys! > Are you sure that this is not a homework problem? ... and let me reveal the secret: http://spoj.sphere.pl/problems/SUPPER/ Hardly it can be easily reduced to "standard" LIS problem (i.e. to find just a (any) Longest Increasing Sequence). > I coded a solution that can compute the or

Re: List of integers & L.I.S.

2005-09-07 Thread [EMAIL PROTECTED]
I coded a solution that can compute the ordering numbers for random.shuffle(range(1, 101)) in 2.5 seconds (typical, Win 2K Pro, Pentium 4 2.40GHz 785Meg RAM) Are you sure that this is not a homework problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S.

2005-09-07 Thread Dan Sommers
On 7 Sep 2005 09:48:52 -0700, "n00m" <[EMAIL PROTECTED]> wrote: > Given a list of N arbitrarily permutated integers from set {1..N}. > Need to find the ordering numbers of each integer in the LONGEST > increasing sequence to which this number belongs. Sample: > List: > [4, 5, 6, 1, 2, 7, 3] > Co

List of integers & L.I.S.

2005-09-07 Thread n00m
Given a list of N arbitrarily permutated integers from set {1..N}. Need to find the ordering numbers of each integer in the LONGEST increasing sequence to which this number belongs. Sample: List: [4, 5, 6, 1, 2, 7, 3] Corresponding ordering numbers: [1, 2, 3, 1, 2, 4, 3] Details: e.g. number 7 b