Post History
Python, 344 bytes 534 bytes: This is not golfed in any way. But it's the current winner! def validate_roman_numeral(candidate): invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD",...
Answer
#5: Post edited
- # [Python](https://python.org), 344 bytes
- **534 bytes**:
This is _not_ golfed in any way. But it's the current winner!- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
- # [Python](https://python.org), 344 bytes
- **534 bytes**:
- This is _not_ golfed in any way. ~~But it's the current winner!~~
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
#4: Post edited
# [Python](https://python.org) (344 bytes)- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
- # [Python](https://python.org), 344 bytes
- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
#3: Post edited
- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
- # [Python](https://python.org) (344 bytes)
- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
#2: Post edited
- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
**375 bytes**:- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **534 bytes**:
- This is _not_ golfed in any way. But it's the current winner!
- ``` python
- def validate_roman_numeral(candidate):
- invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"]
- for invalid_string in invalid_strings:
- if invalid_string in candidate:
- return invalid_string
- return "VALID"
- ```
- **379 bytes**:
- Here's a minimal effort golf of the above:
- ``` python
- def v(c):
- i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX']
- for s in i:
- if s in c:
- return s
- return "VALID"
- ```
- **344 bytes**:
- A little more effort:
- ``` python
- def v(c):
- o="VALID"
- for s in 'DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','C'*4,'I'*4,'M'*4,'X'*4:
- if s in c:
- o=s
- return o
- ```
#1: Initial revision
**534 bytes**: This is _not_ golfed in any way. But it's the current winner! ``` python def validate_roman_numeral(candidate): invalid_strings = ["CCCC", "CCD", "CCM", "CDC", "CMC", "CMD", "CMM", "DCD", "DCM", "DD", "DM", "IC", "ID", "IIII", "IIV", "IIX", "IL", "IM", "IVI", "IXC", "IXI", "IXL", "IXV", "IXX", "LC", "LD", "LL", "LM", "LXC", "LXL", "MMMM", "VC", "VD", "VIV", "VIX", "VL", "VM", "VV", "VX", "XCC", "XCD", "XCL", "XCM", "XCX", "XD", "XLX", "XM", "XXC", "XXL", "XXXX"] for invalid_string in invalid_strings: if invalid_string in candidate: return invalid_string return "VALID" ``` **375 bytes**: Here's a minimal effort golf of the above: ``` python def v(c): i=['DD','DM','IC','ID','IL','IM','LC','LD','LL','LM','VC','VD','VL','VM','VV','VX','XD','XM','CCD','CCM','CDC','CMC','CMD','CMM','DCD','DCM','IIV','IIX','IVI','IXC','IXI','IXL','IXV','IXX','LXC','LXL','VIV','VIX','XCC','XCD','XCL','XCM','XCX','XLX','XXC','XXL','CCCC','IIII','MMMM','XXXX'] for s in i: if s in c: return s return "VALID" ```