コンピュータとじゃんけんするゲーム
- プレイヤーは手を選択
- コンピュータはランダムで手を選択
- 勝敗を判定して表示
| #!/bin/sh | |
| VERSION='90' | |
| TUTOR_DIR="/usr/share/vim/vim$VERSION/tutor" | |
| TUTOR_JA=$(tempfile -p 'ja') | |
| TUTOR=$(tempfile -p 'en') | |
| chmod +w $TUTOR | |
| cp $TUTOR_DIR/tutor.ja.utf-8 $TUTOR_JA | |
| cp $TUTOR_DIR/tutor $TUTOR |
| const createInfo = (start, max) => { | |
| const threads = GmailApp.getInboxThreads(start, max) | |
| const matrix = threads.map(v => ( | |
| [ | |
| v.getId(), | |
| v.getFirstMessageSubject(), | |
| v.getMessageCount() | |
| ] | |
| )) | |
| return matrix |
(() => {
// define function入力は以下のテンプレートを使用する
const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = stream.split('\n')標準入力は以下を使用
const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
// const cols = stream.split(' ')
// const lines = stream.split('\n')
// const matrix = stream.split('\n').map(line => line.split(' '))| // 1114.js | |
| const arr = [0, 1, 12, 24, 36] | |
| const start = 2 | |
| const f1 = (arr, start) => { | |
| const head = arr.slice(0, 2) | |
| const tail = arr.slice(start + 2) | |
| return [...head, 16, 25, ...tail] | |
| } |
| const fun = array => n => array.map(v => v * n) | |
| const array = [1, 2, 3] | |
| console.log(JSON.stringify(array.map(v => fun(array)(v)))) |
| const fileSync = file => { | |
| const stream = require('fs').readFileSync(file, 'utf8').trim() | |
| console.log(stream) | |
| return stream | |
| } | |
| const fileAsync = file => { | |
| const callback = (error, data) => data | |
| const stream = require('fs').readFile(file, 'utf8', | |
| callback |
| const identity = v => v | |
| const join = (sep = '\n') => array => array.join(sep) | |
| const split = (sep = ' ') => string => string.split(sep) | |
| const inputs = (file = '/dev/stdin') => { | |
| const stream = require('fs').readFileSync(file, 'utf-8').trim() | |
| const toArray = sep => fn => iter => Array.from(split(sep)(iter), fn) | |
| return { | |
| readCols: (fn = identity) => toArray(' ')(fn)(stream), | |
| readRows: (fn = identity) => toArray('\n')(fn)(stream), | |
| readStream: (fn = identity) => fn(stream), |