Skip to content

Instantly share code, notes, and snippets.

View butchi's full-sized avatar

IWABUCHI Yu(u)ki (butchi) butchi

View GitHub Profile
@butchi
butchi / parseInt0x.js
Created October 20, 2012 16:50
parseInt('0x')
parseInt('5x'); //=> 5
parseInt('0y'); //=> 0
parseInt('0x'); //=> NaN
parseInt('', 16) //=> NaN
@butchi
butchi / index.html
Created February 2, 2014 09:56
山手線停車駅の座標一覧 ref: http://qiita.com/butchi_y/items/3a6b70b38e13dc56ef13
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>山手座標</title>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="main.js"></script>
</head>
<body>
<table class="table-station">
@each $type in "facebook" "twitter" {
.#{$type} {
@if $type == "facebook" {
$button: "button_like.png";
} @else if $type == "twitter" {
$button: "button_tweet.png";
}
width: image-width($button);
height: image-height($button);
background-image: image-url($button);
@butchi
butchi / index.html
Created June 22, 2014 14:26
クリックするたびにツイート文が変わるTwitterボタン ref: http://qiita.com/butchi_y/items/97ab31f6e5f37c08315c
<html>
<head>
<title>スーパーツイート</title>
</head>
<body>
<div class="twitter">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="butchi_y" data-hashtags="すごいパンチ" data-url="http://jsdo.it/butchi/super_tweet">Tweet</a>
</div>
@butchi
butchi / gist:89aee403e98a3b7e9cda
Created September 11, 2014 16:17
yukicoder no.25
(* http://ch.nicovideo.jp/programing/blomaga/ar620922 *)
lastDigit[n_, m_] := With[
{rd = RealDigits[n/m, 10]},
Piecewise[{
{-1, Depth[First[rd]] > 2 || Head[Last[rd]] === List},
{Last[Cases[First[rd], Except[_?(#1 === 0 & )]]], True}}
]
]
lastDigit[95367431640626, 95367431640625]
@butchi
butchi / gist:1ef05aa7125b0fe4d3e7
Created October 7, 2014 15:58
yukicoder no.36
(* http://yukicoder.me/problems/27 *)
h[n_] := With[{a = FactorInteger[n]}, ! MatchQ[a, {{_, 1}}] && ! MatchQ[a, {{_, 1}, {_, 1}}] && ! MatchQ[a, {{_, 2}}]]
@butchi
butchi / YukiCoder36.nb
Created October 14, 2014 15:18
yukicoder No.39 桁の数字を入れ替え
(* http://yukicoder.me/problems/no/39 *)
maxPos[li_] := Last[Position[li, Max[li]]][[1]]
replace[li_] := ReplacePart[li, {maxPos[li] -> First[li], 1 -> Max[li]}]
f[n_] := FromDigits[replace[IntegerDigits[n]]]
@butchi
butchi / YukiCoder60.nb
Created October 14, 2014 16:01
yukicoder No.40 多項式の割り算
(* http://yukicoder.me/problems/no/40 *)
cl[li_] :=
CoefficientList[PolynomialRemainder[FromDigits[Reverse[li], x], x^3 - x, x], x]
ans[{}] := {0}
ans[li_] := li
In[1]:= ans[f[{1, 1, 1, 0, 0, 1}]]
Out[1]= {1, 2, 1}
@butchi
butchi / YukiCoder36_2.nb
Created October 14, 2014 16:06
yukicoder No.39 桁の数字を入れ替え
(* http://yukicoder.me/problems/no/39 *)
replace[li_, {posA_, posB_}] := ReplacePart[li, {posA -> li[[posB]], posB -> li[[posA]]}]
replacePos[li_] := Select[Tuples[Range[Length[li]], 2], OrderedQ]
map[li_] := replace[li, #] & /@ replacePos[li]
f[n_] := Max[FromDigits[#] & /@ map[IntegerDigits[n]]]
@butchi
butchi / YukiCoder43.nb
Last active August 29, 2015 14:07
yukicoder No. 46 はじめのn歩
(* http://yukicoder.me/problems/no/46 *)
ans[a_, b_] := Floor[(b + a - 1)/a]