Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:/ 10': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sub': 0.09; 'subject:method': 0.09; 'printf': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'skip:@ 20': 0.16; 'wrote:': 0.17; 'subject:page': 0.17; 'skip:% 10': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.28; 'chris': 0.28; 'cat': 0.29; 'perl': 0.29; 'asking': 0.32; 'subject: .': 0.33; 'to:addr:python-list': 0.33; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'enough': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; '8bit%:100': 0.70; '8bit%:92': 0.70; '2013': 0.84; 'subject:Using': 0.84; 'wrong...': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Using filepath method to identify an .html page Date: Tue, 22 Jan 2013 20:16:34 +0100 Organization: None References: <50fe787e$0$30003$c3e8da3$5496439d@news.astraweb.com> <50fe8e69$0$30003$c3e8da3$5496439d@news.astraweb.com> <0459659d-4ec2-4c7d-bee3-b4e363c916dd@googlegroups.com> <12a22c5b-88a9-4577-a642-abe1e56cce5e@googlegroups.com> <8ad4a124-37a8-41fc-938d-9535b8affcbf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p5084a038.dip.t-dialin.net User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358882199 news.xs4all.nl 6885 [2001:888:2000:d::a6]:50883 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37337 Ferrous Cranus wrote: > Τη Τρίτη, 22 Ιανουαρίου 2013 6:11:20 μ.μ. UTC+2, ο χρήστης Chris Angelico > έγραψε: >> all of it. You are asking something that is fundamentally >> impossible[1]. There simply are not enough numbers to go around. > Fundamentally impossible? > > Well.... > > OK: How about this in Perl: > > $ cat testMD5.pl > use strict; > > foreach my $url(qw@ /index.html /about/time.html @){ > hashit($url); > } > > sub hashit { > my $url=shift; > my @ltrs=split(//,$url); > my $hash = 0; > > foreach my $ltr(@ltrs){ > $hash = ( $hash + ord($ltr)) %10000; > } > printf "%s: %0.4d\n",$url,$hash > > } > > > which yields: > $ perl testMD5.pl > /index.html: 1066 > /about/time.html: 1547 $ cat clashes.pl use strict; foreach my $url(qw@ /public/fails.html /large/cannot.html /number/being.html /hope/already.html /being/really.html /index/breath.html /can/although.html @){ hashit($url); } sub hashit { my $url=shift; my @ltrs=split(//,$url); my $hash = 0; foreach my $ltr(@ltrs){ $hash = ( $hash + ord($ltr)) %10000; } printf "%s: %0.4d\n",$url,$hash } $ perl clashes.pl /public/fails.html: 1743 /large/cannot.html: 1743 /number/being.html: 1743 /hope/already.html: 1743 /being/really.html: 1743 /index/breath.html: 1743 /can/although.html: 1743 Hm, I must be holding it wrong...