From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16308 invoked from network); 30 May 2022 08:44:01 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 08:44:01 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id D46B2421F3; Mon, 30 May 2022 18:43:59 +1000 (AEST) Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by minnie.tuhs.org (Postfix) with ESMTPS id 0D55C421F2 for ; Mon, 30 May 2022 18:43:55 +1000 (AEST) Received: by mail-qv1-xf30.google.com with SMTP id el14so3126416qvb.7 for ; Mon, 30 May 2022 01:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=ghAYpa2JKVRuGgLbuGz0oW7KdmfW8sUabelKUYpggYg=; b=a/dDhzeC+hmQvOn+PZfBxMezjLYAZN4O3vb2PT6LaqDWGc+Y7NYxh0BH13bbGNml/u MJVBr2u/1h4+q+LevcrD4R0ucObEdZPlS0cH/HLgKnrj2/x+UcvnyOQQrCFtefjiGXMQ FKk+0QB/fbhP677z8oZn7F+lEW7hl1+yKfl52XGV5js4zXpVCcyXAOy5xLiQHGbsmYW3 SWR9kVf23efhlNrxGcpWKYZnGFXCLZoquS4aGUKB3AnSnZUEOF+mZOeiaDKOxbZe3DU1 hwgK2Hf9zvPt6RRmCrj0EFoYbJhQWxltMhbuBJ1ID8C0xjoYUK0lod5gAb5G1fGfLzOj oUCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=ghAYpa2JKVRuGgLbuGz0oW7KdmfW8sUabelKUYpggYg=; b=gDqMq5kuXSCbtb2+K1dY2zWXXVoz1wHgc/k0AqBJ7ZP7ggn/5FR0EzyDvaCNmyngei jpuhwsX4KapswbbsSHUGnFwdB8bcrqq1gC7/87WWIyHnzHZI4PNjPwUr1IrnnO67C/um Voy3PFT2Zuy5Xtf/FFIIku5ue6TagtA8z4nS8CGjxgA2wvwBUOIafrNHrDQEkk/r7U4P wjmnMBFHUyzanQq11vZwhnxVUcMWqHSHXKgbOpVuYVZHSYerup0d2MzDvwub10+SWAbw 0qIuTZBhzRufUK9+h8fujq4kIM53M+x7Ti8B2GxebicsS3SCl3TrPkHa1MAsD8aseOu2 UPng== X-Gm-Message-State: AOAM530KwW0lgKwNrscL/n8VwXXxgBoJUJqN/m0ELChncyfUuzbhKJ7I tlIYlwSoQMoJV0NDuD4G1On1/Lf0yf7n1yRt X-Google-Smtp-Source: ABdhPJyUorHsOGkKJ23zZPq3O0Zw3YQCukgwSHsP0r+uD3eGyAYwOKPDbo3hND2yUn8Lnvrl3MZalw== X-Received: by 2002:a05:6214:19cc:b0:461:fb6b:d408 with SMTP id j12-20020a05621419cc00b00461fb6bd408mr43418447qvc.64.1653900233646; Mon, 30 May 2022 01:43:53 -0700 (PDT) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id u16-20020a05620a121000b006a0ba4b8f48sm7320523qkj.49.2022.05.30.01.43.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 01:43:53 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Bakul Shah Mime-Version: 1.0 (1.0) Date: Mon, 30 May 2022 01:43:52 -0700 Message-Id: References: <20220530081604.A9FBF21F8A@orac.inputplus.co.uk> In-Reply-To: <20220530081604.A9FBF21F8A@orac.inputplus.co.uk> To: Ralph Corderoy X-Mailer: iPad Mail (19F77) Message-ID-Hash: OKDBKGMZO6NMHHSTK63ODOCK5EGGYFH4 X-Message-ID-Hash: OKDBKGMZO6NMHHSTK63ODOCK5EGGYFH4 X-MailFrom: bakul@iitbombay.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Computer Old Farts Followers X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [COFF] Re: Grep has gone overboard List-Id: Computer Old Farts Forum Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: > On May 30, 2022, at 1:16 AM, Ralph Corderoy wrote:= >=20 > =EF=BB=BFHi Bakul, >=20 >> You can write a program to generate all permutations and use that as >> your regexp. For example abc maps to abc|acb|bac|bca|cab|cba. >=20 > Being lazy, I tend to use a shell's brace expansion and then whittle it > down to generate permutations. I keep thinking it's surprising there's > no Bell Labs program to produce them given there's things like > factor(1). For permutations I just use this k program: $ cat perm.k p:{:[1:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]} perm:{x@p[#x]} $ k perm.k perm "abc" ("abc" "acb" "bac" "bca" "cab" "cba") I won=E2=80=99t bother explaining but p n returns all permutations of indices 0..n-1. Then perm is easy to construct. Similarly easy to insert | between strings but your solution is much more in the spirit of regexp and faster than my brute force solution! Also, thanks for catching the anchoring error! >=20 > The brace expansion is wasteful as it's going from n**l down to n! and > it can result in the old bash here not responding to SIGINT for a while > if it's producing gazillions. >=20 > $ printf '%s\n' {b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y}\ >> {b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y}{b,a,d,u,g,l,y} | >> egrep -v '(.).*\1' | >> fgrep -x -f - /usr/share/dict/words > ladybug > $ >=20 > --=20 > Cheers, Ralph.