Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Is it a valid hidden word?

Perl, 113 bytes reads line from stdin formatted as the test cases. Exits with 1 valid or 0 if invalid. perl -lF,. -E'($_,$n)=@F;@r=map{$n=~s/.{$_}\K/.*/r}1..length$n-1;$"="|";exit(!/$n/&&...

posted 5mo ago by jhnc‭

Answer
#1: Initial revision by user avatar jhnc‭ · 2026-04-10T19:02:14Z (5 months ago)
# Perl, 113 bytes

reads line from stdin formatted as the test cases. Exits with 1 valid or 0 if invalid.

```sh
perl -lF,. -E'($_,$n)=@F;@r=map{$n=~s/.{$_}\K/.*/r}1..length$n-1;$"="|";exit(!/$n/&&((y/ //d,/.$n./)||/^(@r)$/))'
```

```sh
perl -lF,. -E'
    # load clue and word
    ($_,$n) = @F;

    # create all permutations of prefix + ".*" + suffix of word
    @r = map {
        $n =~ s/.{$_}\K/.*/r
    } 1..length$n-1;

    # set array->string interpolation character for use in regex
    $"="|";

    exit(
        !/$n/ && (               # word not in clue, and (
            (y/ //d,/.$n./) ||   # is word break, or
            /^(@r)$/             # is bookend )
        )
    )
'
```



[Try it online!][TIO-mnt9shfw]

[TIO-mnt9shfw]: https://tio.run/##ZU5NT4NAEL3vrxibtYBu2fbgiWCKLbWkwJLdJU3jB9GI2qRuCdCkpq0/XVzw4MHLzLw3896bIi83V82uyqHaPVdg5Pt1bThIA2hHE1twgKJcqxpwdjd8uBzCCXX4FYzzCgbXYBCcOY2JM4KV5Y5nzrh0P56KA1buV0XtA85O9wtqX9DyNLLtTa7e6nesBiMH99zesed0OWcUK9rvm@YnBUpfCLWxsql1PNJHc1xamFpW0ySMcZizVPgE@JwhEcS3oQ@Se5MFARFMFmjFUohSIWHKJGjAIRDgxVOYcCbELyMFgVXKpUBCdqvQ97jWS48jySDS7pJFPgpi8CDRrqFmYi9BQZRwlvgcug/0oPu/J1okURJ6sSa12JcENNG6S@23/ItaMrgJ@FTAMpBzYPpeSF3b9NhH39uiXm9V1Qw2M2L/AA "Perl 5 – Try It Online"