Skip to content

Commit b998901

Browse files
committed
Merge pull request Show-Me-the-Code#145 from Kxrr/master
My solutions
2 parents a6e5f00 + 33fe750 commit b998901

File tree

9 files changed

+587
-0
lines changed

9 files changed

+587
-0
lines changed

Kxrr/0000/0000.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
3+
__author__ = 'Kxrr'
4+
5+
from PIL import Image,ImageDraw,ImageFont
6+
import random
7+
8+
msgNum = str(random.randint(1,99))
9+
10+
# Read image
11+
im = Image.open('kxrr.png')
12+
w,h = im.size
13+
wDraw = 0.8 * w
14+
hDraw = 0.08 * w
15+
16+
# Draw image
17+
font = ImageFont.truetype('/usr/share/fonts/truetype/droid/DroidSans.ttf', 30) # use absolute font path to fix 'IOError: cannot open resource'
18+
draw = ImageDraw.Draw(im)
19+
draw.text((wDraw,hDraw), msgNum, font=font, fill=(255,33,33))
20+
21+
# Save image
22+
im.save('kxrr_msg.png', 'png')

Kxrr/0000/kxrr.png

51.5 KB
Loading

Kxrr/0000/kxrr_msg.png

52.2 KB
Loading

Kxrr/0001/0001.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
__author__ = 'Kxrr'
4+
5+
import random, string
6+
7+
ALL_LETTERS = string.ascii_uppercase + string.digits
8+
codeAmount = 200
9+
codeRound = 10
10+
codeResult = []
11+
12+
while len(codeResult) != codeAmount:
13+
everyCode =''.join((random.choice(ALL_LETTERS) for i in range(codeRound)))
14+
if everyCode not in codeResult:
15+
codeResult.append(everyCode)
16+
17+
print len(codeResult)
18+
print codeResult
19+

Kxrr/0003/0003.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
3+
__author__ = 'Kxrr'
4+
5+
import redis
6+
7+
REDIS_HOST = '127.0.0.1'
8+
REDIS_PORT = 6379
9+
10+
cache = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=0)
11+
12+
# Store
13+
with open('codeResult.txt', 'r') as f:
14+
keyList = []
15+
for lineNum, eachCode in enumerate(f.readlines()):
16+
keyList.append(lineNum)
17+
cache.set(str(lineNum), eachCode)
18+
19+
# Read
20+
for i in keyList:
21+
print cache.get(str(i))
22+
23+

