Post History
Python 3, 56 bytes lambda x:chr(65+f'{int(float(x[:3]))&~8:08b}'.find('0')) Try it online! Takes in the ip address as a string and returns the classification letter. Explanation: x[:...
Answer
#14: Post edited
# [Python3](https://www.python.org/), 59 bytes```pythonlambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))```[Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- `x[:x.find(".")]` extracts everything before the first `'.'` character- `int(…)` converts `str` to `int`- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `117` becomes `'01110101'`)
- - `….find('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python 3], 56 bytes
- <!-- language-all: lang-python -->
- lambda x:chr(65+f'{int(float(x[:3]))&~8:08b}'.find('0'))
- [Try it online!][TIO-kyyvrix6]
- [Python 3]: https://docs.python.org/3/
- [TIO-kyyvrix6]: https://tio.run/##XZDNDoIwEITvPEXjwbbRbNpt@SnGJ1EO@NNAgkCgBwzBV0c0BtTd7By@TCaZre8uq0o12v1xLNLb6ZKSLj5nDQv8jaV9Xjpmiyp1rDvEKuF8/YhiEZ0GCjYvL4wKyvnorq07p@21JXty8Mg0VApAAUqAFnT7QRiCmFYuIAKJoNSk4QyNBGMAff1lNAgyiEAjzD5E9ZuGqP@AMn9Ai1dEYEAuzPfh66iXeJ6tGuJIXpK5V/w21837HaveMseHqWvvhhXfjU8 "Python 3 – Try It Online"
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:3]` extracts the first 3 characters
- - `int(float(…))` converts `str` to `int`, passing through `float` to handle cases like `1.2.3.4` -> `1.2` -> `1`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `117` becomes `'01110101'`)
- - `….find('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#13: Post edited
- # [Python3](https://www.python.org/), 59 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `117` becomes `'01110101'`)
- `….index('0')` finds the index of the first `'0'` character- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 59 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `117` becomes `'01110101'`)
- - `….find('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#12: Post edited
- # [Python3](https://www.python.org/), 59 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 59 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `117` becomes `'01110101'`)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#11: Post edited
# [Python3](https://www.python.org/), 60 bytes- ```python
lambda x:chr(65+f'{int(x[:x.find(".")])&240:08b}'.find('0'))- ```
[Try it online!](https://tio.run/##XZDBDoIwEETvfEXDwdJoNtttQYrxS5QDoo0kigZ6wBC@HUENKrvZObxMJpm9P9z5Vqrebvf9JbsejhlrkvxcBVG4tLwtShc0u6QBW5THwAdfpGJBGhOMDx1/U45ciN6dapdn9almW7bz2DBcIhCCQtDIVx9Ea8Bh5RfEIAmUGnQ9QSPBGKBQ/xgNgYxi0ASTj0j9pxHpGVBmBjSOEZEB@WVhCD/HvdTz7K1ijhUlm3olL/O9Gl9i/dYGTnRD19Z1vtj0Tw "Python 3 – Try It Online")- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- `…&240` sets the last 4 bits of the integer to `0`- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 59 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&~8:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDNDoIwEITvPEXDwdJoNu22IMXwJOoBkAYSRQI9YAi@OuJPEN3NzuHLZJLZ@maLayVHEx/Gc3JJTwnpoqxovMBfG9qXlfW6fdSBKauT54LLjmx1DyMepgN9Q8opY6PNW5slbd6SmOwdMg0VHJCD5KA43XwQboFPK74gBIEg5aTbGWoBWgP6amHUCCIIQSHMPkT5m4ao/oDUf0DxZ0SgQXyZ78PiqHN0HHNtiCVlReZe0ctcN8@PGLc3nmXD1LW3g8t24wM "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&~8` sets the 8 bit (fourth to last) of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#10: Post edited
# [Python3](https://www.python.org/), 62 bytes- ```python
lambda x:chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))- ```
[Try it online!](https://tio.run/##XZDLDoIwEEX3fEXDpm00k@m0IMXHj6gLfDSSKBDoAkP4dkRj8DGTuYuTm5vcqe7@UhZ6cOvdcM1uh1PG2vR4qUUczRzv8sKLFprqmnsRQii3uJebjVmtTIrJoefg8uIkOHIpB39u/DFrzg1bs23AxuEKgRA0gkE@fyNaAI6rPiABRaD1qIsJWgXWAkXmy2gJVJyAIZh8RPo3jcj8AW3/gMFnRGxBfVgUwdfxYB8ErqyZZ3nBpl7py1zVz6e4sHPCy37s2vk@lMvhAQ "Python 3 – Try It Online")- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- `x.split('.')[0]` extracts everything before the first `'.'` character- - `int(…)` converts `str` to `int`
- `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 60 bytes
- ```python
- lambda x:chr(65+f'{int(x[:x.find(".")])&240:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDBDoIwEETvfEXDwdJoNtttQYrxS5QDoo0kigZ6wBC@HUENKrvZObxMJpm9P9z5Vqrebvf9JbsejhlrkvxcBVG4tLwtShc0u6QBW5THwAdfpGJBGhOMDx1/U45ciN6dapdn9almW7bz2DBcIhCCQtDIVx9Ea8Bh5RfEIAmUGnQ9QSPBGKBQ/xgNgYxi0ASTj0j9pxHpGVBmBjSOEZEB@WVhCD/HvdTz7K1ijhUlm3olL/O9Gl9i/dYGTnRD19Z1vtj0Tw "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x[:x.find(".")]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…&240` sets the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#9: Post edited
# [Python3](https://www.python.org/), 69 bytes- ```python
def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))- ```
[Try it online!](https://tio.run/##XZDBasMwEETv/grhiyRaltVKdiw3zY@EHNrEIoaiGHkLMcbf7jqlOGl22Tk8hoHZbuDzJdp5PjVBDOqq69Twd4rieE6qLF6CHNvI6gp999WyyiHXezzo3c5tt67G6nOSENp4UhKl1jM3PR8/@qYX72KfiWWkQSAEi@BQvv4h2gAua@6gAkNg7aKbFXoD3gMV7sHoCUxZgSNYfUT2fxqRewLWPwGHt4jSg7mzooCHk9khy8IlCRZtFGuv@tfcpdtTQj4OivW0dB15yvXb/AM "Python 3 – Try It Online")Creates a function `y` which takes in the ip address as a string and returns the classification letter.- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 62 bytes
- ```python
- lambda x:chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDLDoIwEEX3fEXDpm00k@m0IMXHj6gLfDSSKBDoAkP4dkRj8DGTuYuTm5vcqe7@UhZ6cOvdcM1uh1PG2vR4qUUczRzv8sKLFprqmnsRQii3uJebjVmtTIrJoefg8uIkOHIpB39u/DFrzg1bs23AxuEKgRA0gkE@fyNaAI6rPiABRaD1qIsJWgXWAkXmy2gJVJyAIZh8RPo3jcj8AW3/gMFnRGxBfVgUwdfxYB8ErqyZZ3nBpl7py1zVz6e4sHPCy37s2vk@lMvhAQ "Python 3 – Try It Online")
- Takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#8: Post edited
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
[Try it online!](https://tio.run/##Zc5dC4IwFAbg@36FeLON4HD24cfM/CPRTakkhIkZKOJvNyVcUxkbnJfnPazqmserlOOYZrnT0ZZFddZ86tK5P2rqe8ec9EXZ0Bbe1bNoqAsuu@CVJYmKYxVheBsI5EWZUoKEsbGqZ527HEEgSASFztnpO0qshLDBZaeDsSIAnA5f5DLvXAhcgJTTGxhrZVuvOWgNwlP/1Va00wK4H4ISYJZb0UYLoVZ/NvPWKZzrvgZuqBVtteeBdZfCOv11xi8)- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##XZDBasMwEETv/grhiyRaltVKdiw3zY@EHNrEIoaiGHkLMcbf7jqlOGl22Tk8hoHZbuDzJdp5PjVBDOqq69Twd4rieE6qLF6CHNvI6gp999WyyiHXezzo3c5tt67G6nOSENp4UhKl1jM3PR8/@qYX72KfiWWkQSAEi@BQvv4h2gAua@6gAkNg7aKbFXoD3gMV7sHoCUxZgSNYfUT2fxqRewLWPwGHt4jSg7mzooCHk9khy8IlCRZtFGuv@tfcpdtTQj4OivW0dB15yvXb/AM "Python 3 – Try It Online")
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#7: Post edited
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- [Try it online!](https://tio.run/##Zc5dC4IwFAbg@36FeLON4HD24cfM/CPRTakkhIkZKOJvNyVcUxkbnJfnPazqmserlOOYZrnT0ZZFddZ86tK5P2rqe8ec9EXZ0Bbe1bNoqAsuu@CVJYmKYxVheBsI5EWZUoKEsbGqZ527HEEgSASFztnpO0qshLDBZaeDsSIAnA5f5DLvXAhcgJTTGxhrZVuvOWgNwlP/1Va00wK4H4ISYJZb0UYLoVZ/NvPWKZzrvgZuqBVtteeBdZfCOv11xi8)
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#6: Post edited
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- `…>>4<<4` uses bitshift operations to "round down" to the nearest classification cutoff point- `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `236` becomes `'11100000'` after rounding down in the last step)- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to set the last 4 bits of the integer to `0`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `125` becomes `'01110000'` after taking into account the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#5: Post edited
# [Python3](https://www.python.org/), 77 bytes- ```python
def y(x):return chr(64+(f'{int(x.split(".")[0]):08b}'[:4].find('0')+1 or 5))- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)- `[:4]` keeps only the first 4 digits of the binary string- - `….index('0')` finds the index of the first `'0'` character
- `64+(…+1 or 5)` converts -1 (not found) to 4 (to put it in the E slot) and adds 65 (the character code for 'A')- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 69 bytes
- ```python
- def y(x):return chr(65+f'{int(x.split(".")[0])>>4<<4:08b}'.find('0'))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `…>>4<<4` uses bitshift operations to "round down" to the nearest classification cutoff point
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `236` becomes `'11100000'` after rounding down in the last step)
- - `….index('0')` finds the index of the first `'0'` character
- - `65+…` adds the character code for 'A'
- - `chr(…)` converts the sum from the previous step to a character
#4: Post edited
# [Python3](https://www.python.org/), 73 bytes- ```python
def y(x):return chr(64+(f'{int(x.split(".")[0]):08b}'.find('0')+1 or 5))- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)
- - `….index('0')` finds the index of the first `'0'` character
- - `64+(…+1 or 5)` converts -1 (not found) to 4 (to put it in the E slot) and adds 65 (the character code for 'A')
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 77 bytes
- ```python
- def y(x):return chr(64+(f'{int(x.split(".")[0]):08b}'[:4].find('0')+1 or 5))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)
- - `[:4]` keeps only the first 4 digits of the binary string
- - `….index('0')` finds the index of the first `'0'` character
- - `64+(…+1 or 5)` converts -1 (not found) to 4 (to put it in the E slot) and adds 65 (the character code for 'A')
- - `chr(…)` converts the sum from the previous step to a character
#3: Post edited
# [Python3](https://www.python.org/), 64 bytes```def y(x):return chr(65+f'{int(x.split(".")[0]):08b}'.index('0'))- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)
- `65 + ….index('0')` finds the index of the first `'0'` character and adds 65 (the character code for 'A')- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 73 bytes
- ```python
- def y(x):return chr(64+(f'{int(x.split(".")[0]):08b}'.find('0')+1 or 5))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)
- - `….index('0')` finds the index of the first `'0'` character
- - `64+(…+1 or 5)` converts -1 (not found) to 4 (to put it in the E slot) and adds 65 (the character code for 'A')
- - `chr(…)` converts the sum from the previous step to a character
#2: Post edited
# [Python3](https://www.python.org/), 69 bytes- ```
def y(x):return chr(65+format(int(x.split('.')[0]),'08b').index('0'))- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- `format(…, '08b')` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)- - `65 + ….index('0')` finds the index of the first `'0'` character and adds 65 (the character code for 'A')
- - `chr(…)` converts the sum from the previous step to a character
- # [Python3](https://www.python.org/), 64 bytes
- ```
- def y(x):return chr(65+f'{int(x.split(".")[0]):08b}'.index('0'))
- ```
- Creates a function `y` which takes in the ip address as a string and returns the classification letter.
- ## Explanation:
- - `x.split('.')[0]` extracts everything before the first `'.'` character
- - `int(…)` converts `str` to `int`
- - `f'{…:08b}'` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`)
- - `65 + ….index('0')` finds the index of the first `'0'` character and adds 65 (the character code for 'A')
- - `chr(…)` converts the sum from the previous step to a character
#1: Initial revision
# [Python3](https://www.python.org/), 69 bytes ``` def y(x):return chr(65+format(int(x.split('.')[0]),'08b').index('0')) ``` Creates a function `y` which takes in the ip address as a string and returns the classification letter. ## Explanation: - `x.split('.')[0]` extracts everything before the first `'.'` character - `int(…)` converts `str` to `int` - `format(…, '08b')` converts the integer to a binary string, left-padded to 8 characters (e.g. `192` becomes `'11000000'` and `4` becomes `'00000100'`) - `65 + ….index('0')` finds the index of the first `'0'` character and adds 65 (the character code for 'A') - `chr(…)` converts the sum from the previous step to a character