C 127 119 116 108108 65
This isn't as pretty asone uses the Q-Basic answer, but it shows another waytrick of calculating the Sierpinski triangle, using cellular automata. You probably want '#' insteadHTML answer of '!' making up^ i & j
getting it to print pretty output would take 1 more char (you can get really ugly output by sacrificing the triangle, but exclamation points cost two fewer charactersa^
).
a=32,j;main(i){for(;++i<a;)putchar(a^i&j);++j<a&&main(puts(""));}
To make it pretty turn (32^i&j)
to (32|!(i&j))
and turn it from ++i<a
to ++i<=a
. However wasting chars on looks seems ungolfish to me.
Ugly output:
! ! ! ! ! ! ! ! ! ! ! ! ! ! !
"" "" "" "" "" "" "" ""
"# !"# !"# !"# !"# !"# !"# !"#
$$$$ $$$$ $$$$ $$$$
!$%$% ! !$%$% ! !$%$% ! !$%$%
""$$&& ""$$&& ""$$&& ""$$&&
"#$%&' !"#$%&' !"#$%&' !"#$%&'
(((((((( ((((((((
! ! !()()()() ! ! ! !()()()()
"" ""((**((** "" ""((**((**
"# !"#()*+()*+ !"# !"#()*+()*+
$$$$((((,,,, $$$$((((,,,,
!$%$%()(),-,- ! !$%$%()(),-,-
""$$&&((**,,.. ""$$&&((**,,..
"#$%&'()*+,-./ !"#$%&'()*+,-./
0000000000000000
! ! ! ! ! ! !0101010101010101
"" "" "" ""0022002200220022
"# !"# !"# !"#0123012301230123
$$$$ $$$$0000444400004444
!$%$% ! !$%$%0101454501014545
""$$&& ""$$&&0022446600224466
"#$%&' !"#$%&'0123456701234567
((((((((0000000088888888
! ! !()()()()0101010189898989
"" ""((**((**0022002288::88::
"# !"#()*+()*+0123012389:;89:;
$$$$((((,,,,000044448888<<<<
!$%$%()(),-,-010145458989<=<=
""$$&&((**,,..0022446688::<<>>
"#$%&'()*+,-./0123456789:;<=>?
I actually kind of like how it looks. But if you insist on it being pretty you can dock four chars. Pretty Output:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
!! !! !! !! !! !! !! !
! ! ! ! ! ! ! !
!! !!!! !!!! !!!! !
! ! ! ! ! ! ! !
!! !! !! !
! ! ! !
!!!!!! !!!!!!!! !
! ! ! ! ! ! ! !
!! !! !! !
! ! ! !
!! !!!! !
! ! ! !
!! !
! !
!!!!!!!!!!!!!! !
! ! ! ! ! ! ! !
!! !! !! !
! ! ! !
!! !!!! !
! ! ! !
!! !
! !
!!!!!! !
! ! ! !
!! !
! !
!! !
! !
!
!
Leaving up the older 108 char, cellular automata version.
j,d[99][99];main(i){d[0][48]=1;for(;i<98;)d[j+1][i]=putchar(32|d[j][i+2]^d[j][i++]);j++<50&&main(puts(""));}
So I don't think I'm going to get it much shorter than this soSo I don't think I'm going to get it much shorter than this so I'll explain the code. I'll explainleave this explanation up, as some of the codetricks could be useful.