Kxrr/0003/codeResult.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
OU29SQIAW2
2+
W2YU6Y69OD
3+
PIUD0AD07X
4+
A8MVZOVX46
5+
5ZZJVPKLPJ
6+
PGBLUUY35S
7+
9X69SD6GBL
8+
EO6X9ALS9X
9+
NAH6TA659D
10+
Z9XLBJWW57
11+
EIAWKME1HX
12+
HAMWQJSTX3
13+
UFH4IB71SJ
14+
P6MRJWATJJ
15+
2JDDWLI6RA
16+
2E8GOX7IKW
17+
2WP9BDAZJV
18+
ZRHHH4WV3O
19+
NRC6TA2QS2
20+
YJI75X0UAA
21+
GNUAHR1KV2
22+
75E790JYPR
23+
UAFRKJASBI
24+
YQVW9Y1MVH
25+
4EL7B731JR
26+
BNVGGARHI0
27+
EA0K2Q9DQ1
28+
PC5KTRZHIC
29+
RYGHI5EM4P
30+
U8RN9IP0DA
31+
NWTP93BLP9
32+
IANU2MZAV4
33+
7VSCVKAG1S
34+
2KYMZ4TL3F
35+
7614J1QCHU
36+
L29L5WZ5TY
37+
KHB20I2OBU
38+
Y2NKBG9N06
39+
758QKKTWFH
40+
SYGEUJT4IK
41+
5YS95CYACU
42+
DQSJ6L9W7B
43+
5QAHM82X6X
44+
SAP8IBDVEF
45+
CODQ7LMYG0
46+
WQVHFZ89WT
47+
61A4QC5XAH
48+
2RW8HT3LHW
49+
0DE6HKQDF2
50+
JI4E5CYN3L
51+
Y41ULGK67H
52+
276AKNX81I
53+
XOVU8S5BI6
54+
BBNI4RXS01
55+
WMQ8H6YL69
56+
S3MFA27NDU
57+
R6BY1ZOWQ8
58+
94OA4YBFEV
59+
50JB1H74KZ
60+
HS908KHA0G
61+
W0BYT5S7EN
62+
22BYQ4ABEO
63+
V4RV6KMUP7
64+
EH5T1YQZL6
65+
XVAHH2FSZ4
66+
CV88ZT86PB
67+
O9RT961QOG
68+
YQVCGBKPZO
69+
3RJEG8HIHJ
70+
ST8FSBPCW5
71+
UXVG32CTZG
72+
XNMQRXMB4D
73+
NQQH7VG4C6
74+
LZ3VRXBR4O
75+
ZY9CQB3D34
76+
GRCTV0LSEY
77+
K372NS7L38
78+
9J6WRQRLE0
79+
HGDWUGPY20
80+
9H2FLDOGK7
81+
OJ0MK0ZGCK
82+
XI0GWBNTIB
83+
HE8THGP5W3
84+
3UU85SOPYN
85+
ZDWG0HUU5R
86+
Z0TIX1S0TR
87+
749V4Y2A7W
88+
WKQSX4LQLX
89+
YUXPTZJ0Z0
90+
TKYWZTVTTX
91+
0IP53OCENN
92+
GWZKN21LHT
93+
62K3XRGTUM
94+
647Q6Q9JDQ
95+
2JNA0EG5HP
96+
OV497711S5
97+
SAB9WTZXVR
98+
2O82J9JP11
99+
0VPAZT93TS
100+
EYVNVFOF51
101+
NV9OK1RGR7
102+
CZTSTR1595
103+
JYYU6N9VUE
104+
X3K1VO53DQ
105+
VH2A7CJR55
106+
UYN58BISXY
107+
UKQIAL3PTN
108+
3GG0UX0XYW
109+
S6BVDBIBAK
110+
MI6EQTTU3U
111+
MPQTMI8LQ4
112+
PIL7SMZCV4
113+
EISUEPYZMB
114+
TNOW06L42F
115+
CRRGUFUNT0
116+
QY5AFODE7N
117+
TXARYT5T9S
118+
2F1QHQI62Q
119+
MN27OH85IO
120+
CLE4PX9TRA
121+
EBPHSXJZ6U
122+
6UAQHOIN8X
123+
KW4ENLYMH3
124+
41OUVI11TL
125+
B7X0RNY3YK
126+
U5QY0OHXMF
127+
S13VGA3DYO
128+
TWMDSW11HG
129+
LSGXDBJZ8Q
130+
QCILHG6HS6
131+
ZZM7N8VFY1
132+
QWCDTBDVC3
133+
85BVJF3UKL
134+
SJJUMP3YOC
135+
WPWZ3G1MEY
136+
3P5SBZ3WXJ
137+
270YHBTINI
138+
ZD2HQSUHSV
139+
FTDOK22DEQ
140+
06JA0RCAIP
141+
ZHILS2UB2N
142+
0H30QRZ6RF
143+
4RI7CWSFUC
144+
B1XVETOB9I
145+
NPI14U9U5F
146+
KFCVIROJTB
147+
0Y8UTS2BQP
148+
ENJC3S0IDF
149+
RNVJK8SU0J
150+
6ONNUQLMD1
151+
ZRUKNKOR7W
152+
JBPRC75ZUH
153+
5Q7PKD3NGM
154+
LSTYXQHWGS
155+
07HSFSKZRB
156+
PX9A56VNAM
157+
AGBPWS82E4
158+
NLJEBMS1K0
159+
569NPPBMBW
160+
Y5B8LYLUFI
161+
8I3IR8CEDX
162+
DGW1YBHNE7
163+
JI6VN3UQ5S
164+
YCVVE3TRDN
165+
WBR1UGYT9L
166+
8TL351B8VH
167+
EYLC00Q88I
168+
MZ544ITY9V
169+
0M5V3AV7VW
170+
DM1RXV2RZM
171+
CL4UTYH2KK
172+
RYP0J5S2MB
173+
G01LYVCFSO
174+
99XLJ2J96O
175+
2EQR4E7YJU
176+
MZGYSJ5HAO
177+
GYFOPU72Y1
178+
73NIVD6MET
179+
2W6VS5TSKB
180+
YOXA7LWQIO
181+
TUSEYN4HGX
182+
RH5DJKWGMY
183+
BE16XQOOHV
184+
4RNREWW7SH
185+
AW8FIO68MN
186+
0K2ZJS3YVO
187+
OYSDYZSSGG
188+
M2P4EB3Y7Q
189+
7ZHXYHFXHS
190+
Z870E73IDS
191+
FMLSSK2N5G
192+
K58P7PVVF4
193+
NPKXENQDN1
194+
3YZ9OWLM3J
195+
WRTGTVYECM
196+
B8N0AJRYQV
197+
VBMFFBF9OO
198+
K489UH2WSP
199+
11WY1FARCF
200+
0W0HHYHKGS

