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
| import gym | |
| from gym import wrappers | |
| env = gym.make('CartPole-v0') | |
| env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1') | |
| for i_episode in range(20): | |
| observation = env.reset() | |
| for t in range(100): | |
| env.render() | |
| print(observation) | |
| action = env.action_space.sample() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| from os.path import basename | |
| import urllib.request | |
| import requests | |
| from bs4 import BeautifulSoup | |
| from time import sleep | |
| pages = ['http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=1_20/', | |
| 'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=21_40/', | |
| 'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=41_60/', | |
| 'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=61_80/', |
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
| import numpy as np | |
| import tensorflow as tf | |
| import tflearn | |
| import tflearn.datasets.mnist as mnist | |
| # MNISTデータのダウンロード | |
| trainX, trainY, testX, testY = mnist.load_data(one_hot=True) | |
| # おまじない | |
| tf.reset_default_graph() |
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/ruby | |
| require 'twitter' | |
| client = Twitter::REST::Client.new do |config| | |
| config.consumer_key = "YOUR_CONSUMER_KEY" | |
| config.consumer_secret = "YOUR_CONSUMER_SECRET" | |
| config.access_token = "YOUR_ACCESS_TOKEN" | |
| config.access_token_secret = "YOUR_ACCESS_SECRET" | |
| end | |
| client.update(ARGV[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
| # -*- coding: utf-8 -*- | |
| import math,string,itertools,fractions,heapq,collections,re,array,bisect | |
| class ChessMetric: | |
| def howMany(self, size, start, end, numMoves): | |
| dx = [1, 1, 1, 0, -1, -1, -1, 0, 2, 1, -1, -2, -2, -1, 1, 2] | |
| dy = [1, 0, -1, -1, -1, 0, 1, 1, -1, -2, -2, -1, 1, 2, 2, 1] | |
| dp = [[[0 for i in range(55)] for j in range(100)] for k in range(100)] | |
| dp[start[0]][start[1]][0] = 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
| # -*- coding: utf-8 -*- | |
| import math,string,itertools,fractions,heapq,collections,re,array,bisect | |
| class ShortestPathWithMagic: | |
| def getTime(self, adj, k): | |
| n = len(adj) | |
| d = [[0 for i in range(n)] for j in range(n)] | |
| # convert string to number |
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 math,string,itertools,fractions,heapq,collections,re,array,bisect | |
| class LengthUnitCalculator: | |
| def calc(self, amount, fromUnit, toUnit): | |
| if fromUnit == toUnit: | |
| return amount | |
| if fromUnit == "in": | |
| if toUnit == "ft": |
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 math,string,itertools,fractions,heapq,collections,re,array,bisect | |
| class FriendScore: | |
| def highestScore(self, friends): | |
| n = len(friends) | |
| ans = 0 | |
| for i in range(n): | |
| cnt = 0 |