-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1-2.py
More file actions
29 lines (24 loc) · 743 Bytes
/
Copy pathday1-2.py
File metadata and controls
29 lines (24 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
#input function for both python2.7 and 3
def getInput(prompt=''):
try:
line = raw_input(prompt)
except NameError:
line = input(prompt)
return line
captcha = getInput('captcha string: ')
def main(input):
result = []
input_str = str(input)
string_len = len(input_str)
jump_len = len(input_str) // 2
for i in range(len(input_str)):
current_pos = i
next_pos = i + jump_len
next_pos = int(next_pos % string_len)
if input_str[next_pos] == input_str[current_pos]:
result.append(int(input_str[i]))
return sum(result)
print(main(captcha))