1
\$\begingroup\$

I've been doing code golf puzzles to improve my J. I'd appreciate any feedback on my solution to this problem.

The task is to take an integer and produce an ascii triangle as follows:

5 
|\ 
| \ 
| \ 
| \ 
| \
------

My solution:

(#&'| \' @ (1,1,~])"0 i.) , ('-'#~>:)
asked Jul 21, 2017 at 2:51
\$\endgroup\$
1
  • \$\begingroup\$ I think your answer fails for n=0. It should produce no output, but yours produces '-' Your code golf submission has a clever version that miles put in the comments. *,&'-' '|',.'\'{."0~_1-i. and it passes for n=0 \$\endgroup\$ Commented Jul 23, 2017 at 8:38

1 Answer 1

2
\$\begingroup\$

Based on the approach miles took on your code golf submission:

*,&'-' '|',.'\'{."0~_1-i

I shortened it slightly to this:

*,&'-' '|',.' \'{~=@i.

Both of the above pass n=0

answered Jul 23, 2017 at 9:00
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.