title: Does it Lead or Follow?

text:
# Question
Title: Does it Lead or Follow?
In this challenge you are to write a program or function, that takes a string as input and outputs one of two possible values. We will call one of these values *truthy* and one *falsy*. They do not need to actually be *truthy* or *falsy*. For an answer to be valid it must meet four additional criteria

* When you pass your program to itself it outputs the *truthy* value.
* If you pass your program as input to any older answer it should output the *truthy* output (of the program you are passing to).
* If you pass any older answer to your answer as input it should output the *falsy* output (of your program).
* There must be an infinite number of strings that evaluate to *truthy* output in all answers on the challenge (including your new answer).

What this will do is it will slowly build up a chain of answers each of which can determine if other programs in the chain come before or after it.

The goal of this challenge is to build up a list of source restrictions that are applied to the successive answers making each one more challenging than the last.

## Example

A chain (written in Haskell) could start:

```
f _ = True

```

Since there are no older programs, the criteria do not apply to this answer it need only output one of two possible values, in this case it always outputs `True`.

Following this could be the answer:

```
f x=or$zipWith(==)x$tail x

```

Try it online!

Which asserts that there is a character twice in a row somewhere in the string. The first answer doesn't have this property while the second does (`==`). Thus this is a valid next answer.

## Special rules

* You may use any language you wish (that has a freely available implementation) as many times as you wish.
* If you were the last person to answer you must wait at least 7 days before posting a new answer.
* Your program may not read its own source.
* Since the 4th rule is exceedingly difficult to verify if cryptographic functions are involved, such functions are disallowed.

## Scoring criterion

Each time you add an answer you will get as many points as its place in the chain. For example the 5th answer would gain it's writer 5 points. The goal is to get as many points as you can. The last answer will score its answerer -∞ points. This will probably be more fun if you try to maximize your own score rather than "win" the challenge. I will not be accepting an answer.

> Since this is you may want to sort by oldest

# Answer
# 14. X86 Assembly (gcc 6.3), 324 bytes

```
.TITLE "a"#"a" ELTIT.
.data
i:.fill 25,1,0
s:.string "%25[^\n]"
t:.string "->Hi, Retina!"
f:.string "Bye Retina!"
.global main
main:
pushl $i
pushl $s
call scanf
addl $8, %esp
pushl $i
call strlen
addl $4, %esp
sub $21, %eax
jz y
pushl $f
call printf
addl $4, %esp
jmp en
y:
pushl $t
call printf
addl $4, %esp
en:
ret

```

Try it on ideone!

Note: *this **will** return a runtime error because the exit code is not zero. Running this in the ideone editor will display all stdout output regardless of how the program concludes.*

* **Truthy** output: `"->Hi, Retina!"`
* **Falsy** output: `"Bye Retina!"`

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. **The first line is exactly 21 characters long (not including newline).**

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`.
* The last non-empty line does not have any duplicate characters.
* **The first line is a palindrome of length = 21**
> 10 votes

# Answer
## 9. Retina, 16 bytes

```
.->0`Hi, Retina!

```

Try it online!

If you want to try your own program, simply append it to the input field, separated by two linefeeds. (If your program contains two linefeeds, you'll have to change the separator between all programs and in the TIO header.)

**Satisfies:**

2. The first character is a `.`
3. It contains an `e`
4. Its length is even
5. Its length is a perfect square
6. It contains an `a`
7. It contains a `>` character
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.

Sorry, but you kinda forced me to pad to length 16...

**Without redundant requirements:**

* The first character is a `.`
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.

### Explanation

Starting with `.` is fine, it just means that we suppress Retina's implicit output (provided the first line has a configuration, but I didn't want a two-line program). That means we need it explicit output, but the option for that is `>`, so we're in luck. The `-` can go in front of it because it doesn't do anything.

Now we can get to the program itself. The simplest thing to do is to match a literal string. That's guaranteed to show up in our program, we can easily make sure that it isn't part of any existing program, and it gives us a number as the result. However, it could potentially return a number greater than 1 (so more than two different values). We avoid this with the `0`-limit which only looks at the first match and counts that if it exists. So the `0` ensures that the output is only ever `0` or `1` (depending on whether the input contains the literal string).

As for the literal string... well, we still need to include an `e` and an `a`... and we need the string to have at least 11 characters, so that we match the length requirements (getting to an even square). `Hi, Retina!` happens to satisfy those requirements.
> 7 votes

# Answer
# 13. Perl 5, 64 bytes

```
.1;";1.
\"Hi, Retina!->";$_=<>;chop;print y///c>5&&reverse
eq$_;

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. **The first line is a palindrome of length \> 5.**

**Summary for future answers:**

* First character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10th character is a `"`.
* The last non-empty line does not have any duplicate characters.
* **The first line is a palindrome of length \> 5 (in *characters*).**

**Verification Ruby script**
> 7 votes

# Answer
# 5. Python 3, 64 bytes

```
.012
import sys
print(len(sys . stdin . read()) ** 0.5 % 1 == 0)

```

Try it online! Checks if the length of the input is a perfect square.

**This had been updated by the time 18 answers were present to support multiline input.**

**The update does not hurt the chain.**

---

**Satisfies:**

2. starts with a `.`
3. contains an `e`
4. has an even length
5. has a perfect square length
> 6 votes

# Answer
# 25, Octave, 196 bytes

New requirement: To avoid the tab versus spaces discussion, tabs can no longer be used for indentation. Each line still needs a tab, but it can't be the first character in the line.

```
.6;%+->?|"	"|?>-+%;6.
f=@(x)1&&cellfun(@(C)any(C=='	')&1&&find(C=='	')>1,strsplit(x,char(10)));
%
%
%
%
%
%
%Henry Jams?Hi, Retina!
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%	~

```

**Verify all programs online!**

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line

---

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The first line is a palindrome of length 21.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.
* Its length is an even perfect square.
* It is at least 28 lines long.
* The ninth line must have at least 22 characters, excluding the newline.
* The last non-empty line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.

**Explanation:**

It was actually a bit hard to keep this at 196 bytes, since there are many bytes that are now mandatory on each line.

The first line is simply a scalar that's not outputted, followed by a comment. The second line is an anonymous function that takes a string `x` as input and makes the following operations:

```
strsplit(x,char(10))   % Split at newlines. Can't use a literal newline, or [10,''] due to previous rules
cellfun(@(C) ...     ) % Perform the following operation on each line:
  any(C==' ')          % Make sure there is at least one tab character
  1&&find(C==' ')>1    % Make sure the index is higher than 1
1&&cellfun( ... )     % Check that this is true for all lines.

```

It's lucky that the short circuit operation `&&` takes precedence over `&`, and that `1&&find` doesn't require parentheses. Otherwise I wouldn't manage to golf this down to 196 bytes.
> 6 votes

# Answer
# 11. JavaScript (ES6), 36 bytes

```
.11&&(s=>"Hi, Retina!->"&&s[9]=='"')

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. **The 10-th character is a `"`.**

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`.
> 5 votes

# Answer
# 23, Literate Haskell, 196 bytes

New requirement: Indentation is great, so each line needs to contain at least one tab character.

```
.1+C->|  "	"  |>-C+1.

>	main = interact test
>	test s = show (check (lines s))
>	check = all (elem tab)
>	tab = toEnum 9

	Henry Jams?
	Hi, Retina!
	~

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. **Each line contains a tab character.**

---

**For future answers:**

* The first line is a palindrome of length 21.
* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.
* Its length is an even perfect square.
* It is at least 28 lines long.
* The last non-empty line does not have any duplicate characters.
* Contains the exact sequence `->`.
* Contains the exact strings `Hi, Retina!` and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains a tab character.
* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
> 5 votes

# Answer
# 27. GolfScript, 144 bytes

```
.		;'>-C+"1"+C->';		.
'
z
y
x
w
v
u
Hi, Retina!	Henry Jams?';;
t
s
r
q
o
m
l
k
j
i
h
g
f
e
d
c
b
n	/:^,27>^^^|=lynn
*	n~

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. **There are at least 28 lines, and they are all distinct.**

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and **all lines are distinct**.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".#$[\]` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* The program ends with: `tab`, *(whatever)*, `~`.
> 5 votes

# Answer
# 12. , 36 bytes

```
.1lllGYVH""pØHi, Retina!->üˆ.*±
Ø^0$

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. **The last non-empty line does not have any duplicate characters.**

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`.
* The last line non-empty line does not have any duplicate characters.
> 4 votes

# Answer
# 21. Alphuck, 676 bytes

*Surprisingly, most of the code is not padding.*

