2013-10-01ãã1ã¶æéã®è¨äºä¸è¦§
é¢é£ : Pythonã§CodeEvalã®Multiplication Tables - brainstorm
é¢é£ : Pythonã§CodeEvalã®Fibonacci Series - brainstorm
é¢é£ : Pythonã§CodeEvalã®Sum Of Digits - brainstorm
é¢é£ : Pythonã§CodeEvalã®Lower Case - brainstorm
é¢é£ : Pythonã§CodeEvalã®BitPositions - brainstorm
é¢é£ : Pythonã§CodeEvalã®Multiples of a Number - brainstorm
å¼æ°ã§ãã¡ã¤ã«åã渡ãã¦ãã¡ã¤ã«1è¡ãã¨ã«åèªãéé ã«ãã¦æ¨æºåºåå ¥åãã¡ã¤ã« Hello World Hello CodeEvalå®è¡çµæ World Hello CodeEval Hello é¢é£: Pythonã§codeevalã®reverse words - brainstorm
é¢é£ : CodeEvalã®Sum of Primes - brainstorm æpython2ã§æ¸ããã®ãgoã§æ¸ãã¦ã¿ã å®è¡çµæ 3682913
é¢é£ : ã¨ã©ãã¹ããã¹ã®ãµãã - brainstormç·´ç¿ã®ããæ¸ãã¦ã¿ããã©ãã£ããããªã package main import ( "fmt" "math" ) func Sieve(n int) chan int { s := make([]bool, n) for x := 2; x < int(math.Sqrt(float64(n)))+1; x++ { if !s[x] { for i :=â¦
jsonãè¿ãã ãã®ãµã¼ãã¼ package main import ( "encoding/json" "fmt" "net/http" ) type ColorGroup struct { ID int Name string Colors []string } func handler(w http.ResponseWriter, r *http.Request) { group := ColorGroup{ ID: 1, Name: "Reds"â¦
Odometer â Transition numbers with ease ã¹ãã¼ãã¡ã¼ã¿ã¼ã¿ããã«ã¢ãã¡ã¼ã·ã§ã³ãã¦æ°åã表示ã§ããã©ã¤ãã©ãªã ã¡ãã£ã¨è§¦ã£ã¦ã¿ã¦éãã§ããã jQueryãªã©ä¾åã©ã¤ãã©ãªç¡ãã ãã¼ããããã¤ãç¨æããã¦ãã¦ãã·ã³ãã«ãªãã¤ãã 使ãæããªããâ¦
os.environã使ã # coding=utf-8 import os # ç°å¢å¤æ°è¨å® os.environ["hoge"] = "fuga" # ç°å¢å¤æ°åå¾ print "hoge is {}".format(os.environ["hoge"]) # -> hoge is fuga # ç°å¢å¤æ°ããªã¹ãã§åå¾ for i, pair in enumerate(os.environ.iteritems()): â¦
python # coding=utf-8 from urlparse import urlparse, parse_qs s = "http://www.cwi.nl:80/%7Eguido/Python.html?a=b#f" u = urlparse(s) print u # ã¹ãã¼ã print u.scheme # -> http # ãã¹ã print u.netloc # -> www.cwi.nl:80 # ãã¼ãçªå·ã¨hostnaâ¦
pythonã§æååãasciiæåã®ã¿ã§æ§æããã¦ãããã©ããã調ã¹ãæ¹æ³ãã°ã°ã£ã¦ã¦ãencodeã¨ãdecodeã使ãæ¹æ³ãè¦ã¤ããã def is_ascii(u): try: if isinstance(u, unicode): u.encode('ascii') elif isinstance(u, str): u.decode('ascii') else: returâ¦
é¢é£ : é åã®åè¦ç´ ãå ¨ã¦æ¡ä»¶ãæºãããã©ããã調ã¹ã - brainstorm Goè¨èªã ã¨ãã«ãã¤ã³ã«ã¯ç¡ãããã èªåã§æ¸ãã¨ãããªæãã package main import ( "fmt" ) func All(vs []string, f func(string) bool) bool { for _, v := range vs { if !f(v) â¦
é¢é£ : pythonã§10é²æ°ããné²æ°ã«åºæ°å¤æ - brainstorm package main import ( "fmt" "strconv" ) import () func main() { for i := 2; i <= 36; i++ { fmt.Println(strconv.FormatInt(10000000, i)) } } å®è¡çµæ 100110001001011010000000 200211001102â¦
é¢é£ : Python/Ruby/Javaã§Base64ã¨ã³ã³ã¼ã - brainstorm package main import ( "encoding/base64" "fmt" "io/ioutil" "os" ) func main() { // æååãbyteé åã«ãã¦base64ã«ãã data := "volume contrast brilliance" sEnc := base64.StdEncoding.Encâ¦
é¢é£ : pythonãrubyã§æååã1æåãã¤ã®ãªã¹ãã«ãã - brainstormruneãããªãã¦stringã®ãªã¹ãã«ãã package main import ( "strings" "fmt" ) func main() { str := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" fmt.Printf("%â¦
æå·ãããã·ã¥ã«ã¤ãã¦ã¯ãcryptoããã±ã¼ã¸ã«ããããæã£ã¦ããã crypto - The Go Programming Language package main import "crypto/sha1" import "fmt" func main() { s := "ä»»æã®æåå" h := sha1.New() // ãã¤ãé åã渡ã h.Write([]byte(s)) /â¦
Pycharm 3.0.1 RCããã¦ã³ãã¼ãã§ããããã«ãªã£ã¦ã 主ã«ãã°ãã£ãã¯ã¹ã®æ¨¡æ§PyCharm 3.0.1 RC available | JetBrains PyCharm Blog ãããã§ã®ã¢ãããã¼ãã¯ã§ããªããããã®ã§DLããå¿ è¦ããã JetBrains PyCharm Preview (EAP) - PyCharm - Confluence
ãã¡ã¤ã«åããµã¤ãºãªã©ãåå¾ package main import ( "fmt" "os" ) func main() { f, _ := os.Open("main.go") defer f.Close() if fi, err := f.Stat(); err == nil { fmt.Printf("ãã¡ã¤ã«å: %s\n", fi.Name()) fmt.Printf("ãã¡ã¤ã«ãµã¤ãº(byte): %d\n"â¦
go.textããã±ã¼ã¸ã使ã $ go get code.google.com/p/go.text/encoding $ go get code.google.com/p/go.text/encoding/japanese 使ãæ¹ã調ã¹ãããã«sjisã®ãã¡ã¤ã«ãeucjpã«å¤æãã¦ã³ãã¼ããå¦çãæ¸ãã¦ã¿ã package main import ( "code.google.com/pâ¦
rangeã«stringã渡ãã¨byte positionã¨runeã1ã¤ãã¤åå¾ã§ãã package main import ( "fmt" "unicode/utf8" ) func main() { s := "ããããã" // rangeã«stringã渡ãã¨pos,runeãé ã«è¿ã for pos, r := range s { fmt.Printf("character %c starts at â¦
åè : How to reverse a string in Go? - Stack Overflowstringãruneã®é åã«å¤æããæ¹æ³ãéã«runeã®é åãstringã«å¤æããæ¹æ³ãããã£ãã package main import ( "fmt" "unicode/utf8" ) func Reverse(s string) string { runes := []rune(s) for i,â¦
len(string)ã ã¨ãã¤ãé·ãè¿ãã utf8.RuneCountInStringã使ãã¨æåæ°ãåå¾ã§ããã package main import ( "fmt" "unicode/utf8" ) func main() { s := "ããããã" // å ¥åå¤ fmt.Printf("%v\n", s) // -> ããããã // len(s)ã¯ãã¤ãé·ãè¿ã fmt.â¦
C-x oã§ç§»åããã®ãé¢åããããªã£ãã®ã§ã1ã¹ããã¼ã¯ã§èªç±ã«ç§»åã§ããããã«ãããã£ã (global-set-key (kbd "<C-s-left>") 'windmove-left) (global-set-key (kbd "<C-s-down>") 'windmove-down) (global-set-key (kbd "<C-s-up>") 'windmove-up) (global-set-key (kbd "<C-s-right>") 'windm</c-s-right></c-s-up></c-s-down></c-s-left>â¦
æè¿ã»ãã®ã¡ãã£ã¨ãã¤ã ãã©Goè¨èªãåå¼·ãã¦ã¿ã¦ãããGoè¨èªã§æ¸ãã¨ãã¯emacsã使ãã®ã ãã©ãgofmtãä¿åæã«åãããã«è¨å®ãã¦ãã£ã¦ããããçµæ§æ°æã¡ããã ã³ã¼ãæ¸ãã¦ãã¨ãã¯ãã©ã¼ããããå ¨ãæ°ã«ããªãã¦ãä¿åæã«ç´ãã¦ãããã (setenvâ¦
argparseã§ãã«ããã¤ãæåã渡ãã¨ãã¤ãååã¨ãã¦åå¾ãããunicodeåã¨ãã¦æ±ãããå ´åã¯decodeããå¿ è¦ãããããã¨ã³ã³ã¼ãã£ã³ã°ãã©ãããã¹ãã調ã¹ã¦ãå¤åsys.getfilesystemencodingã使ãã°ãããã ã¨æããã©ãmacosxã®python2ãpython3ã§ãâ¦
èµ·åãããã¨ããã¨X11ãå¿ è¦ã¨ãããåã¯ä½¿ãã¦ãã®ã§Mountain Lionããå¿ è¦ã«ãªã£ãã¨æããã Mountain Lionã®X11ã«ã¤ãã¦ã¯ä»¥ä¸ã®ãã¼ã¸ã«æ å ±ããã X11 ããã³ OS X Mountain Lion ã«ã¤ã㦠ãã¼ã¸ã®ãªã³ã¯ããXQuartsãDLããXQuartz XQuartsãã¤ã³ã¹â¦
è¾æ¸ã§åèªã®åºç¾åæ°ãã«ã¦ã³ããããããªã³ã¼ãã®ãµã³ãã«åãã¦ç»å ´ããåèªã®ã¨ãã ããã¤ã³ã¯ãªã¡ã³ããããªãã¦1ãå ¥ããå¦çãããå¿ è¦ããã data = open("sample.txt").read() words = data.split() d = {} for word in words: if word in d: d[worâ¦