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

added 1708 characters in body
Source Link
lad2025
  • 409
  • 3
  • 7

#PostgreSQL, 246(削除) 246 (削除ここまで), 245 bytes#


EDIT:

Handling ':

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"!',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

SqlFiddleDemo

Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝

#PostgreSQL, 246 bytes#

#PostgreSQL, (削除) 246 (削除ここまで), 245 bytes#


EDIT:

Handling ':

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"!',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

SqlFiddleDemo

Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝
Rollback to Revision 1
Source Link
lad2025
  • 409
  • 3
  • 7

#PostgreSQL, 245246 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"!'"''',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

SqlFiddleDemo

Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝

enter image description here

#PostgreSQL, 245 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"!',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

SqlFiddleDemo

Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝

#PostgreSQL, 246 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"''',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

Output:

enter image description here

added 76 characters in body
Source Link
lad2025
  • 409
  • 3
  • 7

#PostgreSQL, 246245 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"'''"!',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

Output:SqlFiddleDemo

enter image description here Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝

#PostgreSQL, 246 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"''',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

Output:

enter image description here

#PostgreSQL, 245 bytes#

WITH z AS(SELECT DISTINCT*,COUNT(*)OVER(PARTITION BY t,m)c FROM i,regexp_split_to_table(translate(lower(t),'.,"!',''),E'\\s+')m)
SELECT t,CASE WHEN COUNT(*)>1 THEN '' ELSE MAX(m)END
FROM z WHERE(t,c)IN(SELECT t,MAX(c)FROM z GROUP BY t)
GROUP BY t 

SqlFiddleDemo

Output:

╔═══════════════════════════════════════════════════════════════════════════════════════════════╦═══════════════╗
║ t ║ max ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════╬═══════════════╣
║ a a a b b b c ║ ║
║ The old-fashioned man ate an old-fashioned cake. ║ old-fashioned ║
║ IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses. ║ ipv6 ║
║ This sentence has no most frequent word. ║ ║
║ "That's... that's... that is just terrible!" he said. ║ that's ║
║ The man walked down the road. ║ the ║
║ Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy. ║ he ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════╩═══════════════╝
Source Link
lad2025
  • 409
  • 3
  • 7
Loading

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