Kxrr/0004/0004.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
__author__ = 'Kxrr'
4+
5+
import re
6+
7+
with open('0004.txt', 'r') as f:
8+
dictResult = {}
9+
10+
# Find the letters each line
11+
for line in f.readlines():
12+
listMatch = re.findall('[a-zA-Z]+', line.lower()) # remember to lower the letters
13+
14+
# Count
15+
for eachLetter in listMatch:
16+
eachLetterCount = len(re.findall(eachLetter, line.lower()))
17+
dictResult[eachLetter] = dictResult.get(eachLetter, 0) + eachLetterCount
18+
19+
# Sort the result
20+
result = sorted(dictResult.items(), key=lambda d: d[1], reverse=True)
21+
for each in result:
22+
print each

Kxrr/0004/0004.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
The entrepreneur teaching Japan how to take more risks
2+
By Hoang Nguyen BBC reporter, Tokyo
3+
4+
14 September 2015
5+
From the section Business
6+
7+
Jump media player
8+
Media player help
9+
Out of media player. Press enter to return or tab to continue.
10+
Media caption Serial start-up businessman William Saito is on a mission to make Japan more entrepreneurial
11+
The Boss
12+
13+
The 21-year-old building India's largest hotel network
14+
A hair-raising way to start make money
15+
Revolutionising motorcycle taxis
16+
Vietnam's start-up queen
17+
18+
When William Saito quit as a medical doctor immediately after qualifying, his parents refused to speak to him for two years.
19+
20+
But they're not complaining about the end result now, says the 44-year-old Japanese American.
21+
22+
He did the training to fulfil his parents' dream of him becoming a doctor, and as he jokes, his parents never actually said how long they wanted him to be a doctor for - just to be one.
23+
24+
The reason he left so soon was because he was determined to carry on the venture he'd begun at just 11-years-old while still in junior high school.
25+
26+
He had founded his own start-up company, which eventually focused on enhanced security for personal computers through technologies such as fingerprint and iris recognition.
27+
28+
Mr Saito formally incorporated the firm - I/O Software - in 1991 while he was at university. The company became a leader in biometrics and information security, and just 14 years later at the age of 33 he sold it to US giant Microsoft.
29+
30+
While the terms of the deal mean he can't reveal the price he received, Mr Saito admits he would have been in a position to retire then if he'd wanted to.
31+
32+
But unsurprisingly for someone so driven at such a young age, he has continued to work relentlessly, using his experience to help other entrepreneurs, particularly in his parents' home country of Japan.
33+
Image copyright William Saito
34+
Image caption William Saito has always had his finger in several pies
35+
36+
While born and raised in the US, Mr Saito still believes he "owes the Japanese", because it's his heritage which he credits for his success. And now he believes he can give something back.
37+
'Changed my life'
38+
39+
Mr Saito's parents couldn't speak English when they emigrated to the US, settling in Los Angeles in California, just two years before he was born in 1971.
40+
41+
Determined to give their son - the eldest of three - a competitive advantage to ensure he would thrive in their new country, they focused on mathematics, bringing over complex textbooks from Japan, and teaching him things well beyond the expected level for his age.
42+
43+
"That turned into a huge advantage for me," he says.
44+
45+
In fact, his maths became so advanced that his teacher ran out of suitable lessons, suggesting he played with "a thing called a personal computer" instead.
46+
47+
"I was able to take advantage of this lead and it changed my life," Mr Saito says.
48+
Image copyright William Saito
49+
Image caption William Saito is particularly keen to support female Japanese entrepreneurs
50+
51+
On this teacher's advice, his parents took out a home loan to buy him his very own personal computer - worth about $5,000 (£3,200) in today's money - which from their point of view was aimed at helping him become a doctor.
52+
53+
But some work, organised by the same teacher, changed the direction of his life permanently. The teacher suggested to a friend - an accountant at investment bank Merrill Lynch - that Mr Saito, who at the time was just 10-years-old, could help with writing computer programmes.
54+
55+
"When I finished I received a cheque, and I didn't expect that.
56+
57+
"That really changed my view about doing something fun, but at the same time getting paid for it. It was definitely a wake-up moment for me," he says.
58+
59+
Despite his precocious start, Mr Saito denies that he was hot-housed, saying his parents exposed him to lots of different activities, and made it clear that success was about more than just good grades.
60+
61+
In particular, he says both the schools he went to, and his parents, emphasised the importance of volunteering.
62+
63+
It's a lesson he has taken to heart, and since the successful sale of his first firm, he has worked hard to support other would-be entrepreneurs.
64+
65+
He confesses one of his favourite pursuits, is judging business plans, and he travels globally to do this. To date, he calculates he's judged some 15,000 people in such competitions.
66+
67+
But his main focus is his parents' home country of Japan.
68+
'Giving back'
69+
70+
In 2005, after selling I/O Software, he moved to Japan and founded venture capital firm and consultancy InTecur.
71+
72+
He also works as a special adviser for the Japanese government, specialising in cybersecurity.
73+
74+
But his main drive is to make the Japanese more entrepreneurial.
75+
Image copyright William Saito
76+
Image caption William Saito's family always had high hopes for him
77+
Image copyright William Saito
78+
Image caption As a child he was interested in many different things
79+
80+
As well as advising firms on various technology issues, InTecur aims to help young Japanese technology entrepreneurs become successful, something which he feels the Japanese culture, which typically bases seniority on age and experience, makes difficult.
81+
82+
"People in their 20s aren't given the opportunity. So for me I felt an obligation to give back to that next generation because I was given the opportunity," he says.
83+
Image copyright William Saito
84+
Image caption His parents hoped he would become a medical doctor
85+
Image copyright William Saito
86+
Image caption Mr Saito cannot reveal the price that Microsoft paid him for I/O Software
87+
88+
So far, the firm has invested in 24 companies, 14 of which are run by women - who he believes are also often overlooked in Japanese society.
89+
90+
He says he also makes a point of investing in people who have previously failed.
91+
92+
"Failure here [in Japan] is a bad word. I'm the reverse. You have to fail once and gain that experience first, then you know what your weaknesses and strengths are."
93+
94+
It is these attitudes, which he believes are stifling Japan's entrepreneurial spirit and making it harder for the country to grow.
95+
96+
But he's optimistic that things are changing. And it's this which makes him happiest.
97+
98+
"To unleash that potential and to see people make real change, I think I'm most proud about that.
99+
100+
"This is still an unfinished story but it's starting to take root," he says.

0 commit comments

Comments
 (0)