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 »
Sandbox

Post History

75%
+4 −0
Sandbox Find the IP address class [FINALIZED]

posted 2y ago by Razetime‭  ·  edited 11mo ago by trichoplax‭

#6: Post edited by user avatar trichoplax‭ · 2023-06-19T10:24:45Z (11 months ago)
Add finalized tag now that the sandbox can be filtered to exclude tags
Find the IP address class [FINALIZED]
# Task 
Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)

For reference, here is a table:


<table class="wikitable" style="width: 855px;">
<tbody>
<tr>
<th style="width: 92px;">Class</th>
<th style="width: 45px;">Leading<br>bits</th>
<th style="width: 175px;">Number<br>of networks</th>
<th style="width: 160px;">Addresses<br>per network</th>
<th style="width: 29px;">Total addresses<br>in class</th>
<th style="width: 43px;">Start address</th>
<th style="width: 146px;">End address</th>
</tr>
<tr>
<td style="width: 92px;">Class A</td>
<td style="width: 45px;">0</td>
<td style="width: 175px;">128 (2<sup>7</sup>)</td>
<td style="width: 160px;">16,777,216 (2<sup>24</sup>)</td>
<td style="width: 29px;">2,147,483,648 (2<sup>31</sup>)</td>
<td style="width: 43px;">0.0.0.0</td>
<td style="width: 146px;">127.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class B</td>
<td style="width: 45px;">10</td>
<td style="width: 175px;">16,384 (2<sup>14</sup>)</td>
<td style="width: 160px;">65,536 (2<sup>16</sup>)</td>
<td style="width: 29px;">1,073,741,824 (2<sup>30</sup>)</td>
<td style="width: 43px;">128.0.0.0</td>
<td style="width: 146px;">191.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class C</td>
<td style="width: 45px;">110</td>
<td style="width: 175px;">2,097,152 (2<sup>21</sup>)</td>
<td style="width: 160px;">256 (2<sup>8</sup>)</td>
<td style="width: 29px;">536,870,912 (2<sup>29</sup>)</td>
<td style="width: 43px;">192.0.0.0</td>
<td style="width: 146px;">223.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class D (multicast)</td>
<td style="width: 45px;">1110</td>
<td style="width: 175px;">not defined</td>
<td style="width: 160px;">not defined</td>
<td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
<td style="width: 43px;">224.0.0.0</td>
<td style="width: 146px;">239.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class E (reserved)</td>
<td style="width: 45px;">1111</td>
<td style="width: 175px;">not defined</td>
<td style="width: 160px;">not defined</td>
<td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
<td style="width: 43px;">240.0.0.0</td>
<td style="width: 146px;">255.255.255.255</td>
</tr>
</tbody>
</table>


The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.

- The given IP will always be valid, and ti will always be a string.
- IP will not have insignificant zeroes.
- IP will not be in any form other than IPv4 dot notation. 

# Rules
This is code-golf. Shortest answer in each language wins.
#5: Post edited by user avatar Razetime‭ · 2021-12-07T12:44:32Z (over 2 years ago)
  • Find the IP address class
  • Find the IP address class [FINALIZED]
#4: Post edited by user avatar Razetime‭ · 2021-11-15T08:44:45Z (over 2 years ago)
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">0</td>
  • <td style="width: 175px;">128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">10</td>
  • <td style="width: 175px;">16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">110</td>
  • <td style="width: 175px;">2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">1110</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">1111</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">0</td>
  • <td style="width: 175px;">128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">10</td>
  • <td style="width: 175px;">16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">110</td>
  • <td style="width: 175px;">2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">1110</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">1111</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • - The given IP will always be valid, and ti will always be a string.
  • - IP will not have insignificant zeroes.
  • - IP will not be in any form other than IPv4 dot notation.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
#3: Post edited by user avatar Razetime‭ · 2021-11-06T03:58:02Z (over 2 years ago)
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;0</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;10</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;110</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1110</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1111</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">0</td>
  • <td style="width: 175px;">128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">10</td>
  • <td style="width: 175px;">16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">110</td>
  • <td style="width: 175px;">2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">1110</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">1111</td>
  • <td style="width: 175px;">not defined</td>
  • <td style="width: 160px;">not defined</td>
  • <td style="width: 29px;">268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
