# Is the input Bl lu ur rr ry?

This is based off this challenge.

Given an input string, check whether the string is blurry.

## What's a blurry string?

A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings.

Take a non-blurrified pure-ASCII string abc as an example. You repeat every character of this twice:

aabbcc


And then insert spaces at every odd-even index.

a ab bc c


Then, remove the preceding 2 and succeeding 2 extra characters. If there isn't enough space left, ignore the abundant removing instructions.

ab bc


As an example, all of these strings are blurry (the empty line stands for an empty string):

Before  After
"a"   ->
"ab"  ->ab
"abc" ->ab bc
"abcd"->ab bc cd
...

(Before = the string before blurrification)
(After  = the string after blurrification,
i.e. the strings in the set of all blurry strings.)


## Specification

• The input string consists purely of printable ASCII characters. The only whitespace it will contain is the space character.
• You don't have to remove extra characters before the check.
• Your output can consist of any trailing whitespace, as long as it's possible to tell a truthy result from a falsy result.
• It's noteworthy that the definition of "blurry" in this challenge is different than the previous challenge.

## Test cases

Here is a program I use to check my test cases.

""          -> True
"ab"        -> True
"ab bc"     -> True
"aa aa"     -> True
"ab bc cd"  -> True
" b bc cd"  -> True
"ab bc c "  -> True
"a   c cd"  -> True
"        "  -> True

"a"         -> False
"abc"       -> False
"ab  bc  cd"-> False
"ab#bc#cd"  -> False
"abbccd"    -> False
"a ab bc cd"-> False
"a a ab b b"-> False
"ba cb dc"  -> False
"ba bc dc"  -> False
"FFaallssee"-> False
"a aa a"    -> False

• I think it would be good to include some test cases where characters in the pre-blurred string repeat. – xnor May 3 '20 at 2:31
• I meant truthy ones like a aa a or even just eight spaces. (Edit: Oops, I mean aa aa) – xnor May 3 '20 at 2:35
• I'd argue the empty string is not blurry because one doesn't simply remove the first and last two characters from a string shorter than 4. – the default. May 3 '20 at 4:52
• I don't understand how is " b bc cd" or "ab bc c " or "a c cd" or "" or " "*8 blurry. What are the strings that originated those? – RGS May 3 '20 at 6:54
• Depending on the answer to my comment above, it might be good to edit the challenge to explicitly specify we are defining a blurry string in a way that is different from what was done in the challenge in which this one is inspired – RGS May 3 '20 at 6:57

# Perl 5 with -plF/^(.((.)\x20\3)*.|)$/, 7 bytes $_=@F^1


Try it online!

### Explanation

Continuing the theme of abusing -F, I ended up with the same expression used in the Retina answer. The -F argument splits the input string on the valid expression and will place an even number of elements in @F, if the regular expression doesn't match, @F will just contain one entry, the whole string. When numeric operators are applied to a list (@F in this case) the length is implicitly used, so we XOR with 1 to give 0 for the failing test cases and a positive integer for all others.

# Retina, 14 bytes

a.((.) \2)*.|


Try it online!

# Explanation

a forces the match to be on the entire string

.((.) \2)*. just means any character (.) followed by a captured group repeated 0 to many times ((...)*) of any character saved into a second captured group ((.)) followed by a space and the same character that was matched in the second capture group (\2). The final . just matches the last character

| allows the empty string to match by having an alternative match of the empty string

# Python 3, 60 54 bytes

-6 bytes thanks to Surculose Sputum!

a,*b,c=input()or'ab'
while b:x,y,z,*b=b;x[x!=z][y>' ']


Try it online! Output is via exit code.

By using different sets of errors for truthy/falsy inputs this can be 52 bytes, as suggested by Surculose Sputum.

• 55 bytes by throwing NameError when input is empty. – Surculose Sputum May 3 '20 at 8:15
• – Surculose Sputum May 3 '20 at 9:01
• -1 byte: x[x+y!=z+' '] – Tipping Octopus May 6 '20 at 17:54

