Skip to content

Instantly share code, notes, and snippets.

@lamsh
Last active August 29, 2015 14:25
Show Gist options
  • Save lamsh/39a69780119161fe71e0 to your computer and use it in GitHub Desktop.
Save lamsh/39a69780119161fe71e0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# coding: utf-8
# (File name: paring.py)
# Author: SENOO, Ken
# License: CC0
# (Last update: 2015-07-26T20:32+09:00)
import itertools
FR = "./項目リスト.txt"
with open(FR, "U", encoding="utf-8") as fr:
item = fr.read().split()
"""
洪水警戒体制 洪水調節 計画高降水量70%(50%) 非常用洪水吐放流 (解除)非常用洪水吐放流 (解除)計画高降水量70%(50%) (解除)洪水調節 (解除)洪水警戒体制
"""
FW = "./out.csv"
with open(FW, "w", encoding="utf-8-sig", newline="\n") as fw:
for left, right in itertools.combinations_with_replacement(item, 2):
fw.write(left+"→"+right+"\n")
for left, right in itertools.combinations(item[::-1], 2):
fw.write(left+"→"+right+"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment