思いついたので。特に意味はありません。
532856382672
— 12桁の番号 (@12digitnumber) October 14, 2015
ソースコードはこちら
Azure Web job で動かしています。
This file contains 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
Imports CoreTweet | |
Module Module1 | |
Sub Main() | |
Dim consumerKey = "***" | |
Dim consumerSecret = "***" | |
Dim accessToken = "***" | |
Dim accessSecret = "***" | |
Dim tokens = CoreTweet.Tokens.Create(consumerKey, consumerSecret, accessToken, accessSecret) | |
Dim number = GenerateNumber() | |
tokens.Statuses.Update(New Dictionary(Of String, Object) From { | |
{"status", number}}) | |
End Sub | |
Function GenerateNumber() As String | |
Const digits = "0123456789" | |
Dim r = New Random | |
Do | |
Dim number = "" | |
For i = 1 To 12 | |
number &= digits(r.Next(0, 10)) | |
Next | |
If number.Substring(11) <> GetCheckDigit(number.Substring(0, 11)).ToString Then | |
Return number | |
End If | |
Loop | |
End Function | |
Function GetCheckDigit(myNumber As String) As Integer | |
If myNumber.Length <> 11 Then | |
Throw New ArgumentException | |
End If | |
Dim sum = 0 | |
For n = 1 To 11 | |
Dim p = Convert.ToInt32(myNumber.Substring(11 – n, 1)) | |
Dim q = If(n <= 6, n + 1, n – 5) | |
sum += p * q | |
Next | |
Dim r = sum Mod 11 | |
Return If(r <= 1, 0, 11 – r) | |
End Function | |
End Module |
Tシャツも作りました
12桁の番号 ( 12digitnumber ) の【12 digit number】Tシャツ ∞ SUZURI(スズリ) https://t.co/iAJfs4vXkE #suzurijp
— 12桁の番号 (@12digitnumber) October 14, 2015