Skip to content

Instantly share code, notes, and snippets.

@kcha4github
kcha4github / AComprehensiveGuidetoTitanicMachineLearning.ipynb
Created October 10, 2018 13:53
Test of Gist Presentation of Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kcha4github
kcha4github / UnityChan.cs
Created August 15, 2018 01:57
Study for Unity that Charactor moving forward and back.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UnityChan : MonoBehaviour {
public float speed = 1f;
Animator animator;
import numpy as np
chars = np.array(['a', 'b', 'c', 'd', 'e', 'f'])
mask1 = np.random.choice(6, 4)
mask2 = np.random.choice(6, 4, replace=False)
print(mask1) # ex:[4 5 0 5]
print(chars[mask1]) # ex:['e' 'f' 'a' 'f']
print(mask2) # ex:[0 5 4 2]
print(chars[mask2]) # ex:['a' 'f' 'e' 'c']
import numpy as np
import matplotlib.pyplot as plt
def step_function(x):
return np.array(x > 0, dtype=np.int)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def relu(x):
@kcha4github
kcha4github / OutputDividedString.py
Created July 24, 2018 13:37
Way to output list data divided some string.
# -*- coding: utf-8 -*-
values = [1, 2, 3, 4, 5]
strs = map(str, values)
print(" ".join(strs))
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
int[] values = new int[5] { 1, 2, 3, 4, 5 };
Console.WriteLine(string.Join(" ", values));
@kcha4github
kcha4github / knapsack_algorithm.py
Created July 14, 2018 02:25
書籍「アルゴリズムとデータ構造」の動的計画法ナップザック問題をpythonで書き換え。分かりにくいインデックス変数を我流に変更
# -*- coding: utf-8 -*-
ITEMS = 5
SIZE = [2, 3, 5, 6, 9]
VALUE = [2, 4, 7, 10, 14]
NAP_SIZE = 16
nap_value = [0] * (NAP_SIZE + 1)
print("ナップザックの大きさ:", end="")
for i in range(1, NAP_SIZE+1):
# -*- coding: utf-8 -*-
class OldRobot():
def __init__(self):
self.speed = 5
def walk(self):
print("old robot walking {} km/h.".format(self.speed))
class NewRobot():
# -*- coding: utf-8 -*-
names = ["alice", "becky", "charlie", "Dave"]
ages = [25, 38, 12]
for name, age in zip(names, ages):
print(name, age)
# alice 25
# becky 38
# -*- coding: utf-8 -*-
while True:
bins = input().split()
if len(bins) == 0:
break
for b in bins:
print(chr(int(b,2)), end='')