2018-10-01から1ヶ月間の記事一覧

文字列→1文字ずつにカンマいれる

<script> var pi1 ="31415"var pi2 =pi1.replace(/(.)(?=.)/g,"$1,")document.write(pi2) </script>

文字列→1文字ずつのリストに

str1 = "0123456789"str2 = list(str1)print(str2)

pi =[3,1,4,1,5,9,2,6,5,3,5,8,9,7,9]picubes=[x**3 for x in pi]print(picubes)

pi =[3,1,4,1,5,9,2,6,5,3,5,8,9,7,9]pisquares=[x**2 for x in pi]print(pisquares)

さっきのを今度はJSで反転して元に戻してみる

<script> function hanten(p) {return p.split("").reverse().join("")} console.log(hanten("6712483595162964564471389651995548562"));document.write(hanten("612961845123799031836303480873397492701632806249165191")); </script>

いまの数値を分解メモ

(%i1) factor(6712483595162964564471389651995548562); (%o1) 2*13*17*59*4751*54549105912577*993199035727177 (%i2) factor(612961845123799031836303480873397492701632806249165191); (%o2) 47*61*131*9013*122149*14824333149960174181021328023188449…

反転は面白い!②

m='191561942608236107294793378084303638130997321548169216'n=m[::-1]print(n) 結果 612961845123799031836303480873397492701632806249165191

反転は面白い!①

m='2658455991569831744654692615953842176'n=m[::-1]print(n) 結果 6712483595162964564471389651995548562

階段

Sub 階段降りるように()Selection.MoveRight Unit:=wdCharacter, Count:=9 Selection.TypeParagraph Selection.MoveRight Unit:=wdCharacter, Count:=8 Selection.TypeParagraph Selection.MoveRight Unit:=wdCharacter, Count:=7 Selection.TypeParagraph S…

Piのリズムで改行するというのも面白い

Selection.MoveRight Unit:=wdCharacter, Count:=3 Selection.TypeParagraph Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.TypeParagraph Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.TypeParagraph Selection.MoveRight Uni…

全部掛ける、あるいは全部足す

<script> var arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]; var rst1 = arr.reduce(function (previous, current) {return previous * current;}); var rst2 = arr.reduce(function (previous, current) {return previous + current; }); console.log(rst1</script>…

とりあえずmapで2倍してみた

<script> var arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9];var rst = arr.map(function( val ) {return val * 2;}); console.log( rst );document.write( rst ); </script>