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 Question

Tweeted twitter.com/StackCodeGolf/status/1612645679049936896
Clarification
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple lines are repeated the same number of times, choose the shortest of them. If multiple lyrics both occur the same number of times and are of equal length, you may choose any of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple lines are repeated the same number of times, choose the shortest of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple lines are repeated the same number of times, choose the shortest of them. If multiple lyrics both occur the same number of times and are of equal length, you may choose any of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

deleted 4 characters in body
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple sentenceslines are repeated the same number of times, choose the shortest of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple sentences are repeated the same number of times, choose the shortest of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple lines are repeated the same number of times, choose the shortest of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

Became Hot Network Question
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90

Guess the song title

I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine1 the title of a song just based on its lyrics.

I'll define the way a song title can be guessed as the line repeated in its lyrics the most times. If multiple sentences are repeated the same number of times, choose the shortest of them.

Given an input of a multiline string where each line is a lyric (you may take input as a list of lines), output the predicted title of the song, using the method outlined above.

For example, say this totally real song was stuck in my head and I couldn't remember its name:

Hello, world
Hello, world
I just got to say it, hello world
Goodbye, world
Goodbye, world
Goodbye

I can figure using this formula that the song's title is "Hello, world".

You may assume that the input string will contain no empty lines.

Test cases:

Links go to pastebins of the lyrics, with any " removed.


This is , so shortest code in bytes wins.

1 Accuracy not guaranteed. No refunds.

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