Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                // ステッカーカードの配列
const cards: string[][] = [
  ["Eldrazi", "Guacamole", "Tightrope"],
  ["Trendy", "Circus", "Pirate"],
  ["Night", "Brushwagg", "Ringmaster"],
  ["Urza's", "Dark", "Cannonball"],
  ["Misunderstood", "Trapeze", "Elf"],
  ["Zombie", "Cheese", "Magician"],
  ["Carnival", "Elephant", "Meteor"],
  ["Happy", "Dead", "Squirrel"],
  ["Slimy", "Burrito", "Illusion"],
  ["Spooky", "Clown", "Mox"],
  ["Mystic", "Doom", "Sandwich"],
  ["Narrow-Minded", "Baloney", "Fireworks"],
  ["Unsanctioned", "Ancient", "Juggler"],
  ["Deep-Fried", "Plague", "Myr"],
  ["Contortionist", "Otter", "Storm"],
  ["Sticky", "Kavu", "Daredevil"],
  ["Goblin", "Coward", "Parade"],
  ["Phyrexian", "Midway", "Bamboozle"],
  ["Eternal", "Acrobat", "Toast"],
  ["Jetpack", "Death", "Seltzer"],
  ["Demonic", "Tourist", "Laser"],
  ["Cursed", "Firebreathing", "Yogurt"],
  ["Ancestral", "Hot", "Dog", "Minotaur"],
  ["Familiar", "Beeble", "Mascot"],
  ["Giant", "Mana", "Cake"],
  ["Snazzy", "Aether", "Homunculus"],
  ["Squid", "Fire", "Knight"],
  ["Cool", "Fluffy", "Loxodon"],
  ["Space", "Fungus", "Snickerdoodle"],
  ["Playable", "Delusionary", "Hydra"],
  ["Wrinkly", "Monkey", "Shenanigans"],
  ["Geek", "Lotus", "Warrior"],
  ["Primal", "Elder", "Kitty"],
  ["Sassy", "Gremlin", "Blood"],
  ["Yawgmoth", "Merfolk", "Soul"],
  ["Unassuming", "Gelatinous", "Serpent"],
  ["Squishy", "Sphinx", "Ninja"],
  ["Unique", "Charmed", "Pants"],
  ["Unhinged", "Beast", "Hunt"],
  ["Wild", "Ogre", "Bupkis"],
  ["Notorious", "Sliver", "War"],
  ["Weird", "Angel", "Flame"],
  ["Vampire", "Champion", "Fury"],
  ["Trained", "Blessed", "Mind"],
  ["Unglued", "Pea-Brained", "Dinosaur"],
  ["Elemental", "Time", "Flamingo"],
  ["Unstable", "Robot", "Dragon"],
  ["Werewolf", "Lightning", "Mage"]

// 母音の配列
const vowels: string[] = ["a", "e", "i", "o", "u", "y"]

// 単語に含まれる母音を数える
const countVowels = (name: string): number => {
  const lowerCase = name.toLowerCase()
  let count = 0
  vowels.forEach(vowel => {
    if (lowerCase.includes(vowel)) {
      count += 1
  return count

// カード内で最多の母音を含むステッカーを見つける
const maxName = (sticker: string[]): { count: number, index: number } => {
  const counts: number[] = []
  sticker.forEach(name => {
  const count = Math.max(...counts)
  const index = counts.indexOf(count)
  return { count, index }

type Counted = { cardName: string, count: number, stickerName: string }

// 最適なステッカーデッキを算出する
const calculateDeck = (): { cardName: string, count: number, stickerName: string }[] => {
  // 各カードの最多母音ステッカーを見つける
  const countedStickers: Counted[] = []
  cards.forEach(card => {
    const cardName = card.join(" ")
    const count = maxName(card).count
    const stickerName = card[maxName(card).index]
  // 母音のカウントで並べ替える
  const sortedStickers: Counted[] = Array.from(countedStickers).sort((a, b) => {
    return b.count - a.count
  return sortedStickers.slice(0, 10)

// 最適なデッキにおける期待値を計算する
const calculateExepted = (): number => {
  const counts = calculateDeck().map(card => card.count)
  const maxCounts: number[] = []
  for (let x = 0; x < counts.length; x++) {
    for (let y = x + 1; y < counts.length; y++) {
      for (let z = y + 1; z < counts.length; z++) {
        maxCounts.push(Math.max(counts[x], counts[y], counts[z]))
  const sum = maxCounts.reduce((a,b) => a + b)
  return sum / maxCounts.length