Skip to content

Instantly share code, notes, and snippets.

(1..100).each do |n|
if n % 3 != 0 && n % 5 != 0 then
print n
end
if n % 3 == 0 then
print "Fizz"
end
if n % 5 == 0 then
print "Buzz"
end
def basic():
for i in range(1, 101, 1):
cond1 = (i % 3 == 0)
cond2 = (i % 5 == 0)
cond3 = cond1 and cond2
if cond3:
print(i, 'FizzBuzz')
elif cond2:
class NabeatsuCore
def is_fizz?(num)
is_convert?(num, 3)
end
def is_buzz?(num)
is_convert?(num, 5)
end
function fizzbuzz(num) {
for (var i = 1; i < num + 1; i++) {
if(i % 15 === 0) {
console.log("fizzbuzz");
continue;
}
if(i % 3 === 0) {
console.log("fizz")
continue;
}
@kmdsbng
kmdsbng / jooby_kotlin_module_example.kt
Last active November 28, 2017 09:38
Jooby + Kotlin module implementation example.
class AppendAccessControlForDevEnv : Jooby.Module {
override fun configure(env: Env?, conf: Config?, binder: Binder?) {
if (env != null) {
env.router().get("*") {req, rsp ->
rsp.header("Access-Control-Allow-Origin", "http://localhost:8090")
}
}
}
}
// オブジェクト指向用語説明用サンプル
//
// class(クラス) :
// データと関数 をひとまとめにした入れ物の定義(型)。
// 一般に、クラスが持つデータのことを「フィールド」、
// クラスが持つ関数のことを「メソッド」と呼ぶ。
// メソッドは引数で値を与えられなくても、自身のフィールドを
// 使うことができる。
//
// instance(インスタンス) :
@kmdsbng
kmdsbng / file0.txt
Last active November 28, 2017 03:18
オブジェクト指向初心者向け、クラスとインスタンスの説明 ref: https://qiita.com/kmdsbng/items/030702d8664ff7fdbe1f
// オブジェクト指向用語説明用サンプル
//
// class(クラス) :
// データと関数 をひとまとめにした入れ物の定義(型)。
// 一般に、クラスが持つデータのことを「フィールド」、
// クラスが持つ関数のことを「メソッド」と呼ぶ。
// メソッドは引数で値を与えられなくても、自身のフィールドを
// 使うことができる。
//
// instance(インスタンス) :
///<reference path="../../typings/bundle.d.ts" />
import * as React from 'react';
import * as ReactDOM from 'react-dom';
interface HelloWorldProps {};
interface HelloWorldStates {};
class HelloWorld extends React.Component<HelloWorldProps, HelloWorldStates> {
render() {
# -*- encoding: utf-8 -*-
require 'benchmark/ips'
def fib_naive(n)
return 1 if n <= 2
fib_naive(n - 1) + fib_naive(n - 2)
end
def fib_memo(n)
fib_memo_recur(n, {})
a = 1.tap {|i| puts i + i}
a # => 1
b = 1.tap {|i| break i + i}
b # => 2
# >> 2
#lam = lambda {|i| return 1}