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.

Highly Rated Users

Forum
No Posts Rated

Top 50
Given
Received

Forum Statistics

Users
Members:
705
Members Online:
2
Guests Online:
5

Total Post History
Posts:
56484
Topics:
11714

7-Day Post History
New Posts:
373
New Topics:
62
Active Topics:
76

Our newest member
lupets0011

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: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414
LTD Silver - Rating: 414LTD Silver - Rating: 414
 
Posts: 2296
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: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874
 
Posts: 2358
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: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874
 
Posts: 2358
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
In all branches of the economy they brandished their formulas and calculations and refused to understand that bridges and lathes could respond to the enthusiasm of the personnel.

My Crummy Web Page
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747
LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747
 
Posts: 4278
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
In all branches of the economy they brandished their formulas and calculations and refused to understand that bridges and lathes could respond to the enthusiasm of the personnel.

My Crummy Web Page
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747
LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747LTD Silver - Rating: 747
 
Posts: 4278
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: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874LTD Gold - Rating: 874
LTD Gold - Rating: 874
 
Posts: 2358
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: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414
LTD Silver - Rating: 414LTD Silver - Rating: 414
 
Posts: 2296
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: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414LTD Silver - Rating: 414
LTD Silver - Rating: 414LTD Silver - Rating: 414
 
Posts: 2296
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK
Unrated