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

60%
+1 −0
Challenges Number of sides on a polygon

Input The name of a polygon. You are only required to handle inputs listed in the test cases. Output The number of edges the polygon has. Test cases Test cases are in the format input...

1 answer  ·  posted 6mo ago by trichoplax‭  ·  last activity 5mo ago by jhnc‭

Question code-golf number string
#1: Initial revision by user avatar trichoplax‭ · 2026-04-04T15:19:54Z (6 months ago)
Number of sides on a polygon
## Input
- The name of a polygon.
- You are only required to handle inputs listed in the test cases.

## Output
- The number of edges the polygon has.

## Test cases
Test cases are in the format `input : output`.

```txt
triangle : 3
trigon : 3
quadrilateral : 4
quadrangle : 4
tetragon : 4
rectangle : 4
square : 4
rhombus : 4
parallelogram : 4
kite : 4
trapezium : 4
pentagon : 5
hexagon : 6
heptagon : 7
septagon : 7
octagon : 8
enneagon : 9
nonagon : 9
decagon : 10
hendecagon : 11
undecagon : 11
dodecagon : 12
triskaidecagon : 13
tridecagon : 13
tetrakaidecagon : 14
tetradecagon : 14
pentakaidecagon : 15
pentadecagon : 15
hexakaidecagon : 16
hexadecagon : 16
heptakaidecagon : 17
heptadecagon : 17
octakaidecagon : 18
octadecagon : 18
enneakaidecagon : 19
enneadecagon : 19
icosagon : 20
```

## Scoring
This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.

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


[code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"