Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges Circle of text characters

Given a radius R, output a text representation of a circle. Input A positive integer R (strictly greater than zero) You do not need to handle values of R greater than 32 Output A square ...

0 answers  ·  posted 2y ago by trichoplax‭  ·  edited 2y ago by trichoplax‭

Question code-golf string
#2: Post edited by user avatar trichoplax‭ · 2022-10-28T14:26:44Z (about 2 years ago)
Remove clashing word "explanation"
  • Given a radius R, output a text representation of a circle.
  • ## Input
  • - A positive integer R (strictly greater than zero)
  • - You do not need to handle values of R greater than 32
  • ## Output
  • - A square grid of characters of side length 2R + 1
  • - You may choose any 2 distinct characters to represent the foreground (depicting the circle) and the background
  • - The centre of the circle is the centre of the square. That is, the location (R, R) if using zero indexed coordinates
  • - Each foreground character must have a distance from the centre that has either a floor or a ceiling of R. That is, R-1 < distance < R+1. Within a single output, some foreground characters may have a floor of R and some may have a ceiling of R - you do not need to choose one or other consistently
  • - The circle must not have gaps. Specifically, there must be no connected path of horizontally or vertically adjacent background characters joining the centre to any edge of the square. Equivalently, a flood fill from the centre will not reach any of the edges
  • ## Examples
  • Here `.` represents the background and `#` represents the foreground.
  • Using these characters, the rules are equivalent to:
  • - Every `.` must be included in the background
  • - Any `#` may be included in the foreground, but not all of them need to be - some may be left as background provided there are no gaps between the foreground characters
  • This is intended to give the flexibility to allow various different circle drawing approaches to compete.
  • The potential character placements for radius 1 to 10:
  • ```text
  • R = 1
  • ###
  • #.#
  • ###
  • R = 2
  • #####
  • ##.##
  • #...#
  • ##.##
  • #####
  • R = 3
  • .#####.
  • ###.###
  • ##...##
  • #.....#
  • ##...##
  • ###.###
  • .#####.
  • R = 4
  • ..#####..
  • .###.###.
  • ##.....##
  • ##.....##
  • #.......#
  • ##.....##
  • ##.....##
  • .###.###.
  • ..#####..
  • R = 5
  • ..#######..
  • .####.####.
  • ###.....###
  • ##.......##
  • ##.......##
  • #.........#
  • ##.......##
  • ##.......##
  • ###.....###
  • .####.####.
  • ..#######..
  • R = 6
  • ...#######...
  • ..####.####..
  • .##.......##.
  • ##.........##
  • ##.........##
  • ##.........##
  • #...........#
  • ##.........##
  • ##.........##
  • ##.........##
  • .##.......##.
  • ..####.####..
  • ...#######...
  • R = 7
  • ....#######....
  • ..#####.#####..
  • .###.......###.
  • .##.........##.
  • ##...........##
  • ##...........##
  • ##...........##
  • #.............#
  • ##...........##
  • ##...........##
  • ##...........##
  • .##.........##.
  • .###.......###.
  • ..#####.#####..
  • ....#######....
  • R = 8
  • ....#########....
  • ...#####.#####...
  • ..###.......###..
  • .###.........###.
  • ###...........###
  • ##.............##
  • ##.............##
  • ##.............##
  • #...............#
  • ##.............##
  • ##.............##
  • ##.............##
  • ###...........###
  • .###.........###.
  • ..###.......###..
  • ...#####.#####...
  • ....#########....
  • R = 9
  • .....#########.....
  • ....#####.#####....
  • ..####.......####..
  • ..##...........##..
  • .##.............##.
  • ###.............###
  • ##...............##
  • ##...............##
  • ##...............##
  • #.................#
  • ##...............##
  • ##...............##
  • ##...............##
  • ###.............###
  • .##.............##.
  • ..##...........##..
  • ..####.......####..
  • ....#####.#####....
  • .....#########.....
  • R = 10
  • ......#########......
  • ....######.######....
  • ...###.........###...
  • ..###...........###..
  • .###.............###.
  • .##...............##.
  • ##.................##
  • ##.................##
  • ##.................##
  • ##.................##
  • #...................#
  • ##.................##
  • ##.................##
  • ##.................##
  • ##.................##
  • .##...............##.
  • .###.............###.
  • ..###...........###..
  • ...###.........###...
  • ....######.######....
  • ......#########......
  • ```
  • ## Validator
  • You can validate specific outputs with this [text circle validator], which will give an explanation for any failed validations.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [text circle validator]: https://trichoplax.github.io/text-circle-validator/ "Online validator for outputs from this challenge"
  • Given a radius R, output a text representation of a circle.
  • ## Input
  • - A positive integer R (strictly greater than zero)
  • - You do not need to handle values of R greater than 32
  • ## Output
  • - A square grid of characters of side length 2R + 1
  • - You may choose any 2 distinct characters to represent the foreground (depicting the circle) and the background
  • - The centre of the circle is the centre of the square. That is, the location (R, R) if using zero indexed coordinates
  • - Each foreground character must have a distance from the centre that has either a floor or a ceiling of R. That is, R-1 < distance < R+1. Within a single output, some foreground characters may have a floor of R and some may have a ceiling of R - you do not need to choose one or other consistently
  • - The circle must not have gaps. Specifically, there must be no connected path of horizontally or vertically adjacent background characters joining the centre to any edge of the square. Equivalently, a flood fill from the centre will not reach any of the edges
  • ## Examples
  • Here `.` represents the background and `#` represents the foreground.
  • Using these characters, the rules are equivalent to:
  • - Every `.` must be included in the background
  • - Any `#` may be included in the foreground, but not all of them need to be - some may be left as background provided there are no gaps between the foreground characters
  • This is intended to give the flexibility to allow various different circle drawing approaches to compete.
  • The potential character placements for radius 1 to 10:
  • ```text
  • R = 1
  • ###
  • #.#
  • ###
  • R = 2
  • #####
  • ##.##
  • #...#
  • ##.##
  • #####
  • R = 3
  • .#####.
  • ###.###
  • ##...##
  • #.....#
  • ##...##
  • ###.###
  • .#####.
  • R = 4
  • ..#####..
  • .###.###.
  • ##.....##
  • ##.....##
  • #.......#
  • ##.....##
  • ##.....##
  • .###.###.
  • ..#####..
  • R = 5
  • ..#######..
  • .####.####.
  • ###.....###
  • ##.......##
  • ##.......##
  • #.........#
  • ##.......##
  • ##.......##
  • ###.....###
  • .####.####.
  • ..#######..
  • R = 6
  • ...#######...
  • ..####.####..
  • .##.......##.
  • ##.........##
  • ##.........##
  • ##.........##
  • #...........#
  • ##.........##
  • ##.........##
  • ##.........##
  • .##.......##.
  • ..####.####..
  • ...#######...
  • R = 7
  • ....#######....
  • ..#####.#####..
  • .###.......###.
  • .##.........##.
  • ##...........##
  • ##...........##
  • ##...........##
  • #.............#
  • ##...........##
  • ##...........##
  • ##...........##
  • .##.........##.
  • .###.......###.
  • ..#####.#####..
  • ....#######....
  • R = 8
  • ....#########....
  • ...#####.#####...
  • ..###.......###..
  • .###.........###.
  • ###...........###
  • ##.............##
  • ##.............##
  • ##.............##
  • #...............#
  • ##.............##
  • ##.............##
  • ##.............##
  • ###...........###
  • .###.........###.
  • ..###.......###..
  • ...#####.#####...
  • ....#########....
  • R = 9
  • .....#########.....
  • ....#####.#####....
  • ..####.......####..
  • ..##...........##..
  • .##.............##.
  • ###.............###
  • ##...............##
  • ##...............##
  • ##...............##
  • #.................#
  • ##...............##
  • ##...............##
  • ##...............##
  • ###.............###
  • .##.............##.
  • ..##...........##..
  • ..####.......####..
  • ....#####.#####....
  • .....#########.....
  • R = 10
  • ......#########......
  • ....######.######....
  • ...###.........###...
  • ..###...........###..
  • .###.............###.
  • .##...............##.
  • ##.................##
  • ##.................##
  • ##.................##
  • ##.................##
  • #...................#
  • ##.................##
  • ##.................##
  • ##.................##
  • ##.................##
  • .##...............##.
  • .###.............###.
  • ..###...........###..
  • ...###.........###...
  • ....######.######....
  • ......#########......
  • ```
  • ## Validator
  • You can validate specific outputs with this [text circle validator], which will give a reason for any failed validations.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [text circle validator]: https://trichoplax.github.io/text-circle-validator/ "Online validator for outputs from this challenge"
