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

Return to Answer

Commonmark migration
Source Link

#Python 3.5, (削除) 142 (削除ここまで)(削除) 137 (削除ここまで)(削除) 134 (削除ここまで)(削除) 112 (削除ここまで)(削除) 117 (削除ここまで)(削除) 110 (削除ここまで) 127 bytes:

Python 3.5, (削除) 142 (削除ここまで)(削除) 137 (削除ここまで)(削除) 134 (削除ここまで)(削除) 112 (削除ここまで)(削除) 117 (削除ここまで)(削除) 110 (削除ここまで) 127 bytes:

(+17 bytes, because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで)(削除) 137 (削除ここまで)(削除) 134 (削除ここまで)(削除) 112 (削除ここまで)(削除) 117 (削除ここまで)(削除) 110 (削除ここまで) 127 bytes:

(+17 bytes, because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

Python 3.5, (削除) 142 (削除ここまで)(削除) 137 (削除ここまで)(削除) 134 (削除ここまで)(削除) 112 (削除ここまで)(削除) 117 (削除ここまで)(削除) 110 (削除ここまで) 127 bytes:

(+17 bytes, because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes, because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]
def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]
def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes, because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

added 4 characters in body
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes because apparently even if there words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

#Python 3.5, (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) (削除) 134 (削除ここまで) (削除) 112 (削除ここまで) (削除) 117 (削除ここまで) (削除) 110 (削除ここまで) 127 bytes:

(+17 bytes because apparently even if there are words more frequent than the rest, but they have the same frequency, nothing should still be returned.)

def g(u):import re;q=re.findall(r"\b['\-\w]+\b",u.lower());Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Should now satisfy all conditions. This submission assumes that at least 1 word is input.

Try It Online! (Ideone)

Also, if you want one, here is another version of my function devoid of any regular expressions at the cost of about 43 bytes, though this one is non-competitive anyways, so it does not really matter. I just put it here for the heck of it:

def g(u):import re;q=''.join([i for i in u.lower()if i in[*map(chr,range(97,123)),*"'- "]]).split();Q=q.count;D=[*map(Q,{*q})];return['',max(q,key=Q)][1in map(D.count,D)]

Try this New Version Online! (Ideone)

Updated second version of function
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
deleted 2 characters in body
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
added 37 characters in body
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
+17 bytes
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
Added "Try It Online" link for non-competitive version of function
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
Added another version of my function avoid of regular expressions (Just for the heck of it)
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
deleted 97 characters in body
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
[Edit removed during grace period]
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
-5 bytes (back to 112 bytes!)
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
+5 bytes because of a small bug fix
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
-22 bytes
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
-5 bytes
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading
Source Link
R. Kap
  • 5k
  • 2
  • 16
  • 38
Loading

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