- Homebrewのインストール
This file contains hidden or 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
| #!/usr/bin/python | |
| import math | |
| def sieve(n): | |
| nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] | |
| ans = [2,3,5] | |
| while nums[0] <= math.sqrt(n): | |
| for i in range(nums[0]**2, nums[-1]+1, nums[0]): | |
| if i in nums: nums.remove(i) | |
| ans.append(nums.pop(0)) |
This file contains hidden or 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
| def sieve(n): | |
| num = [True]*n | |
| num[0] = num[1] = False | |
| for i in xrange(2,int(n**0.5)+1): | |
| if num[i]: | |
| for j in xrange(i**2, n, i): | |
| num[j] = False | |
| return [i for i in xrange(2,n) if num[i]] | |
| print sieve(999999) |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| while True: | |
| print "借りる値段を入力してね٩(ˊᗜˋ*)و" | |
| n = input('> ') | |
| month = n * (1.1 ** 3) | |
| year = n * (1.1 ** 36) | |
| five_month = n * (1.1 ** (36 * 5)) | |
| print "1ヶ月で{}円, 1年で{}円, 5年で{}円かかるよ(,,Ծ‸Ծ,, )\n".format(int(month),int(year),int(five_month)) |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # arrayを拡張 | |
| class Array | |
| def avg | |
| inject(0.0){|m, i| m+=i.to_i}/size | |
| end | |
| def variance | |
| a = avg |
This file contains hidden or 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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import random | |
| DECIMEL, MINUS = 10, 4 # 小数点/負の数の出現頻度 1/variable name | |
| def randnum(d, m): | |
| num = random.randint(1, 9) | |
| if d: num = randdecimel(num) | |
| if m: num = randminus(num) |
This file contains hidden or 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
| ajax = new Ajax("/comments") | |
| insert_json = (data) -> | |
| lines = $.parseJSON(data).line.reverse() | |
| $("div#comments").html "" | |
| i = 0 | |
| while i < ((if lines.length < 10 then lines.length else 10)) | |
| main = $("<div>", | |
| class: "data" | |
| ) |
This file contains hidden or 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
| #!/usr/bin/python | |
| def rpn(stack, obj): | |
| if type(obj) == int: | |
| stack.append(obj) | |
| else: | |
| p = stack.pop() | |
| if obj == '+': | |
| stack.append(stack.pop() + p) | |
| elif obj == '-': |
This file contains hidden or 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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import random | |
| def _randnum(f, m): | |
| num = random.randint(1, 9) | |
| if f != 0: num = _randdecimel(num, f) | |
| if m != 0: num = _randminus(num, m) | |
| return num |