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 bubble_sort(arr): | |
| n = len(arr) | |
| total_swap = 0 | |
| for i in xrange(n): | |
| numberOfSwaps = 0 | |
| for j in xrange(n - 1): | |
| if arr[j] > arr[j + 1]: | |
| arr[j], arr[j + 1] = arr[j + 1], arr[j] | |
| numberOfSwaps += 1 | |
| total_swap += 1 |
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
| list0 = [] | |
| list1 = [1,2,3] | |
| if list0: | |
| print 'list0' #長さ0なのでFalse扱いで実行されない | |
| if list1: | |
| print 'list1' |
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 -*- | |
| import os, sys, unittest | |
| import math | |
| class Sample(): | |
| def sigmoid(self, v): | |
| return 1.0 / (1 + math.e**(-v)) | |
| class SampleTest(unittest.TestCase): | |
| def setUp(self): |
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
| # CSVからの読みこみ | |
| g = np.genfromtxt("gen.csv",delimiter=",") | |
| print g | |
| # CSV出力 | |
| np.savetxt("saved.csv", c, delimiter=",", fmt="%.2f") |
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
| c = [1,2,3] | |
| import pickle | |
| f = open("sample.pickle", "w") | |
| pickle.dump(c, f) | |
| f.close() | |
| print "load from pickle" | |
| f = open("sample.pickle", "r") | |
| d = pickle.load(f) |
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
| # 二進数にする | |
| n = 15 | |
| binary_s = format(n, 'b') | |
| binary_s = "11000001111010" | |
| print binary_s | |
| print len(binary_s) | |
| from itertools import groupby | |
| def count_continuous(s): | |
| len_list = [] |
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
| class Person: | |
| def __init__(self,initialAge): | |
| # Add some more code to run some checks on initialAge | |
| if initialAge < 0: | |
| print "Age is not valid, setting age to 0." | |
| self.age = 0 | |
| else: | |
| self.age = initialAge | |
| def amIOld(self): | |
| # Do some computations in here and print out the correct statement to the console |
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 fizzbuzz(n): | |
| for i in range(1, n+1): | |
| if i % 15 == 0: | |
| print "FizzBuzz" | |
| elif i % 3 == 0: | |
| print "Fizz" | |
| elif i % 5 == 0: | |
| print "Buzz" | |
| else: | |
| print i |
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
| using UnityEngine; | |
| using System; | |
| using System.Linq; | |
| using System.Collections.Generic; | |
| namespace DL | |
| { | |
| /// <summary> | |
| /// MonoBehaviourの拡張クラス | |
| /// </summary> |
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
| using UnityEngine; | |
| using UnityEditor; | |
| using UnityEngine.UI; | |
| using System.Collections; | |
| using DL; | |
| // Textで作っちゃってDLTextに移行するのが面倒なときに使う | |
| public class TextToDLText { |