```
.11111111"1"11111111.
?|+->Hi, Retina!opaos
iipiiciasceaecppisaic
sapiceasccpisipiiiiia
ecsaiiijaeepiiiiiiaec
saeeejeepiiiaeecsajee
eeeepiaeecsaejipiiiii
iaecsaijeeeeeeeeeejii
iiiijiipiiiaecsaijiii
piaeeeecsaijeejiiijii
iiiiiiiiiiijiipiiiaec
saijiipiaeeeecsaejiii
iiiiiiijeeeeeejiiijpi
iaeeeeecsaeeejpiiaeee
eeeecsajeejiiijiiiiii
iijeeeeeeeeeeejeeepia
eeecsaeejeeeeeeeeeeee
jpiaeeeeecsaijepiaeee
csaeejeeeeeeeeejiiiii
iiiiijiipiiiaecsaiiij
epiiiiaecsaeeejiipiae
eeecsaijepiaeeecsaeje
eeeeeeeeeejiiiiiiiiii
iijiipiiiaecsaiijpiae
eecsaejipiaeeecsajiii
piaeeeecsajiiiiiiiiii
ijeeejiiiiiiiijejiipi
iiaecsajpHenry Jams?a
bcefghiwklmnopqrstuvw
xyzabcdefghwuklmnopqr
stuvwxyzabcdefg~

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.

---

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The first line is a palindrome of length 21.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.

---

* Its length is an even perfect square.
* It is at least 28 lines long.
* The last non-empty line does not have any duplicate characters.

---

* Contains the exact sequence `->`.
* Contains the exact strings `Hi, Retina!` and `Henry Jams?`.
* It contains `|` and `+`.

---

* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
> 4 votes

# Answer
# 26. Self-modifying Brainfuck (SMBF), 256 bytes

The third-to-last character must be a tab.

```
.1111111	"1"	1111111.
x
x
x
x
x
x
x
x	Hi, Retina!Henry Jams?C|xxxxxxxxxxxxxxxxxxxx
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x	<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
x	+>>>->>+>>->>+>>->>>>>>>>>>>+>>>>>->>->>>>
x	>,Z>,^<Z-^<Z-^<---------Z>+.>^
^	x~

```

Prints out `\x00` for truthy and outputs `\x00\x01` for falsey. Always terminates with an error due to an unmatched bracket. This prevents any input from being dynamically executed.

This program only works in the Python interpreter. **DOES NOT WORK ON TIO.** This is because the Python interpreter EOF is NUL.

To use the Python interpreter, paste this code into the line where the `data` is set. This had to be done, because TIO has no easy way to type or input NUL bytes, so I still use Ideone. Then uncomment `sys.stdin = MySTDIN("<[.<]")` and replace the custom input with whatever input you are testing against.

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.

---

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The first line is a palindrome of length 21.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.
* Its length is an even perfect square.
* It is at least 28 lines long.
* The ninth line must have at least 22 characters, excluding the newline.
* The last non-empty line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
* The third-to-last character is a tab.
> 4 votes

# Answer
# 28. Literate Haskell, 256 bytes

```
.	|+xx<<<"a"<<<xx+|	.

>	g x=elem '<'x&&e%x==e
>	e=tail(show 0)
>	('<':a)%('>':b)=a%b
>	a%('<':b)=('<':a)%b
>	a%('>':b)='<':e
>	a%(x:b)=a%b{->Hi, Retina!Henry Jams?-}
>	a@(_:_)%_=a
>	a%b=e

a
b
C
d
e
f
g
h
i
j
k
l
m
n
o
ppppppppp
q	3~

```

Try it online!

Test Driver

**Satisfies**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. There are at least 28 lines, and they are all distinct.
28. **There must be a `>` in the code and angle braces must be balanced**

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and all lines are distinct.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* `#$[\]` may not appear in the program.
* The program ends with: `tab`, *(whatever)*, `~`.
* **Angle braces must be balanced**
> 4 votes

# Answer
## 29. PHP with `-r`, 256 bytes

```
.6|0&"123'  '321"&0|6.
<
0
;
+
eval(
~
preg_replace
('Hi, Retina!'^'g5X|<J'
,
''
^'Henry Jams?'
,'×× ×  ×ÝÅÐÐÝÖÓÎÖÖÁÇÇÀ«Å¹ÖÄ'));?>->/45789:@ABCDEFGHIJKLMNOPQ
*
a
b
c
d
e
f
g
h
i
j
k
m
n
o   p~
```

Not being able to use `$` made this quite tricky, in my original solution I misunderstood the rule, but I think I have everything covered now. I've used high-byte characters, `~` and `eval` to work around the lack of decent variables for PHP. I nearly made the minimum number of unique code points 96, but I thought that might make it a little too hard for some languages.

Here's a reversible hex dump for verification too.

```
00000000: 2e36 7c30 2622 3132 3327 0927 3332 3122  .6|0&"123'.'321"
00000010: 2630 7c36 2e0a 2a09 0a30 090a 3b09 0a2b  &0|6..*..0..;..+
00000020: 090a 6576 616c 2809 0a7e 090a 7072 6567  ..eval(..~..preg
00000030: 5f72 6570 6c61 6365 090a 2827 4869 2c20  _replace..('Hi,
00000040: 5265 7469 6e61 2127 5e27 6735 587c 3c4a  Retina!'^'g5X|<J
00000050: 2709 0a2c 090a 2727 090a 5e27 4865 6e72  '..,..''..^'Henr
00000060: 7920 4a61 6d73 3f27 090a 2c27 9b96 9ad7  y Jams?'..,'....
00000070: 9c90 8a91 8bd7 9c90 8a91 8ba0 9c97 9e8d  ................
00000080: 8cd7 9996 939a a098 9a8b a09c 9091 8b9a  ................
00000090: 918b 8cd7 dd8f 978f c5d0 d08c 8b9b 9691  ................
000000a0: ddd6 d3ce d6d6 c1c7 c7c0 abc5 b9d6 c427  ...............'
000000b0: 2929 3b3f 3e2d 3e2f 3435 3738 393a 4041  ));?>->/45789:@A
000000c0: 4243 4445 4647 4849 4a4b 4c4d 4e4f 5051  BCDEFGHIJKLMNOPQ
000000d0: 090a 3c09 0a61 090a 6209 0a63 090a 6409  ..<..a..b..c..d.
000000e0: 0a65 090a 6609 0a67 090a 6809 0a69 090a  .e..f..g..h..i..
000000f0: 6a09 0a6b 090a 6d09 0a6e 090a 6f09 707e  j..k..m..n..o.p~

```

Try it online!

Test driver

**Satisfies**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. There are at least 28 lines, and they are all distinct.
28. There must be a `>` in the code and angle braces must be balanced.
29. **There must be more than 88 distinct code points in the program.**

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and all lines are distinct.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* `#$[\]` may not appear in the program.
* The program ends with: `tab`, *(whatever)*, `~`.
* Angle braces must be balanced.
* **There must be more than 88 distinct code points in the program.**
> 4 votes

# Answer
# 30. \>\<\> with `-v 0 -v 0`, 324 bytes

`1` is truthy, empty string is falsey

```
.1|-<<<<	"C"	<<<<-|1.
>i:0(?v'	'~
v     >}@@:'	'=0=?;@
v
     >:0(?va=?v&1+&>'	'~
>{r0&/    v   >&}0&^
          >&}rv
<
              >l3(?v@:}@@=?;{'	'~
                  ->1n;
Hi, Retina!
ABDEFGIKLMNOPQSTUVWXYZ
b	c
d
fg
h
jk
o
p	*      *  *
q	  *  *      *
u	*      *  *
w
xz
2
45
6
78	9
Henry Jams?%-	_~

```

**Try it online!**

