prompt
string
response
string
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.*; public class Solution{ static boolean is_equal_shift(String s, int i){ int n=s.length(); String t; t=s.substring(i,n)+s.substring(0,i); if(t.equals(s))return true; else return false; } public static void main(String[] args) { Scanner in = new Scanner(Sy...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { set<string> ss; char s[100]; string tmp; scanf("%s", s); tmp = s; ss.insert(tmp); int n = tmp.size(); for (int i = 0; i < n; i++) { tmp = tmp.substr(1) + tmp[0]; ss.insert(tmp); } printf("%d\n", (int)ss.size()); }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() d = set() for _ in range(len(s)): d.add(s) s = s[-1] + s[:-1] print(len(d))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, l, k = 0, flag = 0, x; char str[51], str1[100][51], m, n; cin >> str; l = strlen(str); strcpy(str1[k++], str); int t = 1; for (i = 0; i < l - 1; i++) { for (x = l - 1; x >= 1; x--) { m = str[x]; n = str[x - 1]; str[...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() n = len(s) word_set = set() word_set.add(s) for i in range(n-1): s = s[-1] + s[:n-1] word_set.add(s) print(len(word_set))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() st = set() l = len(s) for i in range(l): st.add(s[l-i:] + s[:l-i]) print(len(st))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; map<string, long long> h; string s, l; long long i, n, t; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); ; cin >> s; n = s.size(); t++; h[s]++; while (n > 1) { l = ""; for (i = 0; i < s.size() - 1; i++) l += s[i]; s =...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> int main() { char in[100], arr[100]; int rs = 0, p; scanf("%s", in); strcpy(arr, in); int len = strlen(in); while (1) { rs++; char a = arr[0]; for (p = 0; p < len - 1; p++) { arr[p] = arr[p + 1]; } arr[len - 1] = a; if (strcmp(in, arr) == 0) break; } ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); ; long long count = 1; char s[100][100]; long long len; scanf("%s", s[0]); len = strlen(s[0]); for (long long int i = 1; i < len; i++) { s[i][0] = s[i - 1][len - 1]; for (int j = 1; j < len; j++) { s[i...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word=raw_input() tot=[word] n=len(word) sumo=1 for i in range(0,n-1): word=list(word) char = word[0] del word[0] word.append(char) delimiter='' word = delimiter.join(word) if word not in tot: sumo = sumo + 1 tot.append(word) print sumo
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int n = str.length(); set<string> s; s.insert(str); for (int i = 0; i < n; i++) { string t = str[n - 1] + str.substr(0, n - 1); s.insert(t); str = t; } cout << s.size(); }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); string s; cin >> s; set<string> st; st.insert(s); int n = (int)s.size(); for (int i = 0; i < (int)s.size(); i++) { char tmp = s[(int)s.size() - 1]; s.erase(n - 1, 1); s.insert(0, 1, tmp); st.insert(s); } ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() n = len(s) s *= 2 print len(set([s[i:n+i] for i in range(n)]))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=raw_input() s.split() n=len(s) x=s[:] i=0 l=[s,] count=1 while i!=n: new=s[n-1]+s[0:n-1] if new!=x and new not in l: count=count+1 l.append(new) s=new[:] i=i+1 print count
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() a = [s] for i in range(len(s) - 1): s = s[-1] + s[0:len(s) - 1] if s not in a: a += [s] print(len(a))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.Scanner; /** * Created by user on 17.12.2016. */ public class ProblemAOlymp { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); String a = scanner.next(); String b = ""; boolean q = true; int l = a.length(); int k =...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
def main(): s = raw_input() dict = {} cur = s for i in range(len(s)): new_s = s[i:] + s[:i] if new_s in dict: pass else: dict[new_s] = 1 print len(dict) if __name__ == '__main__': main()
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.*; public class Test { static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args)throws Exception { Reader.init(System.in); HashSet<String> set = new HashSet(); String s = Reader.next(); int size =...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
n = input() s = [n] b = [] a = len(n)-1 for i in range(-1,-len(n),-1): b+= n[i] s.append("".join(reversed(b))+n[:a]) a -= 1 print(len(list(dict.fromkeys(s))))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() was = [s] prev = s for i in range(len(s)): now = prev[-1] + prev[0:len(s) - 1] if now in was: break prev = now was.append(now) print(len(was))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() d = {} ans = 0 for i in range(len(s)): l = s[:len(s)-1] r = s[len(s)-1] s = r+l if s not in d: d[s] = 0 ans += 1 print(ans)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; const int NMAX = 55; char str[NMAX]; int ans; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); cin >> str; int lg = strlen(str); char S[NMAX], T[NMAX]; strcpy(T, str); S[0] = T[lg - 1]; S[1] = 0; strncat(S, T, lg - 1); while (strcmp(S, str)...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word =input('') wordlist=[word] cnt = 0 for char in word: nw = word[-1]+ word[:-1] # print (word, nw) if nw not in wordlist:wordlist.append(nw) word = nw # print (wordlist) print (len(wordlist))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; set<string> s; int l = a.length(); for (int i = 0; i < l; ++i) { s.insert(a); string k = ""; k += a[l - 1]; for (int j = 0; j < l - 1; ++j) k += a[j]; a = k; } cout << s.size() << endl; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() t = s[:len(s)-1] se = set() for i in range(len(s)-1, 0, -1): st = s[i] + t if st not in se: se.add(st) t = st[:len(st)-1] if s not in se: print(len(se)+1) else: print(len(se))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = str(input()) ss = set() for i in range(len(s)): ss.add(s[i:]+s[0:i]) print(len(ss))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; import java.io.InputStream; /** * Built using CHelpe...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() x = set() x.add(s) index = 0 for i in s: x.add(s[-1] + (s[0:-1])) s = s[-1] + s[0:-1] index += 1 print(len(x))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
line=input() length=len(line) words=[line] for i in range(length): line=line[-1]+line[:(length-1)] if line not in words: words.append(line) print(len(words))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int fact(int n) { if (n == 0) return 1; return n * fact(n - 1); } string t_string(long long x) { stringstream stringstream; stringstream << x; stri...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() res = set() for i in range(len(s)): res.add(s[(-i if i else len(s)):]+s[:len(s)-i]) print(len(res))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() ans = set() n = len(s) for i in range(n): ch = s[len(s)-1] s = s[:len(s)-1] s = ch + s ans.add(s) print(len(ans))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word = input('') list = [word] n = len(word) - 1 for i in range (len(word)): word = word[n] + word[0:n] if word not in list: list.append(word) print (len(list))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.*; import java.math.*; import java.io.*; public class Luck{ public static InputReader sc; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args){ sc=new InputReader(System.in); out=new PrintWriter(System.out); S...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() c = [s] p = 1 t = len(s) x = s * 2 f = 1 while p != len(s) : if x[p:t+p] not in c : c.append(x[p:t+p]) f = f + 1 p = p + 1 print f
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; s += s; int len = s.size() / 2; int cnt = 1; string done = s.substr(0, len); int i = 1; while (s.substr(i, len) != done) { cnt++; i++; } cout << cnt << endl; return ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
def rotate(l, n): return ' '.join(l[n:] + l[:n]) word = list(input()) set_of_words = set() for i in range(len(word)): set_of_words.add(rotate(word, i)) print(len(set_of_words))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Set; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.StringTokenizer; import java.io.BufferedReader; impo...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
# https://codeforces.com/problemset/problem/745/A # 900 s = input() d = {s:1} for _ in range(len(s)-1): s = s[-1:] + s[:-1] d.setdefault(s, 1) print(len(d))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() k = 0 j = '' i = 1 while s != j: if i == 1: j = s i = 0 j = j[-1] + j[:-1] k += 1 print(k)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; set<string> st; int ret, l = s.size(); for (int i = 0; i < l; ++i) { if (st.count(s) <= 0) { ret++; st.insert(s); } s = (s.substr(1, l - 1)).append(s.substr(0, 1)); ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() o = set() for i in range(len(s)): o.add(s) s = s[-1] + s[:-1] #print(s) #it will give the cyclic order print(len(o))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#!/usr/bin/env python3 s = input() s = s+s d = {} for i in range(int(len(s)/2)): d[s[i:i+int(len(s)/2)]] = 1 print(len(d))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.*; import java.io.*; public class Main { static Scanner scan = new Scanner(System.in); static PrintStream out = new PrintStream(System.out); static HashSet<String> hs = new HashSet<String>(); static int count = 0; public static void main(String[] args) { String str = ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
string = input() wordList = set() currString = string[-1] + string[: -1] res = 1 while currString != string: res+=1 currString = currString[-1] + currString[: -1] print(res)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s=in.nextLine(); Vector<String> o=new Vector<String>(); o.add(s); for (int i=0;i<s.length();i++) { s=s.substring(1, s.length())+s.charAt(0); if (!o.contains(s)) {o.add(s);} } ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R385_Div2_A { FastReader in; PrintWriter out; public static void main(String[] args) { new R385_Div2_A().run(); } void run() { in = new FastReader(System.in...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() lS = len(s) res = [s] for i in xrange(lS): a = s[0:-1] b = s[lS - 1] + a if b not in res: res.append(b) s = b print len(res)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
/* * Author- Naitik Dodia * BTech 2nd Year DAIICT */ import java.io.*; import java.math.*; import java.util.*; import javax.print.attribute.SetOfIntegerSyntax; public class Main { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private stati...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; string s; char c; int i, j; map<string, int> m; int main() { cin >> s; m[s]++; for (i = 0; i < s.size(); i++) { c = s[0]; for (j = 0; j < s.size() - 1; j++) { s[j] = s[j + 1]; } s[s.size() - 1] = c; m[s]++; } cout << m.size() << endl; r...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() z = set() for i in range(len(s)): s = s[1:] + s[:1] z.add(s) print(len(z))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() ss = set() for _ in range(len(s)): ss.add(s) s = s[1:] + s[0] print(len(ss))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.*; /** * * @author KASYM */ public class Slova { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scan = new Scanner( System.in); ArrayList<String> list = new ArrayList<>(); String slovo = scan.nextLine(); ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
# import sys # sys.stdin=open("input.in","r") s=input() l=set() for i in range(len(s)): l.add(s[i:]+s[:i]) print(len(l))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; import java.util.StringTokenizer; import java.util.TreeSet; public class A385 { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
string = input() s = set() for i in range(len(string)): if string not in s: s.add(string) string = string[len(string)-1]+string[:-1] print(len(s))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string s; set<string> se; cin >> s; se.insert(s); for (int i = 1; i < s.size(); ++i) { string ns = string(s.begin(), s.end() - 1); ns = s[s.size() - 1] + ns; s = ns; se.insert(s); } cout << se.size(); return 0; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { map<string, char> used; string s; cin >> s; used[s] = true; int n = s.length(); int ans = 1; for (int i = 0; i < n; i++) { char tmp = s[n - 1]; for (int j = n - 1; j > 0; j--) { s[j] = s[j - 1]; } s[0] = tmp; if (!used[s]...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word=str(input()) n=len(word) alist=[] for i in range(n): new=word[::-1][0:i][::-1]+word[0:n-i] if not new in alist: alist.append(new) print(len(alist))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=input() l = [] l.append(s) for i in range(0,len(s)): new = s[-1]+s[:len(s)-1] if new not in l: l.append(new) s = new print(len(l))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string in; cin >> in; vector<string> vec; for (int i = 0; i < in.length(); i++) { string tmp = in.substr(i, in.length() - i) + in.substr(0, i); vec.push_back(tmp); } sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), v...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string n, nn; int counter = 1; cin >> n; nn = n; for (int i = n.length() - 1; i > 0; i--) { swap(nn[i], nn[i - 1]); } while (n != nn) { for (int i = n.length() - 1; i > 0; i--) { swap(nn[i], nn[i - 1]); } counter += 1; } ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string s, s1; cin >> s1; s = s1; int count = 0, a; a = s1.length(); for (int i = 0; i < a; i++) { rotate(s.begin(), s.begin() + 1, s.end()); if (s != s1) count++; if (s == s1) { cout << count + 1; return 0; } } }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.Scanner; public class Main { static class Node{ Node[] next = new Node[26]; } public static void main(String[] args) { Scanner input = new Scanner(System.in); char[] arr = input.next().toCharArray(); Node f = new Node(); Node temp = f; for(int i = 0 ; i<arr.length ; i+=1){ if(...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-8; int main() { string str, tmp; while (cin >> str) { set<string> s; for (int i = 0; i < str.length(); ++i) { tmp = str.substr(i) + str.substr(0, i); s.insert(tmp); } cout << s.size() << "\n";...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string x; cin >> x; int n = x.length(); set<string> my; my.insert(x); for (int i = 0; i < n; ++i) { x = x.substr(n - 1) + x.substr(0, n - 1); my.insert(x); } cout << my.size(); }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=raw_input('') l=[] l.append(s) for i in range(len(s)): s=s[-1]+s[:(len(s)-1)] l.append(s) print len(set(l))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStre...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String newStr = sc.nextLine(); String in = ""; ArrayList<String> inc = new ArrayList<>(); inc.add(newStr); for (int i = 0; i < newStr.length(); i++) { ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import sys inp = sys.stdin.readline().split()[0] res = {} n = len(inp) for _ in range(n): res[inp] = 1 inp = inp[1:] + inp[0] print len(res) ''' === bbb --- 1 === abcd --- 4 === yzyz --- 2 === '''
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word = input() cyclone = word count = 0 while True: count += 1 cyclone = cyclone[-1] + cyclone[:-1] if word == cyclone: break print(count)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() table = [s] for x in range(len(s)+10): s1 = list(s) temp = s1[0] s1.append(s1[0]) s1.remove(s1[0]) s = "".join(s1) if s not in table: table.append(s) else: break #print(table) print(len(table))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 3; string str, t; set<string> s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; cin >> str; s.insert(str); for (int i = 0; i < str.size(); i++) { t = ""; t += str[str.size() - 1]; str.erase(str.size() - 1, 1); t +...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.*; public class Main { public static void main(String []args) { Scanner sc = new Scanner(System.in); String string[]=sc.next().split(""); ArrayList<String> name=new ArrayList<>(); HashSet<String> words = new HashSet<String>(); for (int i = 0; i <string.leng...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; public class ProblemA { private int process(String input) { Set<String> set = new HashSet<String>(); for (int i = 0; i < input.length(); i++) { String temp = input.substring(i) + in...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.PrintWriter; import java.util.Scanner; import java.io.InputStream; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub InputStream inputStream = System.in; OutputStrea...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
""" Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. * Readability counts * // Author : raj1307 - Raj Singh // Date...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=input() x=[s[i:]+s[:i] for i in range(len(s))] print(len(set(x)))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.InputMismatchException; import java.util.List; import java.util.Set; import java.util.StringTokeniz...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class Main { static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.*; public class CyclicShift { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); ArrayList<String> strlist = ne...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=input() l=[s] for _ in range(len(s)-1): s=s[1:]+s[0] if s not in l: l.append(s) print(len(l))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
t=input() u=[t] p=1 for k in range(len(t)): s=t[len(t)-1]+t[:len(t)-1] if s not in u: p+=1 u.append(s) t=s else: pass print(p)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.*; public class Solution1{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); String d = scan.nextLine(); String e =d; int i=0,n = d.length(); for(i=1;;i++){ d = d.substring(1,n)+d.substring(0,1); if(d.equals(e)) break; } System.ou...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() all_comb = set() for i in range(len(s)): all_comb.add(s) s = s[1:] + s[0] print(len(all_comb))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { set<string> st; string s; cin >> s; st.insert(s); for (int i = 0; i < s.length(); i++) { std::rotate(s.begin(), s.begin() + s.length() - 1, s.end()); st.insert(s); } cout << st.size(); }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; /*package whatever //do not write package name here */ public final class Solution { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(new BufferedReader(new ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
x, d = raw_input(), set() d.add(x) for i in range(len(x)): s=x[i:]+x[:i] d.add(s) print len(d)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
a=input() b=len(a) n=0 c=list(a) d=0 e=0 f=[a] while n<len(a): d=c[b-1] c.pop() c.insert(0,d) e=str(c) if e not in f: f.append(e) n=n+1 print(len(f)-1)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() a = set() new=s for i in range(len(s)): a.add(new) new = new[-1]+new[0:-1] print(len(a))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = str(input()) def extract(index): result = '' for j in range(len(s)): result += s[index] index += 1 if index == len(s): index = 0 return result List = [] def find(st): for j in range(len(List)): if List[j] == st: return True return False for...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; set<string> words; for (int i = 0; i < s.size(); i++) { s = s[s.size() - 1] + s.substr(0, s.size() - 1); words.insert(s); } cout << words.size() << endl; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
x=raw_input() hist=[] f=x for i in x: f=f[-1]+f[:-1] if(f not in hist): hist+=[f] print len(hist)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { set<string> ss; string s; cin >> s; for (int i = 0; i < s.size(); i++) { ss.insert(s); s += s[0]; s = s.substr(1, s.size() - 1); } cout << ss.size() << endl; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.*; import java.util.Scanner; /** * * @author Arar */ public class JavaApplication13 { public String freq(String s) { int m=0; int c=0; String g=""; ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
a = input() l = [] for i in range(len(a)): s = a[i:] + a[:i] if s not in l: l.append(s) print(len(l))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
string = raw_input() res = [] for i in range(0, len(string)): c = string[len(string)-i:len(string)]+string[0:len(string)-i] if c not in res: res.append(c) print len(res)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int vis[200]; char s[100][100]; int main() { memset(vis, 0, sizeof(vis)); scanf("%s", s[0]); int len = strlen(s[0]); int sum = 0; for (int i = 1; i < len; i++) { for (int j = 0; j < len; j++) { s[i][j] = s[0][(j + i) % len]; } } for (int i = 0; i...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() res = set() for i in range(100): res.add(s) s = s[-1] + s[:-1] print(len(res))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
n=raw_input() l=[] cnt=1 l.append(n) for i in range(len(n)): n=n[len(n)-1:]+n[0:(len(n)-1)] flag=1 for i in l: if i==n: flag=0;break cnt+=flag l.append(n) # print l print cnt