-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonchallenge14.py
More file actions
59 lines (47 loc) · 1.19 KB
/
Copy pathpythonchallenge14.py
File metadata and controls
59 lines (47 loc) · 1.19 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# http://www.pythonchallenge.com/pc/return/italy.html
import requests
from PIL import Image
import io
image_url = "http://www.pythonchallenge.com/pc/return/wire.png"
headers = {
'Authorization' : 'Basic aHVnZTpmaWxl'
}
response = requests.get(image_url,headers = headers)
img = Image.open(io.BytesIO(response.content))
answer_img = Image.new("RGB",(100,100))
# 1: 10000 이미지를 나눠서 담기
N = 100
x = 0
y = 0
idx = 0
while N > 0 :
# 오른쪽으로 이동(N)
for j in range(N):
answer_img.putpixel((x,y),img.getpixel((idx,0)))
idx = idx + 1
x = x + 1
x = x -1
y = y + 1
# 아래로 이동(N-1)
for j in range(N-1):
answer_img.putpixel((x,y),img.getpixel((idx,0)))
idx = idx + 1
y = y + 1
y = y -1
x = x -1
# 왼쪽으로 이동(N-1)
for j in range(N-1):
answer_img.putpixel((x,y),img.getpixel((idx,0)))
idx = idx + 1
x = x - 1
x = x + 1
y = y - 1
# 위로 이동 (N-2)
for j in range(N-2):
answer_img.putpixel((x,y),img.getpixel((idx,0)))
idx = idx + 1
y = y -1
y = y + 1
x = x + 1
N = N - 2
answer_img.show()