DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Yuta Goto
Yuta Goto

Posted on

Emojicode FizzBuzz

ใ“ใฎ่จ˜ไบ‹ใฏใ€้›‘่ซ‡Slack Advent Calendar 2019 ใฎ13ๆ—ฅ็›ฎใฎ่จ˜ไบ‹ใงใ™ใ€‚ ๐Ÿ“†

https://adventar.org/calendars/4684

Emojicodeใจใ„ใ†ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชž(?)ใ‚’็”จใ„ใฆFizzBuzzใ‚’ๆ›ธใ„ใŸใฎใงใ€ใ‹ใ‚“ใŸใ‚“ใซ่ชญใฟ่งฃใ„ใฆใ„ใใพใ™ใ€‚ ๐Ÿ’ป

https://www.emojicode.org/

emoji-fizzbuzz

Compile

$ emojicodec fizzbuzz.emojic
Enter fullscreen mode Exit fullscreen mode

Run

$ ./fizzbuzz
Enter fullscreen mode Exit fullscreen mode




๐Ÿ ๐Ÿ‡
  1 โžก๏ธ ๐Ÿ–๐Ÿ†• i

  ๐Ÿ” i โ—€๏ธ๐Ÿ™Œ 15 ๐Ÿ‡
    โ†ช๏ธ i ๐Ÿšฎ 15 ๐Ÿ™Œ 0 ๐Ÿ‡
      ๐Ÿ˜€ ๐Ÿ”คFizzBuzz๐Ÿ”คโ—๏ธ
    ๐Ÿ‰
    ๐Ÿ™…โ†ช๏ธ i ๐Ÿšฎ 5 ๐Ÿ™Œ 0 ๐Ÿ‡
      ๐Ÿ˜€ ๐Ÿ”คBuzz๐Ÿ”คโ—๏ธ
    ๐Ÿ‰
    ๐Ÿ™…โ†ช๏ธ i ๐Ÿšฎ 3 ๐Ÿ™Œ 0 ๐Ÿ‡
      ๐Ÿ˜€ ๐Ÿ”คFizz๐Ÿ”คโ—๏ธ
    ๐Ÿ‰
    ๐Ÿ™… ๐Ÿ‡
      ๐Ÿ˜€ ๐Ÿ”ก i 10โ—๏ธโ—๏ธ
    ๐Ÿ‰
    i โž• 1 โžก๏ธ๐Ÿ– i
  ๐Ÿ‰
๐Ÿ‰
Enter fullscreen mode Exit fullscreen mode
  • ๐Ÿใงใƒกใ‚คใƒณ้–ขๆ•ฐ
  • ๐Ÿ‡ ๐Ÿ‰ใงใƒ–ใƒญใƒƒใ‚ฏใฎๅง‹ใ‚ใจใŠใ‚ใ‚Š
  • โžก๏ธ :lower_left_crayon:๐Ÿ†• ๅค‰ๆ•ฐไปฃๅ…ฅ
  • ๐Ÿ” Whileใƒซใƒผใƒ—
  • โ—€๏ธ๐Ÿ™Œ ๅฐใชใ‚Šใ‚คใ‚ณใƒผใƒซ โ‰ฆ
  • โ†ช๏ธ if
  • ๐Ÿšฎ ๅ‰ฐไฝ™็ฎ—
  • ๐Ÿ™Œ ใ‚คใ‚ณใƒผใƒซ
  • ๐Ÿ˜ƒ ๆ–‡ๅญ—ๅˆ—ๆจ™ๆบ–ๅ‡บๅŠ›
  • ๐Ÿ”ค ๆ–‡ๅญ—ๅˆ—ใ‚’ๅ›ฒใ‚€ใƒ€ใƒ–ใƒซใ‚ฏใ‚ฉใƒผใƒ†ใƒผใ‚ทใƒงใƒณใฎใ‚ˆใ†ใชๅƒใใ‚’ใ™ใ‚‹ใ‚„ใค
  • โ— ้–‰ใ˜ใ‚ซใƒƒใ‚ณใฎใ‚ˆใ†ใชใ‚‚ใฎใ€‚Booleanใฎ้ ญใฎๆ–นใซใ‚ใฃใŸใ‚‰ๅฆๅฎšใ™ใ‚‹ๅƒใใ‚‚ใ‚‚ใคใ€‚
  • ๐Ÿ™…โ†ช๏ธ elseif
  • ๐Ÿ™… else
  • ๐Ÿ”ก ๆ•ดๆ•ฐๅ€คใ‚’ๆ–‡ๅญ—ๅˆ—ใซๅค‰ๆ›ใ™ใ‚‹
  • โž• +

ใชใฎใงใ‚ˆใใฟใ‚‹่จ€่ชžใงๆ›ธใ็›ดใ™ใจใ€

# ruby
def main
  i = 1

  while i <= 15
    if i % 15 == 0
      puts "FizzBuzz"
    elsif i % 5 == 0
      puts "Buzz"
    elsif i % 3 == 0
      puts "Fizz"
    else
      puts i.to_s
    end
    i = i + 1
  end
end
Enter fullscreen mode Exit fullscreen mode
# python3
def main():
  i = 1

  while i <= 15:
    if i % 15 == 0:
      print("FizzBuzz")
    elif i % 5 == 0:
      print("Buzz")
    elif i % 3 == 0:
      print("Fizz")
    else:
      print(str(i))

    i = i + 1
Enter fullscreen mode Exit fullscreen mode

ใจใ‹ใชใ‚Šใพใ™ใ€‚

ๅ…ฅๅŠ›ใฏใ‹ใชใ‚Šๅคงๅค‰ใงใ™ใŒใ€่ฆ‹ใŸ็›ฎใซๆ…ฃใ‚Œใฆใ—ใพใˆใฐใ‹ใชใ‚Šๆฅฝใ—ใ„ใงใ™ใ€‚

Top comments (0)

๐ŸŒš Life is too short to browse without dark mode