Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
LT20260516.pdf
Search
denkyuu1
May 12, 2026
20
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
LT20260516.pdf
denkyuu1
May 12, 2026
Transcript
14 slides
2 つの言語で動くFizzBuzz 学部2 年 denkyuu1 1
自己紹介 コードゴルフにはまってます プログラムの文字数( バイト数) をできるだけ短くする遊び https://code.golf 主に Ruby Julia でコードゴルフをやってます
2
Julia とPython 両方で動くFizzBuzz 名称はpolyglot polyglot とは、複数のプログラミング言語として解釈可能なコンピュータープログラム またはスクリプトであり、コンパイルまたは解釈に使用されるプログラミング言語と は関係なく、同じ操作または出力をするもののことである。 https://ja.wikipedia.org/wiki/Polyglot_( プログラミング)
3
FizzBuzz とは 1~100 までの数に対して 3 の倍数なら Fizz 5 の倍数なら Buzz
15 の倍数なら FizzBuzz を出力する 余りを調べて条件分岐 4
きっかけ Sei2423 Python でもJavascript でも動く???不思議なコード https://qiita.com/Sei2423/items/b68e83d12e0bd10e4b1c Python とJavascript 両方で動くFizzBuzz 言語仕様の違いで遊ぶ
5
Polyglot すぎゃーんメモ polyglot 基礎の基礎 https://memo.sugyan.com/entry/20110306/1299418878 Okiraku Programming 12 言語polyglot で足し算
https://neocat.hatenablog.com/entry/20140421/1398095941 6
Julia とPython の共通点・相違点 Julia Python 配列の添え字 1 から 0 から
内包表記 [... for i in ...] あり あり range(1, 10) 1, 2, ... ,10 1, 2, ... ,9 print() 改行無し デフォルトで改行あり ^ 累乗 xor 文字列連結 * + 文字列繰り返し ^ * これらを組み合わせてFizzBuzz を書きます 7
例 Julia Python [0, 1][1] 0 1 1 ^ 1
1¹ = 1 1 xor 1 = 0 "a" + "b" エラー "ab" "a" * "b" "ab" エラー "a" * 2 エラー "aa" "a" ^ 2 "aa" エラー 8
活用 別の処理をしたい Julia Python ["Julia", "Python"][1] "Julia" "Python" 同じ処理をしたい Julia
Python ["->", "select", "<-"][(1 ^ 1) + 1] "select" "select" 9
結果 [print([["$i", i][1], "Fizz", "Buzz", "FizzBuzz"][(1^1)+(i%3==0)+2*(i%5==0)]*["\n", 1][1]) for i in
range(1, 100^1)] 10
内包表記 [print("FizzBuzz出力") for i in range(1, 100^1)] どちらも1 から100 まで繰り返す
Julia range(1, 100^1) = range(1, 100) Python range(1, 100^1) = range(1, 101) 100 xor 1 = 0b1100100 xor 0b0000001 = 0b1100101 = 101 11
print print([["$i", i][1], "Fizz", "Buzz", "FizzBuzz"][(1^1)+(i%3==0)+2*(i%5==0)]*["\n", 1][1]) ↓↓↓ print( [出力するものリスト][3,
5で割り切れるか判定] * 文字列を1回繰り返す/末尾の改行 ) 12
print([["$i", i][1], "Fizz", "Buzz", "FizzBuzz"][(1^1)+(i%3==0)+2*(i%5==0)]*["\n", 1][1]) 比較 Julia "$i" は変数展開
数字 * 文字列 はエラー print( ["$i", "Fizz", "Buzz", "FizzBuzz"][(1)+(i%3==0)+2*(i%5==0)] * "\n" ) Python 数字 * 1 は数字出力に影響なし print( [i, "Fizz", "Buzz", "FizzBuzz"][(0)+(i%3==0)+2*(i%5==0)] * 1 ) 13
ご清聴ありがとうございました 14
More Decks by denkyuu1
See All by denkyuu1
LT20261017
denkyuu1
0
19
Featured
See All Featured
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Making Projects Easy
brettharned
120
6.9k
Bash Introduction
62gerente
615
220k
ラッコキーワード サービス紹介資料
rakko
5
5.8M
The Invisible Side of Design
smashingmag
301
52k
Technical Leadership for Architectural Decision Making
baasie
4
640
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
480
From π to Pie charts
rasagy
1
450
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
The SEO Collaboration Effect
kristinabergwall1
1
620