#2: Post edited by user avatar Razetime‭ · 2021-11-06T03:53:43Z (over 2 years ago)
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 90px;">Size of <em>network<br>number</em> bit field</th>
  • <th style="width: 66px;">Size of <em>rest</em><br>bit field</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;0</td>
  • <td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;8</td>
  • <td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;24</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;10</td>
  • <td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;16</td>
  • <td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;16</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;110</td>
  • <td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;24</td>
  • <td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;8</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1110</td>
  • <td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1111</td>
  • <td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
  • # Task
  • Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)
  • For reference, here is a table:
  • <table class="wikitable" style="width: 855px;">
  • <tbody>
  • <tr>
  • <th style="width: 92px;">Class</th>
  • <th style="width: 45px;">Leading<br>bits</th>
  • <th style="width: 175px;">Number<br>of networks</th>
  • <th style="width: 160px;">Addresses<br>per network</th>
  • <th style="width: 29px;">Total addresses<br>in class</th>
  • <th style="width: 43px;">Start address</th>
  • <th style="width: 146px;">End address</th>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class A</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;0</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;128 (2<sup>7</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;16,777,216 (2<sup>24</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;2,147,483,648 (2<sup>31</sup>)</td>
  • <td style="width: 43px;">0.0.0.0</td>
  • <td style="width: 146px;">127.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class B</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;10</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;16,384 (2<sup>14</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;65,536 (2<sup>16</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;1,073,741,824 (2<sup>30</sup>)</td>
  • <td style="width: 43px;">128.0.0.0</td>
  • <td style="width: 146px;">191.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class C</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;110</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;2,097,152 (2<sup>21</sup>)</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;256 (2<sup>8</sup>)</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;536,870,912 (2<sup>29</sup>)</td>
  • <td style="width: 43px;">192.0.0.0</td>
  • <td style="width: 146px;">223.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class D (multicast)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1110</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">224.0.0.0</td>
  • <td style="width: 146px;">239.255.255.255</td>
  • </tr>
  • <tr>
  • <td style="width: 92px;">Class E (reserved)</td>
  • <td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1111</td>
  • <td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
  • <td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
  • <td style="width: 43px;">240.0.0.0</td>
  • <td style="width: 146px;">255.255.255.255</td>
  • </tr>
  • </tbody>
  • </table>
  • The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.
  • # Rules
  • This is code-golf. Shortest answer in each language wins.
#1: Initial revision by user avatar Razetime‭ · 2021-11-05T13:39:51Z (over 2 years ago)
Find the IP address class
# Task 
Given an IP address as a string, find its [IP address class.](https://www.guru99.com/ip-address-classes.html)

For reference, here is a table:

<table class="wikitable" style="width: 855px;">
<tbody>
<tr>
<th style="width: 92px;">Class</th>
<th style="width: 45px;">Leading<br>bits</th>
<th style="width: 90px;">Size of <em>network<br>number</em> bit field</th>
<th style="width: 66px;">Size of <em>rest</em><br>bit field</th>
<th style="width: 175px;">Number<br>of networks</th>
<th style="width: 160px;">Addresses<br>per network</th>
<th style="width: 29px;">Total addresses<br>in class</th>
<th style="width: 43px;">Start address</th>
<th style="width: 146px;">End address</th>
</tr>
<tr>
<td style="width: 92px;">Class A</td>
<td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;0</td>
<td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;8</td>
<td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;24</td>
<td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;128 (2<sup>7</sup>)</td>
<td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;16,777,216 (2<sup>24</sup>)</td>
<td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;2,147,483,648 (2<sup>31</sup>)</td>
<td style="width: 43px;">0.0.0.0</td>
<td style="width: 146px;">127.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class B</td>
<td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;10</td>
<td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;16</td>
<td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;16</td>
<td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;16,384 (2<sup>14</sup>)</td>
<td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;65,536 (2<sup>16</sup>)</td>
<td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;1,073,741,824 (2<sup>30</sup>)</td>
<td style="width: 43px;">128.0.0.0</td>
<td style="width: 146px;">191.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class C</td>
<td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;110</td>
<td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;24</td>
<td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;8</td>
<td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;2,097,152 (2<sup>21</sup>)</td>
<td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;256 (2<sup>8</sup>)</td>
<td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;536,870,912 (2<sup>29</sup>)</td>
<td style="width: 43px;">192.0.0.0</td>
<td style="width: 146px;">223.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class D (multicast)</td>
<td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1110</td>
<td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
<td style="width: 43px;">224.0.0.0</td>
<td style="width: 146px;">239.255.255.255</td>
</tr>
<tr>
<td style="width: 92px;">Class E (reserved)</td>
<td style="width: 45px;">&nbsp;&nbsp;&nbsp;&nbsp;1111</td>
<td style="width: 90px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 66px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 175px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 160px;">&nbsp;&nbsp;&nbsp;&nbsp;not defined</td>
<td style="width: 29px;">&nbsp;&nbsp;&nbsp;&nbsp;268,435,456 (2<sup>28</sup>)</td>
<td style="width: 43px;">240.0.0.0</td>
<td style="width: 146px;">255.255.255.255</td>
</tr>
</tbody>
</table>

The simplest way to find the class of an address is to check the bits of its first octet. Once you find the the answer, you are required to output a character or a codepoint which represents one of the characters A, B, C, D or E.

# Rules
This is code-golf. Shortest answer in each language wins.