Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit652389c

Browse files
solved 25
1 parent746c000 commit652389c

30 files changed

+71
-7
lines changed

‎25.py

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
importrequests
22
importwave
3+
fromPILimportImage
4+
fromPILimportImageDraw
35

46

57
defmain():
68
seed="http://www.pythonchallenge.com/pc/hex/"
79
file_path="lake/"
810
auth= ("butter","fly")
911
# first_step(seed, file_path, auth)
10-
bs=second_step()
11-
third_step(bs)
12+
# bss = second_step()
13+
# all_pixel = third_step(bss)
14+
# fourth_step(all_pixel)
15+
fifth_step()
1216

1317

1418
deffirst_step(seed,file_path,auth):
@@ -37,21 +41,73 @@ def second_step():
3741
returnbsAry
3842

3943

40-
defthird_step(bs):
44+
defthird_step2(bss):
4145
result_file=wave.open("lake/result.wav","wb")
4246
src_file=wave.open("lake/1.wav","rb")
4347
nframes=src_file.getnframes()
4448
result_file.setnchannels(src_file.getnchannels())
4549
result_file.setsampwidth(src_file.getsampwidth())
4650
result_file.setframerate(src_file.getframerate())
4751
result_file.setnframes(nframes*25)
48-
foriinrange(len(bs)):
49-
b=bs[i]
50-
result_file.writeframesraw(b)
52+
foriinrange(len(bss)):
53+
bs=bss[i]
54+
result_file.writeframesraw(bs)
5155
src_file.close()
5256
result_file.close()
5357
print("Done")
5458

5559

60+
defthird_step(bss):
61+
all_pixel= []
62+
foriinrange(len(bss)):
63+
bs=bss[i]
64+
bs_len=len(bs)
65+
j=0
66+
pixels= []
67+
whileTrue:
68+
ifj>=bs_len:
69+
break;
70+
x=bs[j]
71+
j+=1
72+
ifj>=bs_len:
73+
break;
74+
y=bs[j]
75+
j+=1
76+
ifj>=bs_len:
77+
break;
78+
z=bs[j]
79+
j+=1
80+
pixel= (x,y,z)
81+
pixels.append(pixel)
82+
all_pixel.append(pixels)
83+
print(all_pixel)
84+
returnall_pixel
85+
86+
87+
deffourth_step(all_pixel):
88+
foriinrange(len(all_pixel)):
89+
im=Image.new("RGB", (60,60))
90+
drawer=ImageDraw.Draw(im)
91+
pixels=all_pixel[i]
92+
count=0
93+
forxinrange(60):
94+
foryinrange(60):
95+
print("drawing i={}, count={}, x={}, y={}".format(i,count,x,y))
96+
drawer.point((x,y),pixels[count])
97+
count+=1
98+
im.save("lake/pic/{}.png".format(i))
99+
100+
101+
deffifth_step():
102+
im=Image.new("RGB", (300,300))
103+
foriinrange(25):
104+
x= (i//5)*60
105+
y= (i%5)*60
106+
im_tmp=Image.open("lake/pic/{}.png".format(i))
107+
im.paste(im_tmp, (x,y))
108+
print("i={}, x={}, y={}".format(i,x,y))
109+
im.save("lake/pic/result.png")
110+
111+
56112
if__name__=="__main__":
57113
main()

‎README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#pythonchallenge
22
Solve Problems inhttp://www.pythonchallenge.com
33

4+
5+
####25
6+
result:http://www.pythonchallenge.com/pc/hex/decent.html
7+
8+
- lake1.html means there is a file named with lake2
9+
-**imagine how they sound**
10+
411
####24
512
result:http://www.pythonchallenge.com/pc/hex/lake.html
613
```python

‎lake/pic/0.png

3.8 KB
Loading

‎lake/pic/1.png

3.15 KB
Loading

‎lake/pic/10.png

7.59 KB
Loading

‎lake/pic/11.png

7.93 KB
Loading

‎lake/pic/12.png

7.76 KB
Loading

‎lake/pic/13.png

7.5 KB
Loading

‎lake/pic/14.png

7.47 KB
Loading

‎lake/pic/15.png

7.38 KB
Loading

‎lake/pic/16.png

7.53 KB
Loading

‎lake/pic/17.png

7.54 KB
Loading

‎lake/pic/18.png

7.11 KB
Loading

‎lake/pic/19.png

6.51 KB
Loading

‎lake/pic/2.png

2.83 KB
Loading

‎lake/pic/20.png

5.35 KB
Loading

‎lake/pic/21.png

6.48 KB
Loading

‎lake/pic/22.png

6.7 KB
Loading

‎lake/pic/23.png

6.14 KB
Loading

‎lake/pic/24.png

5.71 KB
Loading

‎lake/pic/3.png

2.26 KB
Loading

‎lake/pic/4.png

2.34 KB
Loading

‎lake/pic/5.png

7.17 KB
Loading

‎lake/pic/6.png

6.22 KB
Loading

‎lake/pic/7.png

4.34 KB
Loading

‎lake/pic/8.png

4.23 KB
Loading

‎lake/pic/9.png

4.34 KB
Loading

‎lake/pic/result.png

179 KB
Loading

‎lake/result.wav

-264 KB
Binary file not shown.

‎read-bin-file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ def read_bin_file(file_path):
1717
# read_bin_file("lake/2.wav")
1818
# read_bin_file("indian/indian.wav")
1919
# read_bin_file("indian/result.wav")
20-
read_bin_file("maze/maze/mybroken.gif")
20+
# read_bin_file("maze/maze/mybroken.gif")
21+
read_bin_file("lake/lake1.jpg")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp