Skip to main content
improved solution
Source Link
Jakque
  • 2.7k
  • 7
  • 13

Python 3.8 (pre-release)Python 3, 7568 bytes

lambda x:re.findall(f"^{'*'.join(map26*'%c*'}$"%(chr,range*range(65,91)),)}*$",x,10)
import re

Try it online!Try it online!

Python had already a solution (here) but it didn't worked on tests with char like (éèàÈ...).

How it works :

  • re.findall returns all the occurences of a given pattern in a given string.
  • f"^{'*'.join(map26*'%c*'}$"%(chr,range*range(65,91)),)}*$" produce the pattern ^A*B*C*...Y*Z*$ which will match any upper abecedarian upper word.
  • 10 (=2|8) passed in argument to re.findall sets the flag re.IGNORECASE (=2) to disable caseCheck in the string and the flag re.MULTILINE (=8) which apply the pattern to each line of the string.

Python 3.8 (pre-release), 75 bytes

lambda x:re.findall(f"^{'*'.join(map(chr,range(65,91)))}*$",x,10)
import re

Try it online!

Python had already a solution (here) but it didn't worked on tests with char like (éèàÈ...).

How it works :

  • re.findall returns all the occurences of a given pattern in a given string.
  • f"^{'*'.join(map(chr,range(65,91)))}*$" produce the pattern ^A*B*C*...Y*Z*$ which will match any upper abecedarian upper word.
  • 10 (=2|8) passed in argument to re.findall sets the flag re.IGNORECASE (=2) to disable caseCheck in the string and the flag re.MULTILINE (=8) which apply the pattern to each line of the string.

Python 3, 68 bytes

lambda x:re.findall(f"^{26*'%c*'}$"%(*range(65,91),),x,10)
import re

Try it online!

Python had already a solution (here) but it didn't worked on tests with char like (éèàÈ...).

How it works :

  • re.findall returns all the occurences of a given pattern in a given string.
  • f"^{26*'%c*'}$"%(*range(65,91),) produce the pattern ^A*B*C*...Y*Z*$ which will match any upper abecedarian word.
  • 10 (=2|8) passed in argument to re.findall sets the flag re.IGNORECASE (=2) to disable caseCheck in the string and the flag re.MULTILINE (=8) which apply the pattern to each line of the string.
Source Link
Jakque
  • 2.7k
  • 7
  • 13

Python 3.8 (pre-release), 75 bytes

lambda x:re.findall(f"^{'*'.join(map(chr,range(65,91)))}*$",x,10)
import re

Try it online!

Python had already a solution (here) but it didn't worked on tests with char like (éèàÈ...).

How it works :

  • re.findall returns all the occurences of a given pattern in a given string.
  • f"^{'*'.join(map(chr,range(65,91)))}*$" produce the pattern ^A*B*C*...Y*Z*$ which will match any upper abecedarian upper word.
  • 10 (=2|8) passed in argument to re.findall sets the flag re.IGNORECASE (=2) to disable caseCheck in the string and the flag re.MULTILINE (=8) which apply the pattern to each line of the string.