Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Word Length-Sum Multiples

A port of my other question: Double Prime Words

Consider a word/string of n alphanumeric characters with sum of the characters, s, using their numeric position in the alphabet (a=1, B=2, c=3, etc.) or numeric value (0,1, 2, 3 - 9). Numeric characters should be taken at individual value. (66 is two 6 characters for a sum of 12)

A word is a Length-Sum Multiple if and only if s is a multiple of n, specifically s/n is a positive integer {1,2,3,4...}. In the case of s=0, and n={0,00,000,...}, 0 is a multiple of any n but it does not yield a positive integer. Hence an input of {0,00,000,...} is False.

Input can be any combination of numbers and upper or lower case alphabetic characters, as there is no numeric difference between a or A. Handling empty input, n=s=0, is not required.

Output is any appropriate logical format related to your language. i.e. True or False, T or F, 1 or 0, positive for truthy and 0 for falsy, etc. Specifying what format your output will appear is highly appreciated, but not required. (Output need not include n or s, but I include them below as demonstration and example)

Winning condition: In as few bytes as possible, write a function that is able to determine if a string is a Length-Sum Multiple.

Examples

Input -> Output (n,s) 
hello -> False (5, 52) 
MuLtIpLe -> False (8, 108)
Junct10n -> False (8, 83)
Order66 -> False (7, 72)
CodeGolf -> False (8, 67)
SUM -> False (3, 53)
ID -> False (2, 13)
25 -> False (2, 7)
0 -> False (1, 0) 0/1 = 0 which is not a positive integer
10 -> False (2, 1) 
hello2 -> True (6, 54)
5um -> True (3, 39)
length -> True (6, 66)
Order64 -> True (7, 70)
Covid19 -> True (7, 63)
Word -> True (4, 60)
APPLE -> True (5, 50)
lawYER -> True (6, 84)
abc123 -> True (6, 12)
is -> True (2, 28)
television -> True (10, 130)
19 -> True (2, 10)
234 -> True (3, 9)
a -> True (1, 1)
b -> True (1, 2)
C -> True (1, 3)
Z -> True (1, 26)
1 -> True (1, 1)
9 -> True (1, 9)

Answer*

Draft saved
Draft discarded
Cancel
3
  • 1
    \$\begingroup\$ I had þSDŠKÇžw%«ODIgÖ*Ā - only one byte longer :). \$\endgroup\$ Commented Sep 21, 2020 at 16:04
  • \$\begingroup\$ @ovs Nice. I was actually just looking for some alternatives and found another 16-byter: Asálk>®þ«OD®gÖ*Ā. No 15-byter yet, although I have the feeling it's possible. \$\endgroup\$ Commented Sep 21, 2020 at 16:07
  • \$\begingroup\$ @ovs Actually, I think your approach opens up a 15-byter like this: þIáÇžw%«ODIgÖ*Ā, so thanks. :) \$\endgroup\$ Commented Sep 21, 2020 at 16:09

AltStyle によって変換されたページ (->オリジナル) /