forked from Mao-Lab/100_knock
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maruyama #33
Open
ghost
wants to merge
27
commits into
master
Choose a base branch
from
maruyama
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Maruyama #33
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
95f4a3e
100本ノック第一章00.
602dc39
修正しました。
40a6848
Merge pull request #11 from tmaru0204/maruyama
kanjirz50 c113fe4
100本ノック第1章01.です
e3cfd8d
100本ノック第1章02.です。
a88b24c
修正しました。
c96ba5d
連結した文字列から表示するように変更しました。
0815263
修正しました。
8d2b717
Merge pull request #12 from tmaru0204/maruyama
kanjirz50 55b924d
100本ノック第1章03です。
c6669d2
修正しました。
00e83ca
100本ノック第1章04です
9828ec4
100本ノック第1章05です
b737e11
修正しました。
7edae22
修正しました
f488a22
100本ノック第1章06です。
9503726
100本ノック第1章07です
06dd12c
修正しました。
9135131
修正しました
db110af
100本ノック第1章08
9a788cb
Merge pull request #18 from tmaru0204/maruyama
085e5f2
100本ノック第1章09
c11d79d
100本ノック第2章10
e40c250
100本ノック第2章11
5321158
100本ノック第2章12
342cae3
修正しました。
c504e65
Merge pull request #30 from tmaru0204/maruyama
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
s="stressed" | ||
print(s[::-1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding:utf-8 -*- | ||
s = "パタトクカシーー" | ||
print(s[::2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
from itertools import chain | ||
word1 = "パトカー" | ||
word2 = "タクシー" | ||
|
||
merged_word = ''.join(chain(*zip(word1, word2))) | ||
print(merged_word) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
s = """Now I need a drink, alcoholic of course, after the heavy lectures | ||
involving quantum mechanics.""" | ||
s = s.replace(",", "").replace(".", "") | ||
s = s.split(' ') | ||
print(s) | ||
|
||
num = [len(s[a]) for a in range(15)] | ||
print(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
s = """Hi He Lied because Boron Could Not Oxidize Fluorine. New Nations Might | ||
Also Sign Peace Security Clause. Arthur King Can""" | ||
|
||
s = s.replace(",", "").replace(".", "") | ||
s = s.split(' ') | ||
el = {} | ||
|
||
indexs = [0, 4, 5, 6, 7, 8, 14 ,15 ,18] | ||
|
||
for index, word in enumerate(s): | ||
if index in indexs: | ||
el[index+1] = word[0] | ||
else: | ||
el[index+1] = word[0]+word[1] | ||
|
||
print(el) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
def ngram_str(words, n): | ||
yield from zip(*(words[n:] for n in range(n))) | ||
|
||
|
||
def ngram_word(words, n): | ||
words = words.split(" ") | ||
yield from zip(*(words[n:] for n in range(n))) | ||
|
||
|
||
for num in ngram_str("I am a NLPer", 2): | ||
print(num) | ||
|
||
print("\n") | ||
|
||
for num in ngram_word("I am a NLPer", 2): | ||
print(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
def n_gram_str(s, n): | ||
length = len(s) | ||
return [s[i:i+n] for i in range(0, length, n)] | ||
|
||
|
||
s1 = "paraparaparadise" | ||
s2 = "paragraph" | ||
|
||
X = set(n_gram_str(s1, 2)) | ||
Y = set(n_gram_str(s2, 2)) | ||
|
||
print("X = "+str(X)) | ||
print("Y = "+str(Y)) | ||
|
||
print("intersection = "+str(X & Y)) | ||
print("union = "+str(X | Y)) | ||
print("difference = "+str(X - Y)) | ||
|
||
print("se" in list(X | Y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
def weather(x, y, z): | ||
return("{}時の{}は{}".format(x, y, z)) | ||
|
||
|
||
print(weather("12", "気温", "22.4℃")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
def cipher(s): | ||
return "".join([chr(219-ord(c)) if c.islower() else c for c in s]) | ||
|
||
sentence = "abCdeFg" | ||
print(cipher(sentence)) | ||
print(cipher(cipher(sentence))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# coding: utf-8 | ||
import random | ||
|
||
def rand1(word): | ||
if len(word) <= 4: | ||
return word | ||
m = list(word[1:-1]) | ||
random.shuffle(m) | ||
return word[0] + "".join(m) + word[-1] | ||
|
||
|
||
|
||
sentence = """\ | ||
I couldn't believe that I could actually understand \ | ||
what I was reading : the phenomenal power of the human mind .\ | ||
""" | ||
|
||
print(" ".join(map(rand1, sentence.split()))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
高知県 江川崎 41 2013-08-12 | ||
埼玉県 熊谷 40.9 2007-08-16 | ||
岐阜県 多治見 40.9 2007-08-16 | ||
山形県 山形 40.8 1933-07-25 | ||
山梨県 甲府 40.7 2013-08-10 | ||
和歌山県 かつらぎ 40.6 1994-08-08 | ||
静岡県 天竜 40.6 1994-08-04 | ||
山梨県 勝沼 40.5 2013-08-10 | ||
埼玉県 越谷 40.4 2007-08-16 | ||
群馬県 館林 40.3 2007-08-16 | ||
群馬県 上里見 40.3 1998-07-04 | ||
愛知県 愛西 40.3 1994-08-05 | ||
千葉県 牛久 40.2 2004-07-20 | ||
静岡県 佐久間 40.2 2001-07-24 | ||
愛媛県 宇和島 40.2 1927-07-22 | ||
山形県 酒田 40.1 1978-08-03 | ||
岐阜県 美濃 40 2007-08-16 | ||
群馬県 前橋 40 2001-07-24 | ||
千葉県 茂原 39.9 2013-08-11 | ||
埼玉県 鳩山 39.9 1997-07-05 | ||
大阪府 豊中 39.9 1994-08-08 | ||
山梨県 大月 39.9 1990-07-19 | ||
山形県 鶴岡 39.9 1978-08-03 | ||
愛知県 名古屋 39.9 1942-08-02 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
line_number = 0 | ||
with open('input.txt') as input_file: | ||
for line in input_file: | ||
line_number += 1 | ||
|
||
print("行数:"+str(line_number)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
with open('input.txt') as input_file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ネストが多くなるのは、できるだけ避ける with open('file1') as fp1, open('file2') as fp2:
#hogehoge |
||
with open('un11_output.txt','w') as output_file: | ||
for line in input_file: | ||
line = line.replace("\t", " ") | ||
output_file.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
with open('input.txt') as input_file: | ||
with open('col1.txt', 'w') as output1_file: | ||
with open('col2.txt', 'w') as output2_file: | ||
for line in iter(input_file.readlines()): | ||
output1_file.writelines(line.split('\t')[0]+'\n') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3個以上になると \を使って改行しないといけないので ならcontextlib.ExitStackが個人的にはオススメ |
||
output2_file.writelines(line.split('\t')[1]+'\n') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line_numberを使うよりもenumerateを使う