Skip to content

Instantly share code, notes, and snippets.

View shiracamus's full-sized avatar

@shiracamus shiracamus

View GitHub Profile
const WORDS = {
"ポケモン": ['株式会社ポケモン', '任天堂', 'ゲームソフト'],
"株式会社ポケモン": ["登場する架空の生物", "アニメ", "メディアミックス"],
"任天堂": ["マリオ", "ゼルダ", "星のカービィ"],
};
function getAncWords(word) {
// 引数の文字列を元に検索でキーワードを文字列の配列で返す処理
// 例:['株式会社ポケモン', '任天堂', 'ゲームソフト']、空配列が返る事もある
console.log("getAncWords:", word);
def solution(garden):
days = 0
# 咲いている花(1)の周囲で咲いていない花(0)、つまり次に咲く花の位置を列挙
grows = {(ny, nx)
for y, row in enumerate(garden)
for x, flower in enumerate(row)
if flower == 1
for ny, nx in ((y-1, x), (y+1, x), (y, x-1), (y, x+1))
if 0 <= ny < len(garden) and 0 <= nx < len(garden[ny])
if garden[ny][nx] == 0}
import java.util.Random;
public class RPG {
public static void main(String[] args) {
Hero hero = new Hero();
Monster monster = new Dragon();
Character attacker = hero;
Character defender = monster;
while (attacker.isAlive()) {
attacker.attack(defender);
@shiracamus
shiracamus / qiitacode.py
Last active May 2, 2022 02:28
download a Qiita article and print program in code blocks
#!/usr/bin/env python3
"""
download a Qiita article and print program in code blocks
example:
$ python3 qiitacode.py https://qiita.com/shiracamus/items/556ff8d916712a9f7055
$ python3 qiitacode.py https://qiita.com/shiracamus/items/556ff8d916712a9f7055 c
$ python3 qiitacode.py https://qiita.com/shiracamus/items/556ff8d916712a9f7055 py
"""
import random
class Character:
def __init__(self, name, hit_point, attack_power):
self.name = name
self.hit_point = hit_point
self.attack_power = range(attack_power + 1)
def is_dead(self):
import wordlist
from typing import Callable
def best_candidate(words: list[str]) -> str:
if len(words) > 3**5:
return None
for candidate in words:
patterns = set("".join("g" if c == w else "y" if c in word else "w"
for c, w in zip(candidate, word))
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.stream.Collectors;
import java.util.Scanner;
public class BlackJack {
public static void main(String[] args) {
System.out.println("ブラックジャックゲーム");
Deck deck = new Deck();
class Blackjack
def play
puts <<~END
=======================
Welcome to Blackjack!!!
=======================
END
import random
class Hand:
def __init__(self, shape, stronger_than):
self.shape = shape
self._stronger_than = stronger_than
def __repr__(self):