9
\$\begingroup\$

This is Bub. Bub is a soccer player. However, he's not a very good one. He still can't kick the ball to the net! (If you haven't noticed, @ is the ball.

                                                       _____
                                                      |     \
  O                                                   |      \
 \|/                                                  |       \
  |                                                   |  net   \ 
 / ─   @                                              |_________\

To help develop his skills, he's developed a system to help evaluate his performance when he kicks the ball. He's called it the "10 point system."

However, he doesn't know what he needs to do to achieve x number of points. You need to help him visualize where the ball will be, so that he can set an expectation of how many points he wants to get. There are 10 points per round that he can achieve.

Therefore, this is your challenge.

Given a number x, the number of points Bub gets, output the location of the ball on the field. Here are some helpful markers:

  • Bub is exactly 50 spaces away from the net.
  • For each point that Bub gets, the ball moves 5 spaces closer to the net. Therefore, if Bub gets 3 points, the ball is 35 spaces away from the net.
  • For every 3 points that Bub gets, the ball begins to move in the air! It moves one space up.
  • If the number of points Bub gets would move the ball behind the net, you can put the ball anywhere inside the net.

Remember, you need to draw Bub, the ball, and the net.

To get you started, here's an example:

Number of Points: 5

                                                       _____
                                                      |     \
  O                                                   |      \
 \|/                                                  |       \
  |                          @                        |        \ 
 / ─                                                  |_________\

Standard rules apply. Code with the lowest number of bytes wins! Happy golfing!

\$\endgroup\$
  • \$\begingroup\$ Can we count that character as one byte? \$\endgroup\$ – Leaky Nun Jun 20 '16 at 3:53
  • \$\begingroup\$ Do we have to output the trailing spaces exactly as given, or can we print extra? \$\endgroup\$ – PurkkaKoodari Jun 20 '16 at 7:50
  • \$\begingroup\$ @edc65 I take it as "move the ball one position up for each 3 points" \$\endgroup\$ – Luis Mendo Jun 20 '16 at 8:59
  • \$\begingroup\$ @Pietu1998 Exactly as given. \$\endgroup\$ – Zizouz212 Jun 20 '16 at 11:46
  • 2
    \$\begingroup\$ If There are 10 points per round that he can achieve, why sould we care about n>10? \$\endgroup\$ – edc65 Jun 20 '16 at 14:56
3
\$\begingroup\$

Pyth, 106 91 bytes

Run-length encoding, followed by internal encoding.

Hexdump:

0000000: 4a 63 72 58 2e 22 30 41 01 b6 07 31 11 af 55 c5 JcrX."0A...1..U.
0000010: 16 6f 93 4f ea 90 6b 39 f6 e0 dc 81 43 9d 01 f7 .o.O..k9....C...
0000020: 36 93 ee 4c c8 fa a5 28 70 22 6d 43 2b 35 38 64 6..L...(p"mC+58d
0000030: 38 22 0a 20 2f 4f 5c 5c 5f 7c 2d 22 39 62 6a 58 8". /O\\_|-"9bjX
0000040: 4a 4b 2d 35 2f 68 53 2c 54 51 33 58 40 4a 4b 68 JK-5/hS,TQ3X@JKh
0000050: 53 2c 35 38 2b 34 2a 35 51 5c 40                S,58+4*5Q\@

Try it online!

Replace the Unicode character (U+2500) as a single hyphen.

\$\endgroup\$
  • \$\begingroup\$ Oh dear. There's an extra space on the bottom most line of your output! And the ball goes behind the net, not inside! Try an input of 12 and you'll see! \$\endgroup\$ – Zizouz212 Jun 20 '16 at 1:12
  • \$\begingroup\$ Oh yes, the line is Unicode. I love the answer. Kudos for being first! \$\endgroup\$ – Zizouz212 Jun 20 '16 at 1:21
3
\$\begingroup\$

JavaScript (ES6), 189

f=n=>"       o \\|/ | / -".match(/.../g).map((v,r)=>(v=[...v+' '.repeat(50)+'| '[+!r]+' _'[+(!r|r>4)].repeat(r+4)+'\\_'[+!r]],y-r?0:v[x]='@',v.join``),n<11?0:n=11,x=3+n*5,y=5-(n/3|0)).join`
`

Test

f=n=>"       o \\|/ | / -".match(/.../g).map((v,r)=>(v=[...v+' '.repeat(50)+'| '[+!r]+' _'[+(!r|r>4)].repeat(r+4)+'\\_'[+!r]],y-r?0:v[x]='@',v.join``),n<11?0:n=11,x=3+n*5,y=5-(n/3|0)).join`
`
var n=0

setInterval(function(){
  N.textContent=n,O.textContent=f(n),n=(n+1)&15
},1000)
<pre id=O></pre><span id=N></span>

\$\endgroup\$
  • \$\begingroup\$ Your snippet doesn't work for me. I just get an error saying "Script error." \$\endgroup\$ – Zizouz212 Jun 22 '16 at 20:20
  • \$\begingroup\$ @Zizouz212 what browser? Is it ES6 compatible? kangax.github.io/compat-table/es6 \$\endgroup\$ – edc65 Jun 23 '16 at 6:13
  • \$\begingroup\$ @edc65 Ah. My fault then. I use Safari :/ \$\endgroup\$ – Zizouz212 Jun 23 '16 at 12:03

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.