# Python 2, 57 bytes

lambda x:x==''.join(c+' '+c for c in x[::3]+x[-1:])[2:-2]


Try it online!

Uses the same approach as my Pyth answer. The blurring portion of the code is based off of @Surculose Sputum's answer to the original "Blur a string" challenge.

_#""=1<2
p#(' ':x:y:s)|p==x=y#s
_#_=2<1
f""=1<2
f(x:y:s)=y#s
f _=2<1


Try it online!

## Explanation

f is the entry point. No real tricks; loop through recursively ensuring that every third character is a space, while keeping track of the second character of the previous chunk each time and ensuring that it's equal to the first of the next chunk.

• You can combine the first and last case for both (#) and f. Try it online! – Wheat Wizard May 3 '20 at 23:57

# Pyth, 13 bytes

qjd.:+%3Q>1Q2


Try it online!

qjd.:+%3Q>1Q2
%3Q      Take every 3rd character of the input string
(eg. "ab bc cd" becomes "abc")
+   >1Q   Append the last character of the input string
jd.:       2  "Blur" the resulting string
(ie. find all substrings of length 2 and join on spaces)
q              Return true if that matches the input string

• For -1 byte, >1Q is the same as eQ – ar4093 May 4 '20 at 6:49
• @ar4093 Yep, except that eQ throws an Index Out of Range error for the empty string :/ – math junkie May 4 '20 at 13:58

# 05AB1E, 1613 12 bytes

¤º«3ô€нüJðýQ


Try it online!

Uses the blurring program here to re-blur the string. -1 byte thanks to Kevin Cruijssen!

3ô©)€н®θJüJðýQ
3ô                  # Split the input into chunks of 3
©                # Item split the above and store the last item in the register
)               # Wrap everything back into a list
€н             # Get the first character from each item in then above list
            # Item split the list generated from the above map
®θJ         # Join the above with the last letter from the register
üJðý     # Blatant port of https://codegolf.stackexchange.com/a/203906/78850 -- i.e. blur the string
Q    # Check to see if the blurred string is the input


# Charcoal, 26 21 bytes

⁼✂θ¹±¹¦¹⭆✂θ¹±¹¦³⁺⁺ι ι


Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, - for a blurry string, nothing if not. Explanation:

  θ                     Input string
✂ ¹±¹¦¹                Slice off the first and last characters
⁼                       Is equal to
θ             Input string
✂ ¹±¹¦³        Every other third character
⭆               Map over characters and join
⁺⁺ι ι   Wrap a space in that character
Implicitly print


# Japt, 13 bytes

The empty string being truthy cost a couple of bytes :\

¶¬ë3 pUÌ ä+ ¸


Try it (includes all test cases)

¶¬ë3 pUÌ ä+ ¸     :Implicit input of string U
¶                 :Test for equality with
¬                :Split to an array
ë3              :Take every 3rd element, starting with the first
p            :Push
UÌ          :  Last character of U
ä+       :Consecutive pairs, reduced by concatenation
¸     :Join with spaces


# Red, 52 51 bytes

func[a][s:[skip]parse a[opt[s any[copy t s" "t]s]]]


Try it online!

# Jelly, 8 bytes

m3żḊ$K⁼Ṗ  A monadic Link accepting a list of characters which yields 1 (blurry), or 0 (not blurry). Try it online! Or see the test-suite. ### How? m3żḊ$K⁼Ṗ - Link: list of characters, S
m3       - modulo-3-slice (S)
$- last two links as a monad (f(X)): Ḋ - remove the head (X) ż - zip together (X and that) K - join with spaces Ṗ - remove the tail (S) ⁼ - equal?  # JavaScript (Node.js), 29 bytes s=>/^.((.) \2)*.$|^\$/.test(s)
`

Try it online!

Pure port