Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

A Technical Community for IT Professionals

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Forum Statistics

Users
Members:
543
Members Online:
10
Guests Online:
5

Total Post History
Posts:
45705
Topics:
9398

7-Day Post History
New Posts:
343
New Topics:
81
Active Topics:
90

Our newest member
sangeeta

Other

FAQ
All times are UTC [ DST ]

Google Ads

LTD Puzzle 3: ASCII Art Shapes

Mind Boggling Puzzles, to keep that grey matter in shape...
Forum rules
Always post answers in a "Hidecode" tag, so that others have a chance to answer the question too.
Please wait...

LTD Puzzle 3: ASCII Art Shapes

Postby damber on Fri Jun 20, 2008 12:34 pm

This weeks challenge is to create some ASCII art in the shortest code possible. The objectives are:

  • Be able to draw a solid circle/ellipse of user definable height and width and...
  • Be able to draw a solid triangle of user definable height and width
  • User should be able to choose at runtime to print either shape, or both
  • User should be able to choose the ASCII print character (which should be consistent throughout the shapes)
  • Height and Width defined in characters (e.g. 3char x 3char)

Remember that the challenge here is to do this in the shortest code possible, so have fun streamlining, optimising and essentially making it unreadable but very short :-)

Good luck!
a smile is worth a thousand kind words, so smile, it's easy! :-)


CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
User avatar
damber
LTD Admin
LTD Admin
LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342
LTD Silver - Rating: 342
 
Posts: 1959
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK

Re: LTD Puzzle 3: ASCII Art Shapes

Postby Emtucifor on Tue Jun 24, 2008 5:36 pm

Code is hidden, SHOW

Drat having to deal with ascii shapes of width or height 1...

edit: minor formatting changes
Last edited by Emtucifor on Wed Jun 25, 2008 1:00 am, edited 2 times in total.
It's more cheesier if you do it right the first time!
User avatar
Emtucifor
Senior Sage
Senior Sage
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753
 
Posts: 2152
Joined: Fri May 30, 2008 9:30 pm
Location: California

Re: LTD Puzzle 3: ASCII Art Shapes

Postby Emtucifor on Tue Jun 24, 2008 11:14 pm

On the inner loop for the ellipse, replace the two lines with

Code is hidden, SHOW
It's more cheesier if you do it right the first time!
User avatar
Emtucifor
Senior Sage
Senior Sage
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753
 
Posts: 2152
Joined: Fri May 30, 2008 9:30 pm
Location: California
Unrated

Re: LTD Puzzle 3: ASCII Art Shapes

Postby AlexCuse on Wed Jun 25, 2008 1:31 am

Thanks to Erik for some help with the ellipse.

C# 3 with lambda expressions - some long lines, copy into a text editor to see em:

Code is hidden, SHOW
And we have contraptions like computers that cheat you out of becoming. Bill Gates says, "Wait till you see what your computer can become." But it's you who should be doing the becoming, not the damn fool computer.

My Crummy Web Page
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642
LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642
 
Posts: 3532
Joined: Tue Oct 09, 2007 5:26 pm
Location: Pennsylvania, US

Re: LTD Puzzle 3: ASCII Art Shapes

Postby AlexCuse on Thu Jun 26, 2008 1:41 am

since we're going for shortest code, and I've been meaning to start learning it anyways, I decided to try python. i'm sure it can be done better!

Code is hidden, SHOW
And we have contraptions like computers that cheat you out of becoming. Bill Gates says, "Wait till you see what your computer can become." But it's you who should be doing the becoming, not the damn fool computer.

My Crummy Web Page
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642
LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642LTD Silver - Rating: 642
 
Posts: 3532
Joined: Tue Oct 09, 2007 5:26 pm
Location: Pennsylvania, US

Re: LTD Puzzle 3: ASCII Art Shapes

Postby Emtucifor on Thu Jun 26, 2008 8:01 pm

I liked this puzzle.
It's more cheesier if you do it right the first time!
User avatar
Emtucifor
Senior Sage
Senior Sage
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753LTD Gold - Rating: 753
LTD Gold - Rating: 753
 
Posts: 2152
Joined: Fri May 30, 2008 9:30 pm
Location: California
Unrated

Re: LTD Puzzle 3: ASCII Art Shapes

Postby damber on Fri Jun 27, 2008 3:11 pm

any more entries? this is your last chance - after today, we will be moving onto the next puzzle...
a smile is worth a thousand kind words, so smile, it's easy! :-)


CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
User avatar
damber
LTD Admin
LTD Admin
LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342
LTD Silver - Rating: 342
 
Posts: 1959
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK
Unrated

Re: The Winners

Postby damber on Sun Jul 06, 2008 1:38 pm

There are 2 types of winner - a "People's Champion" (the one with the most rating points across all their posts) and the LTD Admin's Champion (selected with our special formula....honest...well, maybe it's just the ones that the admins thought were particularly good :-))

So...

People's Champion: AlexCuse scoring 12 points from 2 different solutions (C# and Python)

LTD Admin's Champion: ErikE for being the first to post a solution which part inspired others, and for a pretty short and concise result.


Congratulations to all.. and good luck on next weeks puzzle :-)
a smile is worth a thousand kind words, so smile, it's easy! :-)


CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
User avatar
damber
LTD Admin
LTD Admin
LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342LTD Silver - Rating: 342
LTD Silver - Rating: 342
 
Posts: 1959
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK
Unrated