#include <iostream>
#include <string>
#include <string_view>
using namespace std;

// ==================================================
bool est_palindrome(string_view s)
{
  if (s.size() <= 1) return true;
  return (s[0] == s[s.size()-1]) and est_palindrome(s.substr(1,s.size()-2));
  // alternative : s.front() == s.back()
}


string palindromise(string_view s)
{
  string retour(s);

  for(auto c : s) retour = c + retour;

  /* Alternative :
  for(auto c : s) retour.insert(s.size(), {c}); // Notez le « truc » pour convertir le char c en une string
  */

  return retour;
}

// ===== tests ===========================================
// pour éviter le « copié-collé » dans test() ci-dessous
void test_elementaire(string_view s) { 
  cout << '"' << s << "\" : " << est_palindrome(s);
}

// --------------------------------------------------
void test(string_view s) {          // niveau 3
// ou void test(string const& s) {  // niveau 2
// ou void test(string s) {         // niveau 1

  test_elementaire(s);
  cout << " --> ";
  test_elementaire(palindromise(s));
  cout << endl;
}

// =======================================================
int main()
{
  test("abcd");  // non palindrome
  test("rever"); // palindrome impair
  test("elle");  // palindrome pair
  test("abcdefghfedcba"); // non palindrome, mais presque

  // cas limites
  test("");
  test("a");
  test("ab");
  test("aa");

  return 0;
}
