-9
\$\begingroup\$

Programming problem: In BotLand, Robots can understand all words of any combination of letters and letters with leading or trailing (not both) numeric value. Given a word W (string of alphanumeric). Write a function to check if W is Bot word. Don't use library functions/ regex.

Example:

Input: BotLand
Output: Bot word

Input: BotLand77
Output: Bot word

Input: 1Bot2Land3
Output: Non Bot word

\$\endgroup\$
1
  • 6
    \$\begingroup\$ Welcome to CGCC. This site hosts recreational programming challenges, based on an objective winning criterion. (Here, you picked code-golf: the shortest answer wins.) It is not designed to get any practical implementation or theoretical answer. So, is it really supposed to be a challenge? \$\endgroup\$
    – Arnauld
    Aug 26, 2019 at 13:37

1 Answer 1

3
\$\begingroup\$

Python 3, 33 bytes

lambda s:1-(s[0]+s[-1]).isdigit()

Try it online!

-8 bytes thanks to Grimy and A _

\$\endgroup\$
6
  • \$\begingroup\$ Python 3, 41 bytes lambda s:a(s[0])+a(s[-1])>0 a=str.isalpha what is this @Jitse. what is this? \$\endgroup\$ Aug 26, 2019 at 13:07
  • 1
    \$\begingroup\$ @MafujShikder it's a program answering your challenge. You can use the Try it online! link to check that it works. \$\endgroup\$
    – Grimmy
    Aug 26, 2019 at 13:09
  • 1
    \$\begingroup\$ 36 bytes \$\endgroup\$
    – Grimmy
    Aug 26, 2019 at 13:10
  • \$\begingroup\$ @Jitse please solve this problem n c \$\endgroup\$ Aug 26, 2019 at 13:18
  • 2
    \$\begingroup\$ 33B if you use 1 for true and 0 for false. 32B by abusing predefined true/false values even further. \$\endgroup\$
    – user85052
    Aug 26, 2019 at 13:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.