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

LessThanDot christmas Logo

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 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:
1603
Members Online:
3
Guests Online:
6

Total Post History
Posts:
80573
Topics:
18459

7-Day Post History
New Posts:
3
New Topics:
1
Active Topics:
3

Our newest member
dafafir

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: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
 
Posts: 3134
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.
God cries a little bit every time someone builds a database.
User avatar
Emtucifor
Guru
Guru
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030
 
Posts: 2835
Joined: Fri May 30, 2008 9:30 pm
Location: Bellingham, WA

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
God cries a little bit every time someone builds a database.
User avatar
Emtucifor
Guru
Guru
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030
 
Posts: 2835
Joined: Fri May 30, 2008 9:30 pm
Location: Bellingham, WA
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
Say what you like about the tenets of National Socialism Dude, at least it's an ethos
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021
LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021
LTD Gold - Rating: 1021
 
Posts: 5411
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
Say what you like about the tenets of National Socialism Dude, at least it's an ethos
User avatar
AlexCuse
LTD Admin
LTD Admin
LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021
LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021LTD Gold - Rating: 1021
LTD Gold - Rating: 1021
 
Posts: 5411
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.
God cries a little bit every time someone builds a database.
User avatar
Emtucifor
Guru
Guru
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030LTD Gold - Rating: 1030
LTD Gold - Rating: 1030
 
Posts: 2835
Joined: Fri May 30, 2008 9:30 pm
Location: Bellingham, WA
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: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
 
Posts: 3134
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: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661LTD Silver - Rating: 661
 
Posts: 3134
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK
Unrated