#!/usr/bin/env python #-*- encoding: utf-8 -*- # # FILE.py # DESC # # Copyright (c) 2008 Pierre "delroth" Bourdon # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from itertools import islice mots = open('/usr/share/dict/french').read().split('\n') mots = [(m, sorted(m)) for m in mots] f = open('anagrammes', 'w') anagrammes = [] n = len(mots) for i, (m1, s1) in enumerate(islice(mots, n)): if i % (n / 10000) == 0: print 100.0 * i / n, "%" for (m2, s2) in islice(mots, i+1, n): if s1 == s2: f.write('%s / %s\n' % (m1, m2))