整数mから整数n(n >= 1、m >= 1)までのFizzBuzzを計算せよ。ただし、FizzBuzzのクラス定義は次のようになっていなければいけないものとする。
なお、剰余は x % y
、 数値の文字列化は num.toString
で可能である。
case class FizzBuzz(val m: Int, val n: Int) {
def call(): Unit = {
???
}
}
もちろんです!以下に、Chrome拡張機能を作成するためのコードの例を示します。これは、指定された仕様を満たすシンプルな拡張機能です。 | |
まず、プロジェクトディレクトリに3つのファイルを作成してください。 | |
manifest.json | |
background.js | |
content.js | |
manifest.json: |
function doPost(e) { | |
// slack appsのEvent Subscriptionsのchallenge。同期する時に利用。 | |
var params = JSON.parse(e.postData.getDataAsString()); | |
if('challenge' in params) | |
{ | |
return ContentService.createTextOutput(params.challenge); | |
} | |
// ユーザ名とtextを取得 | |
var userName = params.event.user; |
以下の日本語をプログラムとして解釈して実行してください。 | |
ほげ数を計算(N) | |
・もし、N < 2 なら1を返す | |
・そうでなければ、「N * ほげ数を計算(N - 1)」を返す | |
ほげ数を計算(10) |
.class public DifferentReturnTypes | |
.super java/lang/Object | |
; | |
; standard initializer | |
.method public <init>()V | |
aload_0 | |
invokenonvirtual java/lang/Object/<init>()V | |
return |
scala> def from(n: Int): LazyList[Int] = LazyList.cons(n, from(n + 1)) | |
def from(n: Int): LazyList[Int] | |
scala> from(0).take(10).toList | |
val res0: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) |
import com.github.kmizu.scomb._ | |
object Calculator1 extends SCombinator[Int] { | |
def root: Parser[Int] = expression | |
def expression: Parser[Int] = rule(A) | |
def A: Parser[Int] = rule(chainl(M) { | |
$("+").map { op => (lhs: Int, rhs: Int) => lhs + rhs } | | |
$("-").map { op => (lhs: Int, rhs: Int) => lhs - rhs } |
import java.util.*; | |
import java.awt.Point; | |
public class NQueen { | |
public static final String ANSI_GREEN = "\u001B[32m"; | |
public static final String ANSI_RESET = "\u001B[0m"; | |
public static final String ANSI_WHITE = "\u001B[37m"; | |
private final int N; | |
private final Set<Point> queens; | |
public NQueen(int N) { | |
this.N = N; |
import org.scalatest.BeforeAndAfterAll | |
import org.scalatest.fixture.FunSpec | |
import scalikejdbc.{DB, _} | |
import scalikejdbc.config.DBs | |
import scalikejdbc.scalatest.AutoRollback | |
class ReservationRepositorySpec extends FunSpec with AutoRollback with BeforeAndAfterAll { | |
//テスト実行前にダミーデータを追加 | |
override def beforeAll(): Unit = { |
整数mから整数n(n >= 1、m >= 1)までのFizzBuzzを計算せよ。ただし、FizzBuzzのクラス定義は次のようになっていなければいけないものとする。
なお、剰余は x % y
、 数値の文字列化は num.toString
で可能である。
case class FizzBuzz(val m: Int, val n: Int) {
def call(): Unit = {
???
}
}
package for | |
public class For: | |
public static void main(String[] args): | |
for(int i = 0; i < 10; i++): | |
System.out.println(i) |