Skip to content

Instantly share code, notes, and snippets.

@honda0510
honda0510 / Gmail.class.vb
Last active December 14, 2015 21:28
Gmailの未読メールをフィードとして取得
Option Explicit
' 参照設定
' Microsoft WinHttp Services, version 5.1
Private Enum HTTPREQUEST_SETCREDENTIALS_FLAGS
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1
End Enum
@honda0510
honda0510 / Module1.vb
Last active December 14, 2015 18:09
『Split, Join』 ~ 車輪の再発明シリーズ ~ http://www.moug.net/faq/viewtopic.php?t=65807
Option Explicit
Sub SplitTest()
Dim Result() As String
Dim ErrNum As Long
Result = Split("")
Debug.Assert LBound(Result) = 0 And UBound(Result) = -1
Result = Split("A,B,C", ",", 0)
@honda0510
honda0510 / Module1.bas
Last active December 14, 2015 17:09
商、剰余、べき乗 | ~ 車輪の再発明シリーズ ~ http://www.moug.net/faq/viewtopic.php?t=65743
Option Explicit
Function Quotient(ByVal Dividend, ByVal Divisor) As Variant
'Quotient = Dividend \ Divisor
Quotient = Fix(Dividend / Divisor)
End Function
Function Modular(ByVal Dividend, ByVal Divisor) As Variant
'Modular = Dividend Mod Divisor
Modular = Dividend - Quotient(Dividend, Divisor) * Divisor
@honda0510
honda0510 / Module.vb
Last active December 14, 2015 17:09
2進数、10進数、16進数の相互変換 | ~ 車輪の再発明シリーズ ~ http://www.moug.net/faq/viewtopic.php?t=65742
Option Explicit
Sub test()
Hex2DecTest
Dec2BinTest
Hex2BinTest
Bin2DecTest
Bin2HexTest
Dec2HexTest
End Sub
@honda0510
honda0510 / Module.vb
Last active December 14, 2015 17:09
二値画像の回転 : 第2回 オフラインリアルタイムどう書くの参考問題 http://qiita.com/items/9d80de41903775296ca6
Option Explicit
Sub test()
Debug.Assert RotateBinImg("3:5b8") = "3:de0"
Debug.Assert RotateBinImg("1:8") = "1:8"
Debug.Assert RotateBinImg("2:8") = "2:4"
Debug.Assert RotateBinImg("2:4") = "2:1"
Debug.Assert RotateBinImg("2:1") = "2:2"
Debug.Assert RotateBinImg("3:5d0") = "3:5d0"
Debug.Assert RotateBinImg("4:1234") = "4:0865"
@honda0510
honda0510 / Module1.vb
Created February 23, 2013 07:43
Tick-Tack-Toe : 第一回 オフラインリアルタイムどう書くの当日のお題 http://nabetani.sakura.ne.jp/hena/1/
Option Explicit
Sub test()
Debug.Assert TickTackToe("79538246") = "x won."
Debug.Assert TickTackToe("35497162193") = "x won."
Debug.Assert TickTackToe("61978543") = "x won."
Debug.Assert TickTackToe("254961323121") = "x won."
Debug.Assert TickTackToe("6134278187") = "x won."
Debug.Assert TickTackToe("4319581") = "Foul : x won."
Debug.Assert TickTackToe("9625663381") = "Foul : x won."
@honda0510
honda0510 / Module1.vb
Created February 19, 2013 11:12
ポーカー : 第一回 オフラインリアルタイムどう書くの参考問題 http://qiita.com/items/cbc3af152ee3f50a822f
Option Explicit
Sub test()
Debug.Assert Poker("S2H2D2C2S3") = "4K"
Debug.Assert Poker("D3C3C10D10S3") = "FH"
Debug.Assert Poker("S2H2D2C3S4") = "3K"
Debug.Assert Poker("S8D10HJS10CJ") = "2P"
Debug.Assert Poker("S2H2D3C4S5") = "1P"
Debug.Assert Poker("S2H3D4C5S6") = "--"
End Sub
@honda0510
honda0510 / Module1.vb
Last active December 13, 2015 19:48
のんびり座りたい ~ 横へな 2013.2.2 http://nabetani.sakura.ne.jp/hena/ord7selectchair/
Option Explicit
Private Reg As Object
#Const ONE_LINER = 0
Sub test()
Debug.Assert Seats("6:NABEbBZn") = "-ZAB-E"
Debug.Assert Seats("1:A") = "A"
Debug.Assert Seats("1:Aa") = "-"
Debug.Assert Seats("2:AB") = "AB"
@honda0510
honda0510 / CountAllPaths.vb
Last active December 11, 2015 20:28
難問 : これでもEXCELの課題なんです(経路問題) http://www.moug.net/faq/viewtopic.php?t=65367
Sub test()
Debug.Print CountAllPaths(5, 5) ' 70
Debug.Print CountAllPaths(10, 10) ' 48620
Debug.Print CountAllPaths(20, 20) ' 35345263800
End Sub
Function CountAllPaths(ByVal Row As Long, ByVal Col As Long) As Double
Dim r As Long
Dim c As Long
@honda0510
honda0510 / reverse.hs
Created January 14, 2013 03:18
reverse' はコンパイルエラーにならないのに reverse'' はコンパイルエラーになるのはなぜだろう
reverse' :: [a] -> [a]
reverse' = foldl (flip (:)) []
reverse'' :: [a] -> [a]
reverse'' = foldl (:) []