|
Post by Josh on May 21, 2017 13:57:08 GMT
ASCII Art #1 In this programming puzzle, you must output the following and somehow make use of the integer 20 to generate it:
* *** ***** ******* ********* *********** ************* *************** ***************** ******************* ***************** *************** ************* *********** ********* ******* ***** *** * Your program must output the above exactly and may include spaces after the asterisks. Make sure you tell us the language name along with the amount of characters if it is golfed.
Good luck!
|
|
|
Post by disillusions on May 21, 2017 14:12:57 GMT
way I did it (done in studio cmd bar so format is crap) (not golfed)
local s = '' for i=1, 20 do s = s..string.rep(' ',20-i)..string.rep('*',i)..'\n' end for i=19, 1, -1 do s = s..string.rep(' ',20-i)..string.rep('*',i)..'\n' end print(s)
|
|
kinrany
New Member
Veteran
Posts: 2
|
Post by kinrany on May 21, 2017 14:34:06 GMT
|
|
|
Post by Josh on May 21, 2017 16:23:44 GMT
Looks good kinrany! Thanks for attempting disillusions, your solution appears to output the left side of the ASCII diamond at double the size it should.
|
|
|
Post by disillusions on May 22, 2017 8:54:23 GMT
Blame studio formatting
|
|
|
Post by Josh on May 22, 2017 14:51:10 GMT
|
|
alu
New Member
Posts: 3
|
Post by alu on Jun 9, 2017 23:27:13 GMT
HolyC U0 PrintSegment(I64 it, I64 sp) { I64 i; for (i = 1; i <= sp; i++) " "; for (i = 1; i <= 2 * it - 1; i++) "*"; "\n"; }
U0 Main() { I64 times = 20 / 2; I64 sp = times - 1; I64 i; for (i = 1; i <= times; i++) PrintSegment(i, sp--); sp = 1; for (i = 1; i <= times - 1; i++) PrintSegment(times - i, sp++); }
Main; Screenshot of output:
|
|
john
New Member
Posts: 11
|
Post by john on Jun 10, 2017 15:40:53 GMT
~@l=1,19I=l<=10&l%11|20-l;w(S.t(' ',M.a(10-I))..S.t('*',M.a(I*2)-1))$
69 bytes, golflua.
|
|
|
Post by Bit on Jun 10, 2017 16:00:54 GMT
~@i=1,19;b=i<=10&i%11|20-i;w(S.t(' ',M.a(10-b))..S.t('*',M.a(b*2)-1))$
70 bytes, golflua. What's golflua?!
|
|
john
New Member
Posts: 11
|
Post by john on Jun 10, 2017 16:02:01 GMT
~@i=1,19;b=i<=10&i%11|20-i;w(S.t(' ',M.a(10-b))..S.t('*',M.a(b*2)-1))$
70 bytes, golflua. What's golflua?! alternative lua interpreter
|
|
|
Post by Bit on Jun 10, 2017 16:03:28 GMT
Well isn't that useful.
|
|
john
New Member
Posts: 11
|
Post by john on Jun 10, 2017 16:49:45 GMT
it's useful AND really fun. it has a lot of nice properties that actually make it really fun to write.
|
|