Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 975365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:34:30+00:00 2026-05-16T03:34:30+00:00

Challenge The shortest program by character count that accepts standard input of the form

  • 0

Challenge

The shortest program by character count that accepts standard input of the form X-Y R, with the following guarantees:

  • R is a non-negative decimal number less than or equal to 8
  • X and Y are non-negative angles given in decimal as multiples of 45° (0, 45, 90, 135, etc.)
  • X is less than Y
  • Y is not 360 if X is 0

And produces on standard output an ASCII “arc” from the starting angle X to the ending angle Y of radius R, where:

  • The vertex of the arc is represented by o
  • Angles of 0 and 180 are represented by -
  • Angles of 45 and 225 are represented by /
  • Angles of 90 and 270 are represented by |
  • Angles of 135 and 315 are represented by \
  • The polygonal area enclosed by the two lines is filled with a non-whitespace character.

The program is not required to produce meaningful output if given invalid input. Solutions in any language are allowed, except of course a language written specifically for this challenge, or one that makes unfair use of an external utility. Extraneous horizontal and vertical whitespace is allowed in the output provided that the format of the output remains correct.

Happy golfing!

Numerous Examples

Input:

0-45 8

Output:

        /
       /x
      /xx
     /xxx
    /xxxx
   /xxxxx
  /xxxxxx
 /xxxxxxx
o--------

Input:

0-135 4

Output:

\xxxxxxxx
 \xxxxxxx
  \xxxxxx
   \xxxxx
    o----

Input:

180-360 2

Output:

--o--
xxxxx
xxxxx

Input:

45-90 0

Output:

o

Input:

0-315 2

Output:

xxxxx
xxxxx
xxo--
xxx\
xxxx\
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:34:30+00:00Added an answer on May 16, 2026 at 3:34 am

    Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

    <>=~/-\d+/;for$y(@a=-$'..$'){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \\)[$t%4]:$":o,@a),$/}
    

    Perl using say feature, 161 149 139 chars

    $ echo -n '<>=~/-\d+/;for$y(@a=-$'"'"'..$'"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
    139
    $ perl -E '<>=~/-\d+/;for$y(@a=-$'"'"'..$'"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \\)[$t%4]:$":o,@a}'
    

    Perl without trailing newline, 153 143 chars

    <>=~/-\d+/;for$y(@a=-$'..$'){print$/,map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \\)[$t%4]:$":o,@a}
    

    Original version commented:

    $_=<>;m/(\d+)-(\d+) (\d+)/;$e=$1/45;$f=$2/45; # parse angles and radius, angles are 0-8
    for$y(-$3..$3){                               # loop for each row and col
        for$x(-$3..$3){
                $t=atan2(-$y,$x)/atan2 1,1;   # angle of this point
                $t+=8if($t<0);                # normalize negative angles
                @w=split//,"-/|\\"x2;         # array of ASCII symbols for enclosing lines
                $s.=!$x&&!$y?"o":$t==$e||$t==$f?$w[$t]:$t>$e&&$t<$f?"x":$";
                # if it's origin -> "o", if it's enclosing line, get symbol from array
                # if it's between enclosing angles "x", otherwise space
        }
        $s.=$/;
    }
    print$s;
    

    EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

    EDIT 2: Added version with comments.

    EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

    EDIT 4: Added a shorter version, bending the rules.

    EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

    EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

    EDIT 7: Smarter regexp. Under 200 chars!

    EDIT 8: Lots of small improvements:

    • Inner for loop -> map (1 char)
    • symbol array from split string -> qw (3 chars)
    • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
    • Logical or -> bitwise or (1 char)
    • Regexp improvement (1 char)
    • Use arithmethic for testing negative angles, inspired by Jacob’s answer (5 chars)

    EDIT 9: A little reordering in the conditional operators saves 2 chars.

    EDIT 10: Use barewords for characters.

    EDIT 11: Moved print inside of loop, inspired by Lowjacker’s answer.

    EDIT 12: Added version using say.

    EDIT 13: Reuse angles characters for fill character, as Gwell’s answer does. Output isn’t as nice as Gwell’s though, that would require 5 additional chars 🙂 Also, .. operator doen’t need parentheses.

    EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian’s suggestion to bta’s answer. Add version without the final newline. Updated say version.

    EDIT 15: More inlining. map{block}@a -> map expr,@a.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I challenge you :) I have a process that someone already implemented. I will
I have a SQL challenge that is wracking my brain. I am trying to
I have a challenge I need some input on. I am currently recruiting programmers
Let me explain my challenge. I have a dataset with a datatable that is
I'm facing a design challenge that I just can't seem to solve in a
Today I've been presented with a fun challenge and I want your input on
Faced with the challenge of a new application with which you had free reign
I'm interested in the programming challenge presented by the game Bejewelled. It seems like
For those who like a good WPF binding challenge: I have a nearly functional
I am trying to develop an online translation service (sort of a personal challenge)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.