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.


Input: BotLand
Output: Bot word

Input: BotLand77
Output: Bot word

Input: 1Bot2Land3
Output: Non Bot word


closed as off-topic by AdmBorkBork, Arnauld, Mr. Xcoder, Kevin Cruijssen, manatwork Aug 26 at 14:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This site is for programming contests and challenges. General programming questions are off-topic here. You may be able to get help on Stack Overflow." – AdmBorkBork, Arnauld, Kevin Cruijssen
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 at 13:37

Python 3, 33 bytes

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

Try it online!

-8 bytes thanks to Grimy and A _

  • \$\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\$ – Mafuj Shikder Aug 26 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 at 13:09
  • 1
    \$\begingroup\$ 36 bytes \$\endgroup\$ – Grimmy Aug 26 at 13:10
  • \$\begingroup\$ @Jitse please solve this problem n c \$\endgroup\$ – Mafuj Shikder Aug 26 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\$ – A _ Aug 26 at 13:36

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