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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid" OR "Get your game on, go play"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, 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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, 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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid" OR "Get your game on, go play"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, 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 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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, 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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, 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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, so shortest code in bytes wins.
1 Accuracy not guaranteed. No refunds.
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:
- Love Me Do → "Love, love me do"
- God Only Knows → "God only knows what I'd be without you"
- Never Gonna Give You Up → "Never gonna give you up"
- All Star → "Get the show on, get paid"
Links go to pastebins of the lyrics, with any " removed.
This is code-golf, so shortest code in bytes wins.
1 Accuracy not guaranteed. No refunds.