This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_fizz(num:) | |
return num % 3 == 0 ? 0b1 : 0b0 | |
end | |
def is_buzz(num:) | |
return num % 5 == 0 ? 0b1 : 0b0 | |
end | |
def fizz_buzz(max:) | |
(1..max).each do |num| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param array $array | |
* @param callable $function | |
* @return null | array | |
*/ | |
function array_find(array $array, callable $function) | |
{ | |
$result = array_filter( | |
$array, | |
function ($item) use ($function) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.devcontainer/ | |
Dockerfile | |
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
app: | |
build: . | |
ports: | |
- 3000:3000 | |
command: "npx yarn play" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:latest | |
WORKDIR /usr/src/app | |
COPY . ./ | |
RUN npx yarn install | |
RUN npx yarn stub | |
CMD ["/bin/bash"] | |
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IRREGULAR_HASH = {"stop": "stopped", "go": "gone", "read": "read"} | |
VOWELS = ["a", "i", "u", "e", "o"] | |
def verb_past(str): | |
if IRREGULAR_HASH.get(str): | |
return IRREGULAR_HASH[str] | |
elif str[-1] == "y" and not str[-2] in VOWELS: | |
return str[:-1] + "ied" | |
elif str[-1] == "c": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
def initialize(value, next_node = nil) | |
@value = value | |
@next_node = next_node | |
end | |
attr_reader :value | |
attr_accessor :next_node | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example: python nl.py fizz_buzz.py | |
import sys | |
def display_lines_with_number(lines): | |
i = 1 | |
for line in lines: | |
# 改行コードの場合は、行番号を振らずに表示する | |
if line == "\n": | |
print(line, end="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THREE_HASH = {0: "fizz", 1: "", 2: ""} | |
FIVE_HASH = {0: "buzz", 1: "", 2: "", 3: "", 4: "", 5: ""} | |
def fb(i): | |
result = "" | |
result += THREE_HASH[i % 3] | |
result += FIVE_HASH[i % 5] | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fb(n): | |
if n % 15 == 0: | |
return 'FizzBuzz' | |
elif n % 5 == 0: | |
return 'Buzz' | |
elif n % 3 == 0: | |
return 'Fizz' | |
return '' | |
i = 1 |
NewerOlder