Movatterモバイル変換
[0]
ホーム
URL:
画像なし
夜間モード
Cookpad Code Puzzle 2022
Goal
You can run the Ruby code on a modern browser like Google Chrome. Try to press "Run Ruby" button.
Observe the behavior of method
func
1
and define a method
answer
1
that performs the same behavior as
func
1
.
Code
# You can call `func1`p func1(0) #=> 1p func1(1) #=> 2p func1(2) #=> 3# Can you tell how `func1` is defined?# Hint: def func1(n) = n + ???# Define `answer1` that works like `func1`def answer1(n) nend
Problem select:
func1
Reset
Run Ruby (or press Ctrl-Enter)
Stop
Loading ruby.wasm...
(Please try reloading if it takes too long)
Output
(C) 2022 Cookpad Inc.
[8]
ページ先頭
©2009-2025
Movatter.jp