**Satisfies**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. There are at least 28 lines, and they are all distinct.
28. There must be a `>` in the code and angle braces must be balanced.
29. There must be more than 88 distinct code points in the program.
30. **The third-to-last character is a tab (#26) AND adjacent lines must have different lengths**

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and all lines are distinct.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* `#$[\]` may not appear in the program.
* The program ends with: `tab`, *(whatever)*, `~`.
* Angle braces must be balanced.
* There must be more than 88 distinct code points in the program.
* **Adjacent lines must have different lengths**
> 4 votes

# Answer
# 32. Io, 256 bytes

New requirement: The codepoint sum has to be a perfect square, just like the bytecount.

(TBH it did take me a whole day to write a program that satisfies my new requirement, hope you enjoy this requirement!)

```
.1//	|+|?"'"?|+|	//1.
//Hi, Retina!	Henry Jams?
C	:= method(a
,	a sum sqrt %1== 0)
//	e@
//
//	?
//	{f
//	&FO`FC*EU/2345678XYZ^
//	B
//	DE
//	F
//	Gh
//	Ig
//	JKh
//	L
//	MN
//	O
//	PQ
//	jklm
//	ST
//	bci
//	V
~	:=9;
//	Apqrstuvwxyz{}
//	defgh
//	<->
	 ~

```

Try it online!

2. It starts with a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. There are at least 28 lines, and they are all distinct.
28. There must be a `>` in the code and angle braces must be balanced.
29. There must be more than 88 distinct code points in the program.
30. The third-to-last character is a tab (#26) AND adjacent lines must have different lengths
31. All printable ASCII characters that are not previously forbidden must be part of the code. The complete list is:  `!"%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~`

**32. The codepoint sum must be a perfect square.**

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and **all lines are distinct**.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* `#$[\]` may not appear in the program.
* The program ends with: `tab`, *(whatever)*, `~`.
* Angle braces must be balanced.
* There must be more than 88 distinct code points in the program.
* Adjacent lines must have different lengths
* It contains all printable ASCII that are not previously forbidden. The characters are:  `!"%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~`.
* The codepoint sum is a perfect square.
> 3 votes

# Answer
# 1. Add++, 7 bytes

```
D,f,@,1

```

Try it online!

Might as well get Add++ in before things start getting difficult. This is very simply a translation of the first example into Add++. `D,f,@,1` defines a function which, no matter the argument given, returns `1`.
> 2 votes

# Answer
# 4. Stacked, 10 bytes

```
.3[#'even]

```

Try it online!

Checks if the length of the program is even. Anonymous function which returns `1` for "true" inputs and `0` for "false" ones.

**Satisfies:**

2. starts with a `.`
3. contains an `e`
4. has an even length
> 2 votes

# Answer
# 24, SNOBOL4 (CSNOBOL4), 256 bytes

```
.;*->+|a	"x"	a|+>-*;.
	x =input
	x =input
	x =input
	x =input
	x =input
	x =input
	x =input
	x =input;* Henry Jams?
	X =INPUT
	OUTPUT =GT(SIZE(X),21)	1

end
	ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234
	Hi, Retina!
	~

```

Try it online!

Prints out `1` for truthy and outputs nothing for falsey.

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.

---

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The first line is a palindrome of length 21.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.
* Its length is an even perfect square.
* It is at least 28 lines long.
* The ninth line must have at least 22 characters, excluding the newline.
* The last non-empty line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* It contains `|`, `+` and `C`.
* Each line contains a tab character.
* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
> 2 votes

# Answer
# 2. Triangularity, 17 bytes

```
..)..
.)Im.
"."=.

```

Try it online!

Checks whether the first character is a dot (`.`).
> 1 votes

# Answer
# 3. Jelly, 5 bytes

```
.
”ee

```

Try it online!

Checks whether the input contains a `e` character. Changed from  to `e` because that seemed unfair to languages without that character. And, to verify, here's a hexdump:

```
00000000: 2e0a ff65 65                             ...ee

```

**Satisfies:**

2. Starts with a `.`
3. Contains an `e`
> 1 votes

# Answer
# 6. Pyth, 16 bytes

```
.e}\as.zS13    5

```

Try it here!

Checks if the input contains an `a`. Outputs either:

* `[True, True, True, True, True, True, True, True, True, True, True, True, True]` for truthy
* or `[False, False, False, False, False, False, False, False, False, False, False, False, False]` for falsy

**Satisfies:**

2. starts with a `.`
3. contains an `e`
4. has an even length
5. has a perfect square length
6. contains an `a`
> 1 votes

# Answer
# 7. Whispers, 66 bytes

```
.abcdefghijklmnopqrstuvwxyz
> ">"
> InputAll
>> 1∈2
>> Output 3

```

Try it online!

Outputs either `True` or `False`. Note the trailing new line.

**Satisfies:**

2. The first character is a `.`
3. It contains an `e`
4. Its length is even
5. Its length in characters is a perfect square
6. It contains an `a`
7. It contains a `>` character
> 1 votes

# Answer
# 8. , 64 bytes

```
.0->z;x=readLines();y=Vectorize(utf8ToInt)(x);any(grepl("->",x))

```

Try it online!

Satisfies:

2. The first character is a `.`
3. It contains an `e`
4. Its length is even
5. Its length is a perfect square
6. It contains an `a`
7. It contains a `>` character
8. Contains the exact sequence `->` in one of its lines.
> 1 votes

# Answer
# 10. Somme, 64 bytes

```
.1->Hi, Retina! I like French :D
"RVll;d.h:and random stuff too!

```

Try it online!

**Verify it online!**

**Satisfies:**

2. The first character is a `.`
3. It contains an `e`
4. Its length is even
5. Its length is a perfect square
6. It contains an `a`
7. It contains a `>` character
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.

**For future answers:**

* The first character is a `.`
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
> 1 votes

# Answer
# 15. Python 3, 64 bytes

```
.1and(11*"""*11(dna1.
Hi, Retina!->   """)and(lambda s:"?"
in s)

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`.
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length = 21
* It contains a `?`.
> 1 votes

# Answer
# 16: Quarterstaff, 64

1 is truthy,

```
.1......."a".......1.
   1->a[Hi, Retina!]
  ?[-124(.|>a)?]
49a!

```

Try it online!

the indentation doesn't do anything, by the way.

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`, and so is the twelfth character (palindromic rule).
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length = 21
* It contains a `?`.
* It contains a `|`
> 1 votes

# Answer
# 18. Python 3, 144 bytes

```
.6;"ea->?"#"?>-ae";6.
"Hi, Retina!"
import sys
print(len(sys.stdin.read().split("\n"))>26+1)

"|||||"
4.2

```

Try it online!

Outputs `True` if the input is at least 28 lines long, `False` otherwise.

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.

**For future answers:**

* The first character is a `.`.
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The 10-th character is a `"`, and so is the twelfth character (palindromic rule).
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length = 21
* It contains a `?`.
* It contains a `|`.
* It contains a `+`.
* It is at least 28 lines long.
> 1 votes

# Answer
# 31. Octave, 324 bytes

New requirement: All printable ASCII that are not previously forbidden must be part of the code. The complete list is:  `!"%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~`.

```
.6;%+<-?|"	"|?-<+%;6.
f=@(x)all(ismember(horzcat(33,34,46,' %&''()*+,=/0123456789:;<->?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~'),x));
%	>>
%	V'quQ9g8u'@f/&'A)eLS;p`t'{ZYv4R3aaa
%	bb
%	c
%	dd
%Henry Jams?Hi, Retina!
%	e
%	ff
%	g
%	hh
%	i
%	jj
%	k
%	ll
%	m
%	nn
%	o
%	pp
%	q
%	rr
%	s
%	tt
%	u
%	vvv
%	a~

```

Try it online!

2. It starts with a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`
23. Each line contains a tab character.
24. The ninth line contains at least 22 characters, excluding the newline.
25. The tab character can't be the first character on a line
26. The third-to-last character is a tab.
27. There are at least 28 lines, and they are all distinct.
28. There must be a `>` in the code and angle braces must be balanced.
29. There must be more than 88 distinct code points in the program.
30. The third-to-last character is a tab (#26) AND adjacent lines must have different lengths
31. All printable ASCII characters that are not previously forbidden must be part of the code. The complete list is:  `!"%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~`

---

**For future answers:**

* The first line is a palindrome matching `.␣␣␣␣␣␣␣␣"␣"␣␣␣␣␣␣␣␣.` (you are free to fill in the ␣s).
* The second character is one of `',16;`, or a tab, or one of `\x04\x0e\x13\x18\x1d`.
* Its length is an even perfect square.
* There are at least 28 lines, and **all lines are distinct**.
* The ninth line must have at least 22 characters (excluding the newline).
* The last line does not have any duplicate characters.
* Contains the exact strings `->`, `Hi, Retina!`, and `Henry Jams?`.
* Each line contains at least one tab character, but it can't be the first character on a line.
* `!".` are banned except where necessary:
    + Only `!` in `Hi, Retina!` and the two `.` and two `"` in the first line are allowed.
* `#$[\]` may not appear in the program.
* The program ends with: `tab`, *(whatever)*, `~`.
* Angle braces must be balanced.
* There must be more than 88 distinct code points in the program.
* Adjacent lines must have different lengths
* It contains all printable ASCII that are not previously forbidden. The characters are:  `!"%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~`.
> 1 votes

# Answer
# 17, Whitespace, 100 bytes

```
.|?|?|?|?"+"?|?|?|?|.
Hi, Retina!->

 abcdefgh

```

I guess the perfect language for this challenge, and I might post more when the chain has progressed.

Try it online.

Outputs `1` if the input contains a `+`, or nothing otherwise.

I created a script to check all the characters the previous answers didn't contain yet, and `+` was the first one, so I've used that as a validation for my answer. My program also returns true in the TIO-links of all previous answers (except in X86 Assembly (gcc 6.3) where I got an error.., although my answer does satisfy to all the rules of the previous answers).

**Satisfies / For future answers:**

* The first and twenty-first characters are `.`.
* Its length is even and a perfect square.
* Contains the exact string `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4.
* The tenth and twelveth characters are `"`.
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length 21.
* It contains a `?`.
* It contains a `|`.
* **It contains a `+`.**

---

**Explanation:**

In Whitespace, every character except for spaces, tabs and new-lines are ignored. Here is the base program with just the spaces, tabs and new-lines:

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

```
[N
S S N
_Label_LOOP][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S S S T  S S S S S N
_Push_43][T S S T   _Subtract][N
T   S S N
_Jump_to_Label_TRUE_if_0][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_TRUE][S S S T N
_Push_1][T  N
S T _Print_as_integer][N
S N
S _Jump_to_Label_EXIT]

```
> 0 votes

# Answer
# 19, Octave, 196 bytes

<sub>Note: I made an edit to the code, to fix an error. The only change was to include the palindrome rule. This avoids a false positive for answer 10.</sub>

---

Most requirements up until now can easily be circumvented using comments and suppressed strings, making it trivial to add answers. I figured I'd make it a bit harder by **disallowing** some characters instead.

```
.6;%+->?|"e"|?>-+%;6.
f=@(x)all(ismember('Hi, Retina!',x))&sum(ismember(x,cat(2,33:36,46,91:93,'')))<6&x(2)<60&all((k=x(1:find(x==10,1)-1))==flip(k))
%

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60.
* The 10-th character is a `"`, and so is the twelfth character (palindromic rule).
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length = 21
* It contains a `?`.
* It contains a `|`.
* It contains a `+`.
* It is at least 28 lines long.
* The following characters can only be used five times in total: `!"#$.[\]`.
    + Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
> 0 votes

# Answer
# 20. Jelly, 100 bytes

This code checks whether or not `Henry Jams?`. Returns `1` for truthy, `0` for falsy.

```
.6;%+->?|"e"|?>-+%;6.
Hi, Retina!->0123456789
0123456789
0123

“Henry Jams?”ẇ

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* Its length is an even perfect square.
* Contains the exact sequence `->`.
* Contains the exact string `Hi, Retina!`.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60.
* The 10-th character is a `"`, and so is the twelfth character (palindromic rule).
* The last non-empty line does not have any duplicate characters.
* The first line is a palindrome of length = 21
* It contains a `?`.
* It contains a `|`.
* It contains a `+`.
* It is at least 28 lines long.
* The following characters can only be used five times in total: `!"#$.[\]`.
    + Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
* Each program must contain `Henry Jams?` as a continuous substring.
> 0 votes

# Answer
# 22, Octave, 100 bytes

Executive summary: There must now be an uppercase `C` in the code.

```
.6;%+->?|"e"|?>-+%;6.
'Hi, Retina!Henry Jams?';
f=@(x)any(x=='C');
%Any C?

%~

```

Try it online!

**Satisfies:**

2. The first character is a `.`.
3. It contains an `e`.
4. Its length is even.
5. Its length is a perfect square.
6. It contains an `a`.
7. It contains a `>` character.
8. Contains the exact string `->`.
9. Contains the exact string `Hi, Retina!`.
10. The sum of the first two Unicode code points is a multiple of 5.
11. The 10-th character is a `"`.
12. The last non-empty line does not have any duplicate characters.
13. The first line is a palindrome of length \> 5.
14. The first line is exactly 21 characters long (not including newline).
15. It contains a `?`.
16. It contains a `|`.
17. Contains a `+`.
18. It is at least 28 lines long.
19. The following characters are used five times in total: `!"#$.[\]` and the codepoint of the second character is less than 60.
20. Contains `Henry Jams?` as a continuous substring.
21. The last character is `~`.
22. It contains a `C`

---

**For future answers:**

* The first character is a `.`, and so is the 21st character (palindromic rule).
* The 10th character is a `"`, and so is the 12th character (palindromic rule).
* The first line is a palindrome of length 21.
* The second character's Unicode code point, mod 5, is 4, **and** its code point is lower than 60 (the printables are `',1;6` and tab).
* The last character is `~`.

---

* Its length is an even perfect square.
* It is at least 28 lines long.
* The last non-empty line does not have any duplicate characters.

---

* Contains the exact sequence `->`.
* Contains the exact strings `Hi, Retina!` and `Henry Jams?`.
* It contains `|`, `+` and `C`.

---

* Each program is now allowed only the 2 `.` and 2 `"` in the first line, and the `!` in `Hi, Retina!`. Those characters cannot be used anywhere else, in addition to no uses of `#$[\]`.
> 0 votes

---
Tags: decision-problem, restricted-source, answer-chaining
---


# Question
Title: You Are the User: Create the Requirements
My boss\* does not understand why her programmers react negatively to users changing program requirements. Help her understand! On every answer, create a new requirement. Then, write a program/function that solves that requirement and all prior requirements, while in a new programming language.

# Examples

User 1 posts the first answer. He specifies that the program must output "Hello, World." He creates a program in Java that outputs "Hello, World."

User 2 posts the second answer. She specifies that the program must accept input *n* and output the *n*th prime, up to the language's number max. She creates a program in C++ that accepts input *n* and outputs the *n*th prime and outputs "Hello, World." She could not have created a program in Java.

User 3 posts the third answer. He specifies that the program source cannot contain the text "Hello". He creates a function in Python that accept input *n* and outputs the *n*th prime and "Hello, World." while not using the text "Hello" in his source. He could not have created a program in Java or C++.

# Answer Format

```
#Answer # - <language name> [version, if pertinent]

Requirement: <rule>.

<code>

[explanations, encoding, TIO link, etc.]

```

# Answer Rules

* The answer must follow the above format, or similar.
* The answer can be a program or a function.
* The answer must fulfill all requirements up to and including the current answer.
* The same user may not post two answers in a row.
* If two answers are posted with the same number, the one posted later should be deleted.
* Do not edit your requirement unless you messed up badly **and** no other answers have been posted.
* If your answer does not comply with your rule and all other rules, it is invalid. Try to fix this before someone else posts the next answer.
* Different versions of the same language only count as different languages **if** the program or function created in either version will behave differently in the other version.
* The answer may not accept any input not required, and may not output anything not required except for necessary whitespace. However, while behind the scenes the program must fulfill all "hidden" (from the user) requirements, it may do whatever else you want it to, especially if you must fulfill an execution time requirement.

# Requirement Rules

* The requirement must only specify one requirement. This requirement can be conditional, and if this requirement requires an input and/or an output, this may be included.
* The requirement may not remove or modify prior requirements, or conflict with them, but may extend one (specify which).
* If the requirement restricts the source (), or requires text in the source, it may only remove a single string (e.g. `0`, `Hello`), or require a single character.
* The requirement cannot require the source to be under 100 bytes, require a specific encoding, or, in and of itself, rule out a majority of common languages.
* The requirement may not force the source to conform to a certain pattern (for example, starting each line with a certain character, or (@Conor) hashing to a certain value) other than that specified in restricted source.

This is , so all answers build on previous answers. I and maybe others will try to keep a list of all requirements. To see answers in order, you can sort by oldest. To see the newest answer, sort by oldest, then navigate to the end of the list.

# How to Win (changed for hold vote):

When no answer is posted for two weeks, the challenge is over, and scores will be calculated. The scores will be calculated by summing the totals number of answers by each user, but weighting posts based on how far into the chain they are (since the later posts have more requirements, they are harder).

Pseudocode:

```
for each answer in user.Answers {
   score += 1 + (answer.number / 100)
}

```

Example:

Sally has three answers. She posted answer 5, answer 7, and answer 20.

Her score will be `1.05 + 1.07 + 1.2 = 3.32`. If it was a straight sum of answers, her score would be 3, but the weighting of chain depth rewards harder answers.

# To start:

Here is the first requirement, given by my boss\*:

Requirement 0: The program must output 0 before anything else.

\*fictional

# List of Requirements and Languages

Note that this may be out of date - please look at the last posted answer immediately prior to posting your answer to ensure you are fulfilling every requirement. I am very sorry if you create an exquisite program, only for someone to snipe it - if you really really want to post it anyway, specify non-competing.

> Full (but maybe not current) Requirement: Cannot contain `0`, `*` or `]` in the source code, and cannot use a join-on-newline builtin. Outputs `0`, then takes a non-negative integer input `n` and outputs a newline followed by the 0-indexed `n`th Fibonacci number (may be `1` indexed), followed by a newline, followed by the same input n squared, followed by a newline, followed by `n` multiplied by a new input `m`, followed by a newline, followed by `10^B`, where `B` is the number of bytes in the source code, followed by a newline, followed by the `n`th `0`-indexed (may also be `1`-indexed) prime number, followed by a newline, followed by the Greatest Common Divisor of n and m.
>
> 0: The program must output `0` before anything else. **Language: N/A**
> 1: The program source cannot contain `0`. **Language: 05AB1E**
> 2: The program takes a non-negative integer input `n` and outputs a newline followed by the `0`-indexed n'th Fibonacci number (may be `1` indexed). **Language: dc**
> 3: The program outputs a newline, followed by the same input `n` squared. **Language: J**
> 4: The program outputs a newline, followed by `n` multiplied by a new input `m`. **Language: Ohm**
> 5: The program cannot contain `*` (ASCII code `0x2A`). **Language: Python 3**
> 6: The program outputs a newline, followed by `10^B`, where `B` is the number of bytes in the source code. **Language: Mathematica**
> 7: The program outputs a newline, followed by the `n`th `0`-indexed (may also be `1`-indexed) prime number. **Language: JavaScript (ES6)**
> 8: The program does not use a join-on-newlines builtin, but can use any other join builtin. **Language: Jelly**
> 9: The program outputs a newline followed by the Greatest Common Divisor of n and m. **Language: Scala**
> 10: The program cannot contain `]`. **Language: Pyth**

# Current Scores (ordered by first post)

> **Okx**: 1.01
> **R. Kap**: 2.09
> **Conor O'Brien**: 1.03
> **Nick Clifford**: 1.04
> **Eric Rose**: 1.05
> **Greg Martin**: 1.06
> **Erik the Outgolfer**: **2.18**
> **math\_junkie**: 1.09

# Answer
# Answer 10 - Pyth

Requirement: Takes two inputs, `n` (\>=0) and `m`. *Outputs* `0` without the use of `0`, `*` or `]` anywhere in the source code, and without builtins for joining on newlines. Then outputs a newline followed by the `1`-indexed nth Fibonacci number (may be `0` indexed), followed by a newline, followed by `n` squared, followed by a newline, followed by `n` multiplied by `m`, followed by a newline, followed by `10^B` where `B` is the number of bytes in the source code, followed by a newline and the `n`th `1`-indexed (may also be `0`-indexed) prime number, and finally followed by a newline and the Greatest Common Divisor of n and m.

```
JU2KE=H2VQ=+Js>2J=+YK=hHW!P_H=hH;jb[ZeJ^Q2sY^T51HiK

```

Online interpreter
> 4 votes

# Answer
# Answer 1 - 05AB1E

Requirement: Prints `0`... without a `0` in the source code

```
¾

```
> 7 votes

# Answer
# Answer 5 - Python 3

**Requirements:** Outputs 0 without 0 in the source code, then takes a non-negative integer input n and outputs a newline followed by the 0-indexed nth Fibonacci number (may be 1 indexed), followed by a newline, followed by the same input n squared, followed by a newline, followed by n multiplied by a new input m. Do not use the character `*`, ASCII code `0x2A`.

```
def f(n, m):
    print(1-1)
    a = 1-1
    b = 1
    for i in range(n):
        c = a+b
        a = b
        b = c
    print(b)
    print(n.__mul__(n))
    print(n.__mul__(m))

```
> 7 votes

# Answer
# Answer 2 - dc

```
12298P?sa1 1-sb1sc[lblcdsb+scla1-dsa1 1-<y]dsyxlcp

```

**Requirement:** Outputs `0` without `0` in the source code, then takes a non-negative integer input `n` and outputs a newline followed by the `0`-indexed `n`'th Fibonacci number (may be `1` indexed).

Try it online!
> 5 votes

# Answer
# Answer 3 -

```
echo"+(1-1),(*:,~[:+/@:!&i.-)@".1!:1(3)

```

Requirement: Outputs `0` without `0` in the source code, then takes a non-negative integer input `n` and outputs a newline followed by the `0`-indexed `n`'th Fibonacci number (may be `1` indexed), followed by a newline, followed by the same input `n` squared.

Try it online!
> 5 votes

# Answer
# Answer 4 — Ohm

Requirement: Outputs `0` without `0` in the source code, then takes a non-negative integer input `n` and outputs a newline followed by the 0-indexed `n`th Fibonacci number (may be 1 indexed), followed by a newline, followed by the same input n squared, followed by a newline, followed by `n` multiplied by a new input `m`.

```
¼,≡ƒ,²,*,

```
> 5 votes

# Answer
# Answer 6 — Mathematica

Requirement: Outputs 0 without 0 or * in the source code, then takes a non-negative integer input n and outputs a newline followed by the 0-indexed nth Fibonacci number (may be 1 indexed), followed by a newline, followed by the same input n squared, followed by a newline, followed by n multiplied by a new input m, followed by a newline, followed by 10^B where B is the number of bytes in the source code.

```
((e=Echo)[1-1];e@Fibonacci@#;e[#^2];e[1##];2^# 5^#&@59)&

```
> 5 votes

# Answer
# Answer 7 - JavaScript (ES6)

```
(a,b)=>String.fromCharCode(48)+'\n'+(m=(a)=>a>1?m(a-1)+m(a-2):1)(a)+'\n'+Math.pow(a,2)+'\n'+Math.exp(Math.log(a)+Math.log(b))+'\n'+1E257+'\n'+(T=(u,i=2,l=1-1,m=2)=>l<=u?(p=(o,z=2,s=1-1)=>z<o?p(o,z+1,s+(o%z<1&&z!=o)):s)(i)<1?T(u,i+1,l+1,i):T(u,i+1,l,m):m)(a)

```

**Requirement:** A function that takes two inputs, a non-negative integer `n` and any number `m` and *returns* a string containing `0` without the use of `0` anywhere in the source code, then a newline followed by the `0`-indexed `n`th Fibonacci number (may be `1` indexed), followed by a newline, followed by `n` squared, followed by a newline, followed by `n` multiplied by `m` without the use of `*` anywhere in the source code, followed by a newline, followed by `10^B` where `B` is the number of bytes in the source code, and finally followed by a newline and the `n`th `0`-indexed (may also be `1`-indexed) prime number.

## Test Snippet

```
S=(a,b)=>String.fromCharCode(48)+'\n'+(m=(a)=>a>1?m(a-1)+m(a-2):1)(a)+'\n'+Math.pow(a,2)+'\n'+Math.exp(Math.log(a)+Math.log(b))+'\n'+1E257+'\n'+(T=(u,i=2,l=1-1,m=2)=>l<=u?(p=(o,z=2,s=1-1)=>z<o?p(o,z+1,s+(o%z<1&&z!=o)):s)(i)<1?T(u,i+1,l+1,i):T(u,i+1,l,m):m)(a)
```

```
m: <input type="number" min=0 id="i1"></input>
<br>
n: <input type="number" step="0.01" id="i2"></input>
<br>
<input type="button" value="Submit" onclick="console.log(S(document.getElementById('i1').value, document.getElementById('i2').value))"></input>
```
> 4 votes

# Answer
# Answer 8 - Jelly

Requirement: A function that takes two inputs, a non-negative integer `n` and any number `m` and *returns* a string containing `0` without the use of `0` anywhere in the source code, then a newline followed by the `0`-indexed `n`th Fibonacci number (may be `1` indexed), followed by a newline, followed by `n` squared, followed by a newline, followed by `n` multiplied by `m` without the use of `*` anywhere in the source code, followed by a newline, followed by `10^B` where `B` is the number of bytes in the source code, and finally followed by a newline and the `n`th `0`-indexed (may also be `1`-indexed) prime number. No builtins for joining on newlines allowed, but joining builtins still allowed.

```
ÆḞṭØDW⁺¤;⁸²¤;×;ȷ25;⁸ÆN¤j⁷

```

Try it online!
> 3 votes

# Answer
# C (gcc), submission #11, 432 bytes

```
n,m,z,c,q,a,s,t;A(a,b){return b?A(b,a%b):a;}B(n){if(n<=1)return 1-1;for(int i=2;i<n;i++)if(n%i==1-1)return 1-1;return 1;}C(n,c,z){while(c<n){if(B(z++))c++;}return z-1;}D(n){return(!n||n==1)?n:(D(n-1)+D(n-2));}main(){putchar(48);scanf("%d",&n);t=s=n;while(--t)s+=n;printf("\n%d\n%d\n",D(n),s);scanf("%d",&m);q=A(n, m);a=n;while(--m-1)n+=n;printf("%d\n",n);putchar(49);for(z=0;z<432;z++)putchar(48);printf("\n%d\n%d",C(a,1-1,1-1),q);}

```

I hereby ban line endings appearing anywhere in the source code :v).

Try it online!
> 3 votes

# Answer
# Answer 9 - Scala

**Requirements**: Takes two inputs, `n` (\>=0) and `m`. Outputs `0` without the use of `0` or `*` anywhere in the source code, and without builtins for joining on newlines. Then outputs a newline followed by the `1`-indexed nth Fibonacci number (may be `0` indexed), followed by a newline, followed by `n` squared, followed by a newline, followed by `n` multiplied by `m`, followed by a newline, followed by `10^B` where `B` is the number of bytes in the source code, followed by a newline and the `n`th `1`-indexed (may also be `0`-indexed) prime number, and finally followed by a newline and the Greatest Common Divisor of n and m.

```
(n:Int,m:Int)=>{
 val z=1-1;val o=println _;var i=1;var j=z
 o(z)
 o((1 to n).foldLeft(z,1)((a,b)=>(a._2,a._1+a._2))._1)
 o(math.pow(n,2))
 o(List.fill(n)(m).sum)
 o(math.pow(9+1,299))
 while(j!=n){i+=1;if((2 to i-1)forall(i%_!=z))j+=1};o(i)
 o((1 to math.min(n,m)).filter(c=>n%c==z&&m%c==z).last)
}

```

Try it out here
> 2 votes

---
Tags: answer-chaining
---


title: Count The Genus

text:
# Question
Title: Count The Genus
# Objective

Given a matrix of **connected** box drawing characters, count its genus, the number of plane sections it encloses.

# Valid input

The box drawing characters are `─│┌┐└┘├┤┬┴┼╴╵╶╷` (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these characters only, along with unique "nothing" value that represents a blank.

The input may also be a string with box drawing characters, whitespaces, and line feeds. You cannot mix different types of whitespaces, or different types of line feeds. Trailing whitespaces and line feeds are permitted.

# Rule

Invalid input falls in *don't care* situation. In particular, you don't need to handle any input having multiple connected components, e.g.

```
# this
┌─┐┌─┐
└─┘└─┘
# or this
┌───┐
│┌─┐│
│└─┘│
└───┘

```

# Examples

For font issues, every example is presented using normal spaces (U+0020) once and ideographic spaces (U+3000) once.

## Genus 0

```
# Using U+0020 space
┤ ╷
└─┘

┌┼┐
 ─┴

# Using U+3000 space
┤　╷
└─┘

┌┼┐
　─┴

```

## Genus 1

```
# Using U+0020 space
┌─┬
│ │
└─┘

┼┬─┬
╵│ │
└┴─┘

# Using U+3000 space
┌─┬
│　│
└─┘

┼┬─┬
╵│　│
└┴─┘

```

## Genus 2

```
# Using U+0020 space
┼┼┼┼
 ┼┼┼

# Using U+3000 space
┼┼┼┼
　┼┼┼

```

# Answer
> 6 votes
# APL (Dyalog Extended), 73 bytes

```
1-1⊥∘(∊∨/¨⍮2(-⊃⍤∧∘⌽/⍮(3⊃∧∘⌽)⌿)⊢)(⊂4⍴2)⊤¨(9467+⎕AV⍳'ð{dòlxõ _0h8p∆')⍳⎕UCS

```

Try it online!

Over half of the bytes were used in converting the char matrix into an easier-to-use format. Basically, converts each box-drawing char into `[right, up, down, left]`, counts non-blanks and joints, and computes `1 - non-blanks + joints`.

This works because of Euler characteristic `V - E + F = 1` (not counting the surrounding area as a face), thanks to the assumption that the entire figure is connected. If we count any segment starting from the center to some boundary as an edge (and the respective endpoints as vertices), every non-blank char has `V - E = 1`, but the `V` in the entire shape is reduced by the number of joints. Plugging into the rearranged equation `F = 1 - V + E` gives the above formula `1 - non-blanks + joints`.

# Answer
> 5 votes
# Retina, 131 bytes

```
T`─┐┬╴┼┤┴┘│╵└├┌╶╷`L
(?=(.)*[BCEFILMO].*¶(?>(?<-1>.)*)[E-L])
-
(?=[ACEGK-N]-?[A-H])|^
-
+`-\s*\w

C`-

```

Try it online!

TIO counts the box drawing characters as only one byte even though they are not ASCII (the Retina code page).

## How?

This uses a rearranged Euler characterstic `F=1+E-V` to find the number of faces under the assumption that there is only one connected component.

The number of vertices, `V`, is the same as the number of box characters.

There is +1 edge for every horizontally adjacent pair of box characters where the first has a right edge and the second has a left edge. There is +1 edge for every vertically adjacent pair of box characters where the first has a down edge and the second has a up edge. This is harder to express in regex, so I borrowed the method of standard vertical matching to deal with vertical edges.

```
# Translate each of the box characters into letters to avoid repeating them
# We do this smartly:
# ─┐┬╴┼┤┴┘        correspond to A-H and all have a left edge
#     ┼┤┴┘│╵└├    correspond to E-L and all have an up edge
#           └├┌╶  correspond to K-N and all have a right edge
T`─┐┬╴┼┤┴┘│╵└├┌╶╷`L
# Prepend a '-' to the first character of a vertically adjacent pair with (down edge, up edge)
# Each '-' will represent one edge
(?=(.)*[BCEFILMO].*¶(?>(?<-1>.)*)[E-L])
-
# Prepend a '-' to the first character of a horizontally adjacent pair with (left edge, right edge)
# Simply pass over '-' from the previous step using -?
# |^: also prepend an extra '-', which counts as an extra edge, to the beginning of the whole string for the +1
(?=[ACEGK-N]-?[A-H])|^
-
# Now there is a - for each edge and a capital letter for each vertex, with some whitespace
# Compute #(edges) - #(capital letters)
# Until the output is constant:
# Replace an edge and a capital letter with the empty string (`\s*` to pass over whitespace)
+`-\s*\w

# Count the number of `-`s
C`-

```

# Answer
> 2 votes
# Charcoal, 100 bytes

```
ＷＳ⊞υιＢ×³⊕Ｌθ×³⊕ＬυψＦυ«⸿⸿⸿Ｆι«Ｍ³→Ｆ⁴¿＆Ｘ²λ⍘§”E←T¹÷S1²m[ω→℅P”﹪℅κ⊕⊘φφＰ✳⊗λ²»»≔⁰ηＦＬθＦＬυ«Ｊ×³ι×³κ↘≧⁺¬℅ＫＫη¤#»⎚Ｉ⊖η

```

Try it online! Link is to verbose version of code. Takes input as a newline-terminated rectangular character array. While I could have written a version that uses the Euler characteristic, I felt that I should really write a version using all of Charcoal's power to calculate the number of regions in any shape. Explanation:

```
ＷＳ⊞υι

```

Input the shape.

```
Ｂ×³⊕Ｌθ×³⊕Ｌυψ

```

Draw an empty box large enough to completely enclose the shape at three times scale.

```
Ｆυ«⸿⸿⸿Ｆι«Ｍ³→

```

Loop over each character of the input, positioning the cursor at the appropriate position.

```
Ｆ⁴¿＆Ｘ²λ⍘§”E←T¹÷S1²m[ω→℅P”﹪℅κ⊕⊘φφＰ✳⊗λ²

```

Loop over each direction, looking up the box lines based on taking the ordinal of the character modulo 501 and 23 (the latter automatically via Charcoal's cyclic indexing) in a table of hex digits (and `g`s for filler), drawing a line for each matching bit in the digit, thus drawing the original shape at triple size.

```
»»≔⁰η

```

Start with no regions.

```
ＦＬθＦＬυ«

```

Loop over each character.

```
Ｊ×³ι×³κ↘

```

Jump to the upper right of the character.

```
≧⁺¬℅ＫＫη

```

Increment the region count if it's empty.

```
¤#

```

And then try to fill it anyway.

```
»⎚Ｉ⊖η

```

Print one less then the resulting count (since this procedure counts the outside too).

---
Tags: code-golf, math, unicode, topology
---


title: Writing erasable code

text:
# Question
Title: Writing erasable code
My phone number (which I will not be sharing here) has a neat property where there is a two digit number, which when iteratively removed from my phone number will eventually remove all the digits. For example if my phone number were

```
abaababbab

```

Then by repeatedly removing `ab` we would eventually get nothing (I encluse the string I am removing in brackets to make it clear)

```
abaababb[ab]
abaab[ab]b
aba[ab]b
ab[ab]
[ab]

```

Now to generalize this property lets have any string. A "minimal eraser" of that string will be the smallest substring such that if iteratively removed it will eventually make the string empty.

Some examples at the bottom.

# Task and Scoring

*Warning: This challenge is not . Do not assume it is without reading the scoring*

Your challenge will be to take a string as input and output a minimal eraser of that string.

Your answers will be scored by taking them as a string of bytes and calculating that string's minimal eraser. The length in bytes of that eraser is your score, with lower being better.

Your answer must support strings containing all printable ascii plus any characters that appear in your program.

# Test cases

```
abaababbab -> ab
baababbab -> baababbab
baababab -> baababab
echoecho -> echo
ototoo -> oto
ibiibibii -> ibi
aabaabaa -> abaa / aaba

```

# Answer
# Python 3, score <sup>~~... 48~~ ~~29~~ </sup> 20

```
+1,eval(bytes([57]))

```

A completely different approach from the last 2 versions (and also result in manageable generated program). Check out the revision history for some (possibly) interesting ideas.

---

Given an arbitrary Python program:

```
print(1)

```

it can be transformed, without changing the behavior:

```
exec("print(1)")

```

```
eval(rb'exec("print(1)")')

```

```
eval(bytes([101, 120, 101, 99, 40, 34, 112, 114, 105, 110, 116, 40, 49, 41]))

```

The number list is getting long, so I'll use a shorter list for demonstration. Note that only printable ASCII characters can appear in the string representation and the first character is `e`, so the first number is 101 and all numbers are at least 32.

```
eval(bytes([101, 32, 32]))

```

Rewrite the first number to `57+1+1+1+...+1+1+1`, the rest into `9+1+1+...+1`; then add some `,9` at the end of the list. This is always possible because of the conditions mentioned before, and the program's behavior is unchanged because **the byte `9` is `\t`, a whitespace character**.

```
eval(bytes([57+1+1+...+1, 9+1+1+...+1+1, 9+1+1+...+1, 9, 9,..., 9]))

```

The number of `,9` added must satisfy that **the total number of `9`s is equal to the number of `+1`**.

Then replace all the `9` with `eval(bytes([57])`, and prepend `+1,`.

```
+1,eval(bytes([57+1+1+...+1,eval(bytes([57])+1+1+...+1+1,eval(bytes([57])+1+1+...+1,eval(bytes([57]),eval(bytes([57]),...,eval(bytes([57])]))

```

Done! It's easy to see that this string has the eraser string `+1,eval(bytes([57])`.

---

It's trivial to see that there exists a Python snippet that solves the given problem.

```
g=lambda s, e: not s or any(
	s[i:].startswith(e) and g(s[:i]+s[i+len(e):], e)
	for i in range(len(s)-len(e)+1))
f=lambda s: min((s[i:j] for j in range(len(s)+1) for i in range(j) if g(s, s[i:j])), key=len)
print(f(input()))

```

Try it online!
> 13 votes

# Answer
# Brachylog, 23 bytes, score 23

Rather boring, as it doesn't have a non-trivial eraser.

```
{|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh

```

Try it online! or verify the other test cases (split in two, so TIO doesn't time out.)

### How it works

```
{|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh
{                 }ᶠ     Find all outputs for the implicit input, that …
 |                        either is itself or …
  ~c₃                     split into three groups in every possible way
                           [,,AAABBB],[,AA,AABB],[AAA,B,BB],[AA,AB,BB] etc. …
     ↺↔                    with the middle moved to the back [AA,BB,AB] …
       A                   assign to A
        t.                 the tail AB is the output of this predicate
          l>0              and its length is greater than 0.
             ∧Ak          Also, [AA,BB] …
                c          concatenated AABB …
                 ↰         used in a recursive call
                           has the same output as this predicate: AB.
                     lᵒh Order all possible erasers by length, take first

```
> 4 votes

# Answer
# Javascript, 228 bytes, score 228

Naive solution I guess:

```
(r,d)=>{w=0;l=r.length;for(var i=0;i!=-1&&i<l;){i=r.indexOf(d,i);w=w||((i<0)?0:t(r.substr(0,i)+r.substr((i++)+d.length,l),d))}return !r?1:w}
f=a=>{n=a.length;for(p=1;p<=n;p++)for(i=0;i<=n-p;i++)if(t(a,b=a.substr(i,p)))return b}

```

Try it online!
> 0 votes

---
Tags: string, code-challenge, source-layout
---


title: Are These Scores Possible?

text:
# Question
Title: Are These Scores Possible?
## Background

In the sport of Table Tennis (aka Ping-Pong or Whiff Whaff), two opponents play a sequence of rounds, where each round consists of players hitting a ball back and forth until one player (may or may not be the server) gains a point.

Table Tennis has some official rules that make for a good game, but we will use a different set of rules for a better challenge.

The modified rules are as follows:

1. The score is announced directly before each serve as a pair `(current server's score, other player's score)`.
2. Person `A` serves for 5 points, then Person `B` serves for 5 points, then back to `A`. Hence, `A` serves whenever the total score `A+B` is `0-4` mod 10.
3. After each serve, either `A` scores a point or `B` scores a point. `A` and `B` both start with `0` points.
4. For simplicity, games never end.

Following is an example game:

```
(A starts serving, so the scores are read as (A,B))
0,0; A scores a point
1,0; B scores a point
1,1; A scores a point
2,1; A scores a point
3,1; A scores a point
(B is now serving, so the scores are read as (B,A))
1,4; A scores a point
1,5; B scores a point
2,5; B scores a point
3,5; B scores a point
4,5; B scores a point
(A is now serving, so the scores are read as (A,B))
5,5; B scores a point
5,6 …
(game continues)

```

## Task

Given a pair of unique score readouts, determine if they can be announced in the same game.

Your program/function may take input as any reasonable way equivalent to an ordered pair of numbers.

The output can follow your language's convention for truthy/falsey or use any two distinct values to represent true/false.

## Examples

Given `(4,5), (1,4)`, the output should be truthy. The example game is one where this score set occurs.

Given `(4,2), (3,5)`, the output should be falsey. They occur at point totals `6` and `8` respectively, so `B` is serving in both readouts, so both are reported as `(B,A)`. It is impossible for `B`'s score to decrease from `4` to `3` while `A`'s score increases from `2` to `5`, so this situation is impossible.

Given `(3,1), (1,5)`, the output should be truthy. `(3,1)` is reported as `(A,B)`, while `(1,5)` is reported as `(B,A)`, so the game can transition from `(3,1)` to `(1,5)` if `A` scores `2` points.

## Test Cases

```
Truthy:
(4,5), (1,4)
(3,1), (1,5)
(0,0), (0,1)
(0,0), (45,54)
(6,9), (11,9)

Falsey:
(12,5), (11,6)
(4,2), (3,5)
(3,3), (5,2)
(2,1), (4,1)
(17,29), (17,24)

```

# Answer
> 10 votes
# Python 2, 58 bytes

```
lambda a,b,A,B:(A-a)*(B-b)<(a-b)*(A-B)*((a+b)/5+(A+B)/5&1)

```

Try it online!

Outputs True/False reversed

**59 bytes**

```
lambda a,b,A,B:A*B+a*(b-A-B)<(b-a)*[A,B][(a+b)/5+(A+B)/5&1]

```

Try it online!

**59 bytes**

```
lambda a,b,A,B:A*B+b*a<[A*b+B*a,a*A+b*B][(a+b)/5+(A+B)/5&1]

```

Try it online!

**62 bytes**

```
a,b,A,B=input()
if(a+b)/5+(A+B)/5&1:a,b=b,a
print(A-a)*(B-b)<0

```

Try it online!

# Answer
> 7 votes
# Perl 5 `-p` `-Minteger`, ~~77~~, 73 bytes

```
/ (.*) (.*) /;$_=($`-$2)*($1-$')>=(($`+$1)/5+($2+$')/5)%2*($`-$1)*($2-$')

```

Try it online!

2 bytes saved using xnor approach, and 2 other bytes using integer division, explanation is (renaming: $\` -\> a, $1 -\> b, $2 -\> c, $' -\> d), first answer was:

* `(a-B)(b-A)>=0` if scores are in reversed order (`(a+b)/5%2^(A+B)/5%2==1`)
* `(a-A)(b-B)>=0` otherwise

as `(a-B)(b-A)>=0` is equivalent to `(a-A)(b-B)>=(a-b)(A-B)`

* `(a-B)*(b-A)>=0` \<=\> `ab+AB-aA-bB>=0` \<=\> `ab+AB-aB-Ab>=aA+bB-aB-bA` \<=\> `(a-A)(b-B)>=(a-b)(A-B)`

answer can be

* `(a-A)(b-B)>=0` if `(a+b)/5%2^(A+B)/5%2==1`
* `(a-A)(b-B)>=(a-b)(A-B)` if `(a+b)/5%2^(A+B)/5%2==0`

or

* `(a-A)(b-B)>=(a-b)(A-B)*((a+b)/5%2^(A+B)/5%2)`

or with integer division

* `(a-A)(b-B)>=(a-b)(A-B)*((a+b)/5+(A+B)/5)%2`

# Answer
> 4 votes
# 05AB1E, ~~15~~ ~~14~~ 12 bytes

```
εDO5÷FR]`-Pd

```

-2 bytes thanks to *@Neil*.

Try it online or verify all test cases.

**Explanation:**

```
ε        # Map both pairs in the (implicit) input to:
 D       #  Duplicate the pair
  O      #  Pop this duplicate and calculate its sum
   5÷    #  Integer-divide it by 5
     F   #  Loop that many times:
      R  #   Reverse the pair every iteration
         #   (the pair is reversed for odd sums; and remains unchanged for even sums)
]        # Close both the loop and map
         # (all pairs are now in the order [A,B])
 `       # Pop and push both pairs separated to the stack
  -      # Subtract the values of the pairs from one another at the same indices
   P     # Take the product of those two values
    d    # And check that it's non-negative / >=0 (thus no score is decreasing)
         # (after which the result is output implicitly)

```

# Answer
> 3 votes
# APL (Dyalog Extended), 15 bytes

```
≡⍥⍋∘⌽⍨⌊⍤+.÷∘5⌽⊢

```

Try it online!

```
≤⌿⍣2⍤∧⌊⍤+.÷∘5⌽⊢

```

Try it online!

It took a long time to shave one byte from 16. You can see a long history of alternative solutions in the TIO link.

Both solutions take a 2×2 matrix as single input, where each row is a score readout. The first one would also work in Dyalog APL 18.0, since it only uses 17.x features plus `⍥⍤`.

### How it works

```
≡⍥⍋∘⌽⍨⌊⍤+.÷∘5⌽⊢  ⍝ Input: 2×2 matrix
      ⌊⍤+.÷∘5    ⍝ For each row, divide each number by 5, sum, then floor
             ⌽⊢  ⍝ Rotate each row by that amount
   ∘⌽⍨           ⍝ Check for the above and its horizontal reverse...
≡⍥⍋              ⍝   Is the sorting order equal?

≤⌿⍣2⍤∧⌊⍤+.÷∘5⌽⊢  ⍝ Alternative solution
      ⌊⍤+.÷∘5⌽⊢  ⍝ Same as above up to here
    ⍤∧           ⍝ Ascending sort the rows
≤⌿⍣2             ⍝ 1st axis reduce by ≤ twice;
                 ⍝ Since the rows are sorted, first ≤⌿ gives [1 x]
                 ⍝ where x is 1 iff the 2nd column is also increasing
                 ⍝ Then the second ≤⌿ tests if x is 1

```

# Answer
> 3 votes
# APL (Dyalog) 18.0, ~~19 18~~ 17 bytes

```
0≤×.-⍥(⌊⍤+.÷∘5⌽⊢)

```

Try it online!

This makes use of the new operators over () and atop (), both of which are very good for golfing. TIO is still on 17.0, so this doesn't work, but I've tested it locally for the given test cases. Takes the two inputs as the left and right parameters.

# Answer
> 3 votes
# Charcoal, 30 bytes

```
ＵＭθＥι§ι⁺÷Σι⁵μ¬›⁰ΠＥ²⁻§§θ⁰ι§§θ¹ι

```

Try it online! Link is to verbose version of code. Takes a pair of pairs of integers and outputs a Charcoal boolean, i.e. `-` for possible, nothing for impossible. Explanation:

```
ＵＭθＥι§ι⁺÷Σι⁵μ

```

Cyclically rotate each pair by one fifth of its sum.

```
¬›⁰ΠＥ²⁻§§θ⁰ι§§θ¹ι

```

Check that the product of the differences between the pairs is not negative.

# Answer
> 2 votes
# , ~~65~~ ~~59~~ 57 bytes

(or 56 bytes by outputting FALSE for Truthy and TRUE for Falsey)

```
function(a,b)prod(a-b[(0:1+sum(a)/5-sum(b)%/%5)%%2+1])>=0

```

Try it online!

*Edit: -6 bytes by flipping b elements using indexing, instead of using if-else*

*Edit 2: -2 bytes by not bothering to do integer division for both a and b, since indexing will only use the integer part anyway.*

Commented version:

```
validscores=function(a,b){
    b=b[                    # Select elements from b
    (0:1+                   # with index of: zero or 1, plus
    sum(a)%/%5              # changes of serve until first score
    -sum(b)%/%5)            # minus changes of serve until second score
    %%2+1]                  # modulo 2, plus 1.
                            # This will flip the elements of b if there
                            # have been an odd number of changes of serve,
                            # & otherwise leave b as it was).
    prod(a-b)>=0            # a-b now gives changes in each players points:
}                           # so if the second score came after the first,
                            # both changes must be >=0, otherwise both must be <=0.
                            # So, either way, the product must be >=0

```

# Answer
> 2 votes
# Jelly, 11 bytes

```
ṚS:5Ɗ¡€Ṣ>/E

```

A monadic Link accepting a list of the to pairs which yields a `1` if valid, or a `0` if not.

**Try it online!** Or see the test-suite.

### How?

```
ṚS:5Ɗ¡€Ṣ>/E - Link: list, S            e.g. [[17,29],[17,24]]
      €     - for each (pair in S):
     ¡      -   repeat...
Ṛ           -   ...what: reverse
    Ɗ       -   ...number of times: last three links as a monad:
 S          -       sum                       46     41
   5        -       five                       5      5
  :         -       integer division           9      8  -> [[29,17],[17,24]]
       Ṣ    - sorted                                        [[17,24],[29,17]]
         /  - reduce by:
        >   -   is greater than?       ([17>?29, 24>?17])   [0,1]
          E - all equal?                                    0

```

# Answer
> 2 votes
# Jelly, ~~26~~ ~~23~~ 20 bytes

Thanks to fireflame241, I was able to shave off a few bytes already.

```
S€%⁵:5E¬µ³U⁸¡Ðo_/ṠIỊ

```

Original:

```
S€%ȷ1<5E¬©µ³Ṛ€®¡Ðo_/ṠIA=2¬

```

Try it online!

Here's my Jelly solution. It's my first Jelly program, so it can definitely be improved a lot, especially at the part where I use the register. I don't quite understand how argument flow works yet.

Here's how it works:

S€%⁵:5E¬µ³U⁸¡Ðo_/ṠIỊ - Example input:                     [[4,5],[1,4]]

S€%⁵<5               - Figure out who is serving each time
S€                   - Calculates sum of each inner list: [9, 5]
  %⁵                 - Modulo 10:                         [9, 5]
    <5               - Vectorized less than 5?:           [0, 0]

      E¬µ³U⁸¡Ð       - If server is different, reverse list 1
      E              - Checks if all elements are equal:  1
       ¬             - Logical not:                       0
        µ            - Start a monadic chain
         ³           - Get first input:                   [[4,5],[1,4]]
          U          - Reverse order of inner lists
             Ðo      - At odd indices (ie. the first list)
           ⁸¡        - {left argument, ie. 0} times:      [[4,5],[1,4]]

               _/ṠIỊ - Calculate difference in score per player.
                       If one decreased and the other increased,
                       it's not a possible score
               _/    - Vectorized subtract:               [3, 1]
                 Ṡ   - Get sign:                          [1, 1]
                  I  - Difference between elements:       0
                   Ị - abs(x) <= 1:                       0
```
</code></pre>

# Answer
> 1 votes
# Java 8, ~~116~~ ~~63~~ 54 bytes

```
(a,b,A,B)->(A-a)*(B-b)<((a+b)/5+(A+B)/5)%2*(a-b)*(A-B)

```

Whopping -53 bytes thanks to *@NahuelFouilleul* as a port from his Perl answer, so make sure to upvote him!!
Additional -9 bytes by porting *@xnor*'s first Python answer.

Takes the inputs as four loose integers.
Outputs `false` for truthy; and `true` for falsey.

Try it online.

**Explanation:**

```
(a,b,A,B)->   // Method with four integer parameters and boolean return-type
  (A-a)*(B-b) //   Get the difference between the values of the two pairs,
              //   and take the product of those two differences
  <           //  And check that this is smaller than:
   ((a+b)     //     The sum of the first pair
     /5       //     integer-divided by 5
    +         //    Plus:
     (A+B)/5) //     The sum of the second pair, integer-divided by 5 as well
   %2         //   Check if these two added together are odd (1 if odd; 0 if even)
   *(a-b)     //   Multiplied by the reduced by subtraction of the first pair
   *(A-B)     //   Multiplied by the reduced by subtraction of the second pair

```

# Answer
> 1 votes
# C (gcc), 58 bytes

```
f(a,b,A,B){a=(A-a)*(B-b)<(a-b)*(A-B)*((a+b)/5+(A+B)/5&1);}

```

Try it online!

Port of xnor's Python answer.
Outputs \\$0\\$ if they can be announced in the same game and \\$1\\$ otherwise.

# Answer
> 1 votes
# Javascript , 70 bytes

```
(a,b,c,d)=>(~~((a+b)%10/5)==~~((c+d)%10/5)?(c-a)*(d-b):(d-a)*(c-b))>=0

```

Input: is 4 numbers representing two pairs in order.

Output: true/false

Try it online

---
Tags: code-golf, decision-problem, game
---