30
\$\begingroup\$

For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size.

What is a right triangle?

For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the same width) equal to that line number:

.
..
...
....

Trailing newlines are allowed.

The challenge:

Your code should form a right triangle, and output a right triangle with the same height made up of any non-newline characters.

As this is code golf, shortest answer in bytes per language wins.

\$\endgroup\$
14
  • 8
    \$\begingroup\$ So, to be clear, 1 byte solutions outputting a single character are valid? Also, for longer solutions, must all characters in the output be the same, as in your example? And why are functions disallowed? \$\endgroup\$
    – Shaggy
    Commented Apr 4, 2020 at 21:19
  • \$\begingroup\$ @Shaggy Yes, 1 byte solutions would be valid (though for most golfing languages this is probably trivial anyway), characters do not need to be the same, and I actually think I'll revise the rules to allow functions. \$\endgroup\$ Commented Apr 4, 2020 at 21:21
  • \$\begingroup\$ Based on "made up of any non-newline characters", a null byte is allowed, right? \$\endgroup\$
    – S.S. Anne
    Commented Apr 4, 2020 at 21:41
  • \$\begingroup\$ @S.S.Anne Yes, I'd say the only bytes not allowed would be \n and \r (0x0a and 0x0d) \$\endgroup\$ Commented Apr 4, 2020 at 21:52
  • 1
    \$\begingroup\$ I have the feeling this challenge would have been better as a code-bowling challenge tbh :) \$\endgroup\$ Commented Apr 6, 2020 at 8:42

61 Answers 61

1 2
3
0
\$\begingroup\$

Deadfish~, 1 byte

o

Outputs

0

This is kind of cheating but I can't think of any other way to do it in Deadfish~.

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.