Differences between revisions 1 and 2
Revision 1 as of 2008-02-23 21:52:41
Size: 539
Editor: S0106004854886a46
Comment:
Revision 2 as of 2008-02-24 14:58:44
Size: 735
Editor: musmire
Comment: Solution to problem 8
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:

= Problem 8: Eliminate consecutive duplicates of list elements =

{{{
    from itertools import groupby
    def compress(alist):
        return [key for key, group in groupby(alist)]
}}}

Python Solutions to [https://prof.ti.bfh.ch/hew1/informatik3/prolog/p-99/ 99 Prolog Prolems].

Index TableOfContents(2)

Problems 1-6

André Roberge has a zip file with solutions to the first six problems, in Crunchy format: [http://crunchy.googlecode.com/files/first_6_of_99_problems.zip First six]

Problem 7: Flatten a nested list structure

Based on the standard library documentation:

    from itertools import chain
    def flatten(listOfLists):
        return list(chain(*listOfLists))

Problem 8: Eliminate consecutive duplicates of list elements

    from itertools import groupby
    def compress(alist):
        return [key for key, group in groupby(alist)]

ProblemSets/99 Prolog Problems Solutions (last edited 2011-01-19 02:01:22 by 208)

Unable to edit the page? See the FrontPage for instructions.