message stringlengths 2 11.9k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 137 108k | cluster float64 18 18 | __index_level_0__ int64 274 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The input consists of alphabetical characters and digits
In... | instruction | 0 | 63,953 | 18 | 127,906 |
"Correct Solution:
```
def main():
text = input()
len_text = len(text)
pattern = input()
len_pattern = len(pattern)
for i in range(len_text - len_pattern + 1):
if text[i:i+len_pattern] == pattern:
print(i)
return
main()
``` | output | 1 | 63,953 | 18 | 127,907 |
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The input consists of alphabetical characters and digits
In... | instruction | 0 | 63,954 | 18 | 127,908 |
"Correct Solution:
```
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/14/ALDS1_14_A
def solve():
T = input()
P = input()
if len(T) < len(P):
exit()
for index, pos in enumerate(range(len(T) - len(P) + 1)):
if T[pos:pos+len(P)] == P:
print(index)
if __name__ ==... | output | 1 | 63,954 | 18 | 127,909 |
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The input consists of alphabetical characters and digits
In... | instruction | 0 | 63,955 | 18 | 127,910 |
"Correct Solution:
```
T = input()
P = input()
for i in range(len(T)):
if P in T[i:i+len(P)]:
print(i)
else:
pass
``` | output | 1 | 63,955 | 18 | 127,911 |
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The input consists of alphabetical characters and digits
In... | instruction | 0 | 63,956 | 18 | 127,912 |
"Correct Solution:
```
T=input()
P=input()
b=0
while True:
a=T.find(P,b)
if a==-1:
break
print(a)
b=a+1
``` | output | 1 | 63,956 | 18 | 127,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,957 | 18 | 127,914 |
Yes | output | 1 | 63,957 | 18 | 127,915 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,958 | 18 | 127,916 |
Yes | output | 1 | 63,958 | 18 | 127,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,959 | 18 | 127,918 |
Yes | output | 1 | 63,959 | 18 | 127,919 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,960 | 18 | 127,920 |
Yes | output | 1 | 63,960 | 18 | 127,921 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,961 | 18 | 127,922 |
No | output | 1 | 63,961 | 18 | 127,923 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,962 | 18 | 127,924 |
No | output | 1 | 63,962 | 18 | 127,925 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,963 | 18 | 127,926 |
No | output | 1 | 63,963 | 18 | 127,927 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000
* 1 ≤ length of P ≤ 1000
* The ... | instruction | 0 | 63,964 | 18 | 127,928 |
No | output | 1 | 63,964 | 18 | 127,929 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience,... | instruction | 0 | 64,313 | 18 | 128,626 |
Yes | output | 1 | 64,313 | 18 | 128,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience,... | instruction | 0 | 64,316 | 18 | 128,632 |
No | output | 1 | 64,316 | 18 | 128,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience,... | instruction | 0 | 64,318 | 18 | 128,636 |
No | output | 1 | 64,318 | 18 | 128,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience,... | instruction | 0 | 64,319 | 18 | 128,638 |
No | output | 1 | 64,319 | 18 | 128,639 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,490 | 18 | 128,980 |
Yes | output | 1 | 64,490 | 18 | 128,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,491 | 18 | 128,982 |
Yes | output | 1 | 64,491 | 18 | 128,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,492 | 18 | 128,984 |
Yes | output | 1 | 64,492 | 18 | 128,985 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,493 | 18 | 128,986 |
Yes | output | 1 | 64,493 | 18 | 128,987 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,494 | 18 | 128,988 |
No | output | 1 | 64,494 | 18 | 128,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,495 | 18 | 128,990 |
No | output | 1 | 64,495 | 18 | 128,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,496 | 18 | 128,992 |
No | output | 1 | 64,496 | 18 | 128,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination t... | instruction | 0 | 64,497 | 18 | 128,994 |
No | output | 1 | 64,497 | 18 | 128,995 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,584 | 18 | 129,168 |
"Correct Solution:
```
c = input()
print("a" if(c.islower()) else "A")
``` | output | 1 | 64,584 | 18 | 129,169 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,585 | 18 | 129,170 |
"Correct Solution:
```
print("aA"[input()<"a"])
``` | output | 1 | 64,585 | 18 | 129,171 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,586 | 18 | 129,172 |
"Correct Solution:
```
n = input()
print('A') if n.isupper() else print('a')
``` | output | 1 | 64,586 | 18 | 129,173 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,587 | 18 | 129,174 |
"Correct Solution:
```
print('a' if ord(input()) > 90 else 'A')
``` | output | 1 | 64,587 | 18 | 129,175 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,588 | 18 | 129,176 |
"Correct Solution:
```
ans = 'A' if input().isupper() else 'a'
print(ans)
``` | output | 1 | 64,588 | 18 | 129,177 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,589 | 18 | 129,178 |
"Correct Solution:
```
al=input()
print('A' if al.isupper() else 'a')
``` | output | 1 | 64,589 | 18 | 129,179 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,590 | 18 | 129,180 |
"Correct Solution:
```
print("aA"[input().isupper()::2])
``` | output | 1 | 64,590 | 18 | 129,181 |
Provide a correct Python 3 solution for this coding contest problem.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lowercase (`a` - `z`) English letter.
Input
Input is giv... | instruction | 0 | 64,591 | 18 | 129,182 |
"Correct Solution:
```
s = input()
print("A" if s.isupper() else "a")
``` | output | 1 | 64,591 | 18 | 129,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,592 | 18 | 129,184 |
Yes | output | 1 | 64,592 | 18 | 129,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,593 | 18 | 129,186 |
Yes | output | 1 | 64,593 | 18 | 129,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,594 | 18 | 129,188 |
Yes | output | 1 | 64,594 | 18 | 129,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,595 | 18 | 129,190 |
Yes | output | 1 | 64,595 | 18 | 129,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,596 | 18 | 129,192 |
No | output | 1 | 64,596 | 18 | 129,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,597 | 18 | 129,194 |
No | output | 1 | 64,597 | 18 | 129,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,598 | 18 | 129,196 |
No | output | 1 | 64,598 | 18 | 129,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.
Constraints
* \alpha is an uppercase (`A` - `Z`) or lo... | instruction | 0 | 64,599 | 18 | 129,198 |
No | output | 1 | 64,599 | 18 | 129,199 |
Provide a correct Python 3 solution for this coding contest problem.
YAML (YAML Ain't Markup Language) is one of the formats for expressing an object as a character string.
You will be given an object represented by a subset of YAML and a query that specifies the property, so please answer the value of the specified ... | instruction | 0 | 64,784 | 18 | 129,568 |
"Correct Solution:
```
from collections import defaultdict
d = defaultdict(lambda : "no such property")
check, *yaml = list(open(0))
before = []
beforei = []
ka = defaultdict(lambda :-1)
bv = -1
for y in yaml:
y = y.split(":")
vacant = y[0].count(" ")
if bv >= vacant:
for num,b in enumerate(beforei... | output | 1 | 64,784 | 18 | 129,569 |
Provide a correct Python 3 solution for this coding contest problem.
YAML (YAML Ain't Markup Language) is one of the formats for expressing an object as a character string.
You will be given an object represented by a subset of YAML and a query that specifies the property, so please answer the value of the specified ... | instruction | 0 | 64,785 | 18 | 129,570 |
"Correct Solution:
```
#! /usr/bin/env python3
import re
gkey = input()
yaml = {}
opening_key = ['']
opening_ind = [-1]
space_prog = re.compile(r' *')
key_prog = re.compile(r'[a-z\d]+')
while True:
try:
line = input()
except EOFError:
break
indent = len(space_prog.match(line).group())
... | output | 1 | 64,785 | 18 | 129,571 |
Provide a correct Python 3 solution for this coding contest problem.
YAML (YAML Ain't Markup Language) is one of the formats for expressing an object as a character string.
You will be given an object represented by a subset of YAML and a query that specifies the property, so please answer the value of the specified ... | instruction | 0 | 64,786 | 18 | 129,572 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+9
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 64,786 | 18 | 129,573 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,809 | 18 | 129,618 |
"Correct Solution:
```
s=input()
for _ in[0]*int(input()):
a=input().split()
o=a[0];i=int(a[1]);j=int(a[2])+1
if'p'==o[0]:print(s[i:j])
else:
t=a[3]if'p'==o[2]else s[i:j][::-1]
s=s[0:i]+t+s[j:]
``` | output | 1 | 64,809 | 18 | 129,619 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,810 | 18 | 129,620 |
"Correct Solution:
```
x = list(input())
n = int(input())
for i in range(n):
com = input().split()
a = int(com[1])
b = int(com[2])
if com[0] == "print":
print("".join(x[a:b+1]))
elif com[0] == "reverse":
x[a:b+1] = x[a:b+1][::-1]
elif com[0] == "replace":
x[a:b+1] = list(... | output | 1 | 64,810 | 18 | 129,621 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,811 | 18 | 129,622 |
"Correct Solution:
```
s = input()
for i in range(int(input())):
q = input().split()
op, a, b = q[0], int(q[1]), int(q[2])
if op == 'print':
print(s[a : b+1])
elif op == 'reverse':
t = s[a : b+1]
s = s[:a] + t[::-1] + s[b+1:]
elif op == 'replace':
s = s[:a] + q[3] + s... | output | 1 | 64,811 | 18 | 129,623 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,812 | 18 | 129,624 |
"Correct Solution:
```
S = str(input())
for i in range(int(input())):
L = input().split()
o = L[0]
a = int(L[1])
b = int(L[2]) + 1
if len(L) == 4:
p = L[3]
else:
p = 0
if o == "print":
print(S[a:b])
elif o == "reverse":
S = S[:a]+S[a:b][::-1]+S[b:]
el... | output | 1 | 64,812 | 18 | 129,625 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,813 | 18 | 129,626 |
"Correct Solution:
```
s = input()
n = int(input())
for i in range(n):
c = input().split()
a = int(c[1])
b = int(c[2])
if "replace" in c:
s = s[:a] + c[3] + s[b+1:]
if "reverse" in c:
u = s[a:b+1]
s = s[:a] + u[:: -1] +s[b + 1:]
if "print" in c:
print(s[a:b+1], sep = '')
``` | output | 1 | 64,813 | 18 | 129,627 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,814 | 18 | 129,628 |
"Correct Solution:
```
s = input()
q = int(input())
for _ in range(q):
c = input().split()
if c[0] == 'replace':
s = s[:int(c[1])] + c[3] + s[int(c[2])+1:]
elif c[0] == 'reverse':
s = s[:int(c[1])] + s[int(c[1]):int(c[2])+1][::-1] + s[int(c[2])+1:]
else:
print(s[int(c[1]):int(c[2... | output | 1 | 64,814 | 18 | 129,629 |
Provide a correct Python 3 solution for this coding contest problem.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the ... | instruction | 0 | 64,815 | 18 | 129,630 |
"Correct Solution:
```
str = input()
for q in range(int(input())):
com, *num = input().strip().split()
a, b = int(num[0]), int(num[1])
if com == 'print':
print(str[a:b+1])
elif com == 'replace':
str = str[:a] + num[2] + str[b+1:]
else: # com == 'reverse'
str = str[:a] + str[a... | output | 1 | 64,815 | 18 | 129,631 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.