Skip to content

Instantly share code, notes, and snippets.

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
list0 = []
list1 = [1,2,3]
if list0:
print 'list0' #長さ0なのでFalse扱いで実行されない
if list1:
print 'list1'
# -*- 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):
# CSVからの読みこみ
g = np.genfromtxt("gen.csv",delimiter=",")
print g
# CSV出力
np.savetxt("saved.csv", c, delimiter=",", fmt="%.2f")
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)
# 二進数にする
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 = []
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
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
using UnityEngine;
using System;
using System.Linq;
using System.Collections.Generic;
namespace DL
{
/// <summary>
/// MonoBehaviourの拡張クラス
/// </summary>
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System.Collections;
using DL;
// Textで作っちゃってDLTextに移行するのが面倒なときに使う
public class TextToDLText {