13
\$\begingroup\$

While moving, I broke my lamp. Now, I need a new one. It's your job to make me a lamp! I'm not sure what size I want, though I know I want a squiggly one.

Your program/function must take in a number input, and print out a lamp with that many squiggles/bumps.

Examples:

Input:2

Output:

/--\
 ()
 ()
/__\

Input:3

Output:

/--\
 ()
 ()
 ()
/__\

Input:5

Output:

/--\
 ()
 ()
 ()
 ()
 ()
/__\

Rules:

  • 0 & negative numbers don't matter
  • To give the lamps (an this challenge) more of a variety, you must change the lamp shade.
    • They must be 4 characters wide and 1 character high.
    • They can be in any shape, including non-lamp-shade shapes.
    • They must not contain whitespace.
    • The base must stay the same.
  • You must show an example input & output with your lamp shade.
  • Shortest code wins!
\$\endgroup\$
  • \$\begingroup\$ But it doesn't squiggle at all!. Would have loved if inputs > 5 made it squiggle. \$\endgroup\$ – Optimizer Jul 21 '15 at 20:15
  • 22
    \$\begingroup\$ I downvoted. I think this is a boring ASCII art. There's a repeated section in the middle and no overlap between the parts, which are also too short to compress. It just has form ABBB..BBBC. The requirement to change a section just means people will use a short built-in string. \$\endgroup\$ – xnor Jul 21 '15 at 20:27
  • 7
    \$\begingroup\$ You can all stop downvoting already! I think OP got the message. \$\endgroup\$ – xnor Jul 21 '15 at 21:16
  • 1
    \$\begingroup\$ @xnor I feel sorry for the poor guy. This is probably one of the most downvoted questions ever :/ i.stack.imgur.com/T4A7X.jpg \$\endgroup\$ – Beta Decay Jul 22 '15 at 7:08
  • 1
    \$\begingroup\$ Not voted in any way myself, but given the similarity with Draw an ASCII Lightning Bolt, I can understand the downvoters. Some little twist like having larger base for higher lamp, or having a repeated decoration only on each nth squiggle would made it a little bit different. \$\endgroup\$ – manatwork Jul 22 '15 at 11:07

34 Answers 34

0
\$\begingroup\$

Noether, 26 bytes

"-"4*P?I(" ()"P?!i)"/__\"P

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Charcoal, 16 12 10 bytes

8E⊕N(←_/‖M

-4 bytes thanks to @ASCII-only.
-1 byte thanks to @Neil by using a Map.

Try it online (verbose) or try it online (pure).

Uses 8()8 as cap, but the 8 can be any character from Charcoal's code-page that isn't used as a command/operator.

Explanation:

Print 8:

Print("8");
8

Print ( the input+1 amount of times downwards:

Print(Map(Incremented(InputNumber()), "("));
E⊕N(

Then after that print _/ in a left direction:

Print(:Left, "_/");
←_/

And finally mirror everything vertically:

ReflectMirror();
‖M
\$\endgroup\$
  • 1
    \$\begingroup\$ 12? \$\endgroup\$ – ASCII-only Aug 6 '18 at 6:12
  • \$\begingroup\$ @ASCII-only Thanks! Forgot about Print(... Time(...));, and smart way of using Move(:DownLeft); so regular Prints instead of MultiPrints can be used and the space at " (" can be saved at the same time. \$\endgroup\$ – Kevin Cruijssen Aug 6 '18 at 6:33
  • \$\begingroup\$ You can save a byte here using Map too, although you'll need to rewrite the way you print the {8 so that you don't have to explicitly move to the next line. \$\endgroup\$ – Neil Jan 27 at 12:23
  • 1
    \$\begingroup\$ @Neil Still not sure how to do {8 in 3 bytes while moving the cursor at the same time, but I've been able to golf 2 bytes instead of 1 by using 8( instead of {8 as lamp shade. Still curious how to do the {8 in 3 bytes through. :) \$\endgroup\$ – Kevin Cruijssen Jan 27 at 17:43
  • 1
    \$\begingroup\$ Print("{"); Print(:Down, "8"); \$\endgroup\$ – Neil Jan 27 at 17:55
0
\$\begingroup\$

Brain-Flak, 164 bytes

({}<((((((((((()()){}()){})()){}()){}())){}()))[[]]()){({}<>)<>}<>>()){({}[()]<(((((((()()){}()){}){}){}())[()])[(()()()()){}])((()()()()()){})>)}(((({}{}{}{}{}))))

Try it online!

Output for 5:

{{{{
 ()
 ()
 ()
 ()
 ()
/__\
\$\endgroup\$
-1
\$\begingroup\$

PyMin, 24 bytes / 17 characters

»ƒ+ѿ+" ø\n"*¬+ɓ+ѿ

Output for 5:

Fizz
 ()
 ()
 ()
 ()
 ()
Buzz

Shorter version with v0.5:

21 bytes / 13 characters

»ƒƜ+" ø¶"¯+ɓƜ
\$\endgroup\$
  • \$\begingroup\$ The base of the lamp must be /__\. \$\endgroup\$ – snail_ Aug 7 '18 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.