#1: Initial revision by user avatar trichoplax‭ · 2022-10-28T14:22:00Z (about 2 years ago)
Circle of text characters
Given a radius R, output a text representation of a circle.

## Input
- A positive integer R (strictly greater than zero)
- You do not need to handle values of R greater than 32

## Output
- A square grid of characters of side length 2R + 1
- You may choose any 2 distinct characters to represent the foreground (depicting the circle) and the background
- The centre of the circle is the centre of the square. That is, the location (R, R) if using zero indexed coordinates
- Each foreground character must have a distance from the centre that has either a floor or a ceiling of R. That is, R-1 < distance < R+1. Within a single output, some foreground characters may have a floor of R and some may have a ceiling of R - you do not need to choose one or other consistently 
- The circle must not have gaps. Specifically, there must be no connected path of horizontally or vertically adjacent background characters joining the centre to any edge of the square. Equivalently, a flood fill from the centre will not reach any of the edges

## Examples

Here `.` represents the background and `#` represents the foreground.

Using these characters, the rules are equivalent to:
- Every `.` must be included in the background
- Any `#` may be included in the foreground, but not all of them need to be - some may be left as background provided there are no gaps between the foreground characters

This is intended to give the flexibility to allow various different circle drawing approaches to compete.

The potential character placements for radius 1 to 10:

