Skip to main content
added 915 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Try it online!Verify all programs online!

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.

Verify all programs online!

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.

Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

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!	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	
%	~

Try it online!

Satisfies:

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