Skip to content

Instantly share code, notes, and snippets.

@FGFW
FGFW / python版恶俗古风自动生成器.py
Last active April 13, 2016 02:11
python版恶俗古风自动生成器.py
"""
python版恶俗古风自动生成器.py
模仿自: http://www.jianshu.com/p/f893291674ca
2016年4月4日 18:37:31 codegay
"""
from random import sample
import time
import os
@FGFW
FGFW / python解欧拉计划008-相邻13个数字最大乘积.py
Created April 9, 2016 00:49
python解欧拉计划008-相邻13个数字最大乘积.py
"""
python解欧拉计划008-相邻13个数字最大乘积.py
http://pe-cn.github.io/8/
2016年4月9日 07:01:13 codegay
我开了一个github项目来解欧拉计划,欢迎大家贡献自己的原创代码:
https://github.com/FGFW/projecteuler
"""
n=''.join("""73167176531330624919225119674426574742355349194934
@FGFW
FGFW / python判断路径是目录还是文件.py
Created April 7, 2016 19:10
python判断路径是目录还是文件.py
"""
python判断路径是目录还是文件.py
http://bbs.bathome.net/thread-39957-1-1.html
2016年4月8日 03:04:00 codegay
"""
import os
files=[r for r in open("test.txt") if os.path.isfile(r.strip())]
@FGFW
FGFW / python移动文本第A行到第N行.py
Created April 4, 2016 11:35
python移动文本第A行到第N行.py
"""
python移动文本第A行到第N行.py
http://bbs.bathome.net/thread-39853-2-1.html
2016年4月4日 18:50:06 codegay
这个问题本质等于把列表元素第A个移动到第N....
"""
with open("22.txt") as f:
txt=f.readlines()
txt.insert(4,txt[1])#第二行插入第五行的位置
del(txt[1])#删除原来的第二行
@FGFW
FGFW / julia下载QQ.jl
Created April 2, 2016 12:48
julia下载QQ.jl
#="""
julia下载QQ.jl
从http://im.qq.com/pcqq/页面中提取出QQ的下载地址,并下载.
2016年4月1日 19:16:15 codegay
"""=#
url=string("http://im.qq.com/pcqq/","?",time())
download(url,"qq.html")
f=open("qq.html")
txt=readall(f)
m=matchall(r"(?P<test>http://.*?.exe)",txt)
@FGFW
FGFW / julia解无忧公主的数学时间097.jl
Created March 29, 2016 16:49
julia解无忧公主的数学时间097.jl
#="""
julia解无忧公主的数学时间097.jl
http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==&mid=402225879&idx=1&sn=6ea8e1d5e6a2520ad65eb2713a98af6e&3rd=MzA3MDU4NTYzMw==&scene=6#rd
2016年3月29日 21:42:46 codegay
木有想法傻傻暴力算
"""=#
using Iterators
n=[r for r in 1:7]
f=x->length(Set(x))==5&&x[1]<x[2]>x[3]&&x[3]<x[4]>x[end];
result=[]
@FGFW
FGFW / python解无忧公主的数学时间097.py
Created March 29, 2016 16:38
python解无忧公主的数学时间097.py
"""
python解无忧公主的数学时间097.py
codegay 2016年3月30日 00:17:26
http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==&mid=402225879&idx=1&sn=6ea8e1d5e6a2520ad65eb2713a98af6e&3rd=MzA3MDU4NTYzMw==&scene=6#rd
"""
from itertools import product
n=[[h for h in range(1,7+1)] for r in range(5)]
f=lambda x:x[1]>x[0] and x[1]>x[2] and x[3]>x[2] and x[3]>x[4] and len(set(x))==5
x={r for r in product(*n) if f(r)}
print("097结果:",len(x))
@FGFW
FGFW / julia文件合并排序.jl
Created March 29, 2016 10:22
julia文件合并排序.jl
"""
julia文件合并排序.jl
http://bbs.bathome.net/thread-39841-1-1.html
2016年3月29日 17:29:48 codegay
思路如crlf所说,找出不存target中id,合并然后sort排序就可以.
"""
indexio=open("index2.txt")
targetio=open("target2.txt")
indtxt=[strip(r) for r in readlines(indexio)]
@FGFW
FGFW / julia生成指定格式的字符串.jl
Created March 28, 2016 22:09
julia生成指定格式的字符串.jl
"""
julia生成指定格式的字符串.jl
http://bbs.bathome.net/thread-39829-1-1.html
2016年3月29日 05:06:07 codegay
"""
#生成aabbcc格式的字符串
ss="abcdefghijklmnopqrstuvwxyz0123456789"
result=open("result.txt","w+")
for a in ss
for b in ss
@FGFW
FGFW / julia文本文件合并去重.jl
Created March 26, 2016 19:42
julia文本文件合并去重.jl
#="""
julia文本文件合并去重.jl
http://bbs.bathome.net/thread-39822-1-1.html
2016年3月27日 01:02:58 codegay
"""=#
f1=open("1.txt")
txt1=readlines(f1)
txt2=readlines(open("2.txt"))
txt=vcat(txt1,txt2) #以readlines取读文件流,vcat连接两个Array,julia不支持+号连接字符串和数组,支持$符内插
@show length(txt)