```text
R = 1

###
#.#
###


R = 2

#####
##.##
#...#
##.##
#####


R = 3

.#####.
###.###
##...##
#.....#
##...##
###.###
.#####.


R = 4

..#####..
.###.###.
##.....##
##.....##
#.......#
##.....##
##.....##
.###.###.
..#####..


R = 5

..#######..
.####.####.
###.....###
##.......##
##.......##
#.........#
##.......##
##.......##
###.....###
.####.####.
..#######..


R = 6

...#######...
..####.####..
.##.......##.
##.........##
##.........##
##.........##
#...........#
##.........##
##.........##
##.........##
.##.......##.
..####.####..
...#######...


R = 7

....#######....
..#####.#####..
.###.......###.
.##.........##.
##...........##
##...........##
##...........##
#.............#
##...........##
##...........##
##...........##
.##.........##.
.###.......###.
..#####.#####..
....#######....


R = 8

....#########....
...#####.#####...
..###.......###..
.###.........###.
###...........###
##.............##
##.............##
##.............##
#...............#
##.............##
##.............##
##.............##
###...........###
.###.........###.
..###.......###..
...#####.#####...
....#########....


R = 9

.....#########.....
....#####.#####....
..####.......####..
..##...........##..
.##.............##.
###.............###
##...............##
##...............##
##...............##
#.................#
##...............##
##...............##
##...............##
###.............###
.##.............##.
..##...........##..
..####.......####..
....#####.#####....
.....#########.....


R = 10

......#########......
....######.######....
...###.........###...
..###...........###..
.###.............###.
.##...............##.
##.................##
##.................##
##.................##
##.................##
#...................#
##.................##
##.................##
##.................##
##.................##
.##...............##.
.###.............###.
..###...........###..
...###.........###...
....######.######....
......#########......
```

## Validator
You can validate specific outputs with this [text circle validator], which will give an explanation for any failed validations.

> Explanations are optional, but I'm more likely to upvote answers that have one.

  [text circle validator]: https://trichoplax.github.io/text-circle-validator/ "Online validator for outputs from this challenge"