Skip to main content
Commonmark migration
Source Link

#Common Lisp SBCL, 145 bytes

Common Lisp SBCL, 145 bytes

(do((b 1)(l'(1 2 3 4 5 6 7 8 9))(i 1(+ i b)))((= i 0))(format t"~17:@<~v{~a~}~v{~a~}~>~%"i l i(reverse(subseq l 0(1- i))))(if(> i 8)(setf b -1)))

It is worse than the other Common Lisp solution, but it works and I think it is different enough to be posted.

Explanation

###Explanation i is incremented up to 9 and then decremented to 0 (when i=9 sign of b is changed effectively changing addition to subtraction - this avoids second loop.

In each line I print numbers: `123...i(i-1)...1 using loops of format function (for first loop I use list '(1 2 3 4 5 6 7 8 9) and for decrementing loop I use reversed subsequence of this list. Text is then centered.

I didn't notice that numbers are squares of 11..11. As far as this solution is concerned the diamond could be made out of letters or (! @ # ...) (for that you would need to change ~a to ~c in format function.

#Common Lisp SBCL, 145 bytes

(do((b 1)(l'(1 2 3 4 5 6 7 8 9))(i 1(+ i b)))((= i 0))(format t"~17:@<~v{~a~}~v{~a~}~>~%"i l i(reverse(subseq l 0(1- i))))(if(> i 8)(setf b -1)))

It is worse than the other Common Lisp solution, but it works and I think it is different enough to be posted.

###Explanation i is incremented up to 9 and then decremented to 0 (when i=9 sign of b is changed effectively changing addition to subtraction - this avoids second loop.

In each line I print numbers: `123...i(i-1)...1 using loops of format function (for first loop I use list '(1 2 3 4 5 6 7 8 9) and for decrementing loop I use reversed subsequence of this list. Text is then centered.

I didn't notice that numbers are squares of 11..11. As far as this solution is concerned the diamond could be made out of letters or (! @ # ...) (for that you would need to change ~a to ~c in format function.

Common Lisp SBCL, 145 bytes

(do((b 1)(l'(1 2 3 4 5 6 7 8 9))(i 1(+ i b)))((= i 0))(format t"~17:@<~v{~a~}~v{~a~}~>~%"i l i(reverse(subseq l 0(1- i))))(if(> i 8)(setf b -1)))

It is worse than the other Common Lisp solution, but it works and I think it is different enough to be posted.

Explanation

i is incremented up to 9 and then decremented to 0 (when i=9 sign of b is changed effectively changing addition to subtraction - this avoids second loop.

In each line I print numbers: `123...i(i-1)...1 using loops of format function (for first loop I use list '(1 2 3 4 5 6 7 8 9) and for decrementing loop I use reversed subsequence of this list. Text is then centered.

I didn't notice that numbers are squares of 11..11. As far as this solution is concerned the diamond could be made out of letters or (! @ # ...) (for that you would need to change ~a to ~c in format function.

Source Link
user65167
user65167

#Common Lisp SBCL, 145 bytes

(do((b 1)(l'(1 2 3 4 5 6 7 8 9))(i 1(+ i b)))((= i 0))(format t"~17:@<~v{~a~}~v{~a~}~>~%"i l i(reverse(subseq l 0(1- i))))(if(> i 8)(setf b -1)))

It is worse than the other Common Lisp solution, but it works and I think it is different enough to be posted.

###Explanation i is incremented up to 9 and then decremented to 0 (when i=9 sign of b is changed effectively changing addition to subtraction - this avoids second loop.

In each line I print numbers: `123...i(i-1)...1 using loops of format function (for first loop I use list '(1 2 3 4 5 6 7 8 9) and for decrementing loop I use reversed subsequence of this list. Text is then centered.

I didn't notice that numbers are squares of 11..11. As far as this solution is concerned the diamond could be made out of letters or (! @ # ...) (for that you would need to change ~a to ~c in format function.