top of page

CCC 2016 J3: Hidden Palindrome


Using capabilities of substrings put all possible palindromes into a list. Then using the max() function find the largest palindrome hidden inside the inputted word

A = input()
length = []
for i in range(len(A)):
 for j in range(i,len(A)):
        A2 = A[i:j+1]
 if A2 == A2[::-1]:
            length.append(len(A2))
print(max(length))

Recent Posts

See All

CCC '24 J5 - Harvest Waterloo

#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c, sr, sc; cin >> r; cin >> c; int p[r][c]; bool v

CCC '24 J4 - Troublesome Keys

#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { string ps; string ds; cin >> ps; cin >> ds;

CCC '22 J5 - Square Pool

#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int, int> b){ return a.first < b.first; } bool colcom(pair<int,

コメント


bottom of page