(This might be too difficult for anyone but a native speaker or a very experienced English speaker).
Simply by adding the punctuation, you can turn this series of words into a sentence that makes sense. It doesn't make much sense, but it makes sense.
Can you punctuate it appropriately?
If but and and were but and and but but would be and and and would be but.
Hint #1: the needed punctuation marks are mostly quotation marks, plus one or two commas.
Hint #2: the riddle depends on the fact that in the finished sentence, sometimes "and" means simply "and," and sometimes it means "the word and." Similarly for "but."
Hint #3: I have read the sentence aloud in the following recording. I have tried to read it in a way that brings out its meaning. Listening to the spoken sentence should tell you how you need to punctuate the written sentence.
Yes, perfect, Kseniia.
With regard to your usage question, "but" can mean "only," "just a little bit," or "no more than." It's not rare, but it's not common, everyday usage.
A good example of use would be a famous (false!) quotation from Nathan Hale. He was an American spy who was hanged by the British during the American Revolutionary war. The legend is that he said:
"I only regret that I have but one life to give for my country."
Thus, he is so willing to give up his life for his country, that he would be willing to do it more than once if that were possible. But, he has "but one life" to give. In this case, "but" means "only."
Other examples of use:
"If he had but taken a second to lock his car, it would not have been stolen." He only needed to do one very small thing.
"There were but a few willing to speak out against injustice."
In the (silly) puzzle sentence, which makes very little sense even when punctuated, the meaning is "not very much is needed; all that is is needed is for these two words to a have their meanings interchanged."
I'm not 100% sure it really makes sense, but I think it has to be something like this (based mostly on the recording, to be honest):
If "but" and "and" were but "and" and "but", "but" would be "and" and "and" would be "but".
But may I please ask a question? I understand everything after the comma but I'm not sure I get this "if they were but" part. Could someone please explain it to me? Does that mean "if they were reversed" or something? Or is it something similar to the "if they were anything but" grammatical construction?
Really? Wow, maybe I'm not hopeless then.
Many thanks for the explanation and the examples! I've managed to find this expression in Shakespeare's "Much Ado About Nothing":
"O Lord, my lord, if they were but a week married,
they would talk themselves mad",
but I didn't know that "but" can also mean "only" in some contexts, and the translation into Russian is also poetic so... Yes, now it's much clearer. Thank you!