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
今日の"どう書く"問題のアルゴリズム例
Search
Takashi Kanemoto
April 17, 2019
Programming
490
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
今日の"どう書く"問題のアルゴリズム例
Nagoya.php #15 補足資料
https://nagoyaphp.connpass.com/event/120856/
Takashi Kanemoto
April 17, 2019
More Decks by Takashi Kanemoto
See All by Takashi Kanemoto
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
2
380
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
5
1.7k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
640
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
1.4k
今年書いた技術記事で伸びたやつの自慢と自分の中では力作なのにさっぱり伸びなかったやつの供養 / My Tech Articles 2024
ttskch
2
240
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
48
45k
データベース/SQL超入門!完全初心者向けに世界一分かりやすく解説します
ttskch
2
8.9k
Symfony UX Autocompleteとかいう 顧客が本当に必要だったもの
ttskch
0
2.4k
就活生あるいは新人エンジニアさんへのお節介なアドバイス
ttskch
0
1.7k
Other Decks in Programming
See All in Programming
すこし踏み込む CancellationToken
htkym
2
1.7k
ChromeでローカルLLM
ryu1013
0
130
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
100
contenteditable と日本語入力に向き合う
colorful12
0
190
R8 の設定見直しでアプリサイズ削減
andpad
0
210
JRuby: Past, Present, and Future
headius
0
230
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
170
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
660
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
250
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
130
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
410
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Making Projects Easy
brettharned
120
6.8k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Leo the Paperboy
mayatellez
10
2.4k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
620
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
Transcript
ࠓͷ”Ͳ͏ॻ͘”ͷ ΞϧΰϦζϜྫ 2019/04/17 #nagoyaphp @ttskch
ʹ͍ͭͯ
͖ͨͭͪʢ໊͋ͩʣ • (ג)ΧϧςοτίϛϡχέʔγϣϯζCTO • WebΤϯδχΞྺ7ɺPHPྺ7 • #nagoyaphpʊ • #symfony_meetup
͖ͨͭͪʢ໊͋ͩʣ • ͓ख͍ͨ͠ຊʢ2015/12ʣ • Schooߨࢣʢ2018/04ʣ ʮGitHubΛͬͨσϓϩΠࣗಈԽ࣮ફʯ ʮجຊ͔Β͔ͬ͠ΓֶͿ Symfony2ೖʯ
ͨ ͭ ͖ ͪ twitter.com/ttskch ͋͞ɺ͋ͳͨࠓ͙͢ϑΥϩʔ͠Α͏!!! શແྉ ·͞ʹ໊ݴػ ਓੜͰେͳ͜ͱɺͯ͢ ͖͔ͨͭͪΒڭΘͬͨ
͖ͨͭͪΛϑΥϩʔͨ͠Β ࠊ௧͕࣏Γ·ͨ͠ 100% φϯτʂ ϑΥϩϫʔ͔Βͷࢧ࣋ 100% ͍ͯ͠Δ ͍ͯ͠ͳ͍ ϑΥϩϫʔ͞Μ100ਓʹฉ͖·ͨ͠ ͖ͨͭͪΛϑΥϩʔ͍ͯ͠Δʁ
ձࣾʹ͍ͭͯ
(ג)Χϧςοτίϛϡχέʔγϣϯζ https://quartet-communications.com
(ג)Χϧςοτίϛϡχέʔγϣϯζ https://www.google.co.jp/search?q=Χʔςϯ
(ג)Χϧςοτίϛϡχέʔγϣϯζ https://lisket.jp
We are hiring!ʢϚδͰʣ • PHPer/JSer ઈࢍେืूதʂʢϦϞʔτόΠτՄʣ • Symfony+Angular ͰɺWebࠂۀքΛ ϗϫΠτʹ͢ΔΈΛ࡞ͬͯ·͢
• ܦӦϏδϣϯʮੈքҰޮతͳཧళʯ
We are hiring!ʢϚδͰʣ • ࣗࣾαʔϏεʮLisketʯͰࣗࣾͷۀޮԽ • શࣾһͷฏۉۀ͕࣌ؒ5h/݄͙Β͍Ͱ͢ ಛผड
We are hiring!ʢϚδͰʣ ΤϯδχΞͷಇ͖͢͞େࣄʹͯ͠·͢✨
We are hiring!ʢϚδͰʣ ·͓͚ͣͩͰʂؾܰʹ͔͚͍ͯͩ͘͞
ࠓͷ”Ͳ͏ॻ͘”ͷ ΞϧΰϦζϜྫ 2019/04/17 #nagoyaphp @ttskch
http://nabetani.sakura.ne.jp/hena/ordf04octsp/
ͷٻΊํ
1 2 4 8 16 32 64 128
3 5 4 4
3 5 4 4 1 2 3 2
1 2 3 2 3 5 4 4 ؔͯͦ͠͏
3 5 4 4 1 2 3 2
3 5 4 4 1 2 3 2 3 -1
= 2
3 5 4 4 1 2 3 2 2 +
3 = 5 3 -1 = 2
3 5 4 4 1 2 3 2
3 5 4 4 1 2 3 2 2 -1
= 1
3 5 4 4 1 2 3 2 1 +
3 = 4 2 -1 = 1
3 5 4 4 ࣮ઢؒͷڑ͔ΒٻΊΒΕΔ
5
5 4
5 4 4 -1 = 3
5 4 3 + 3 = 6 4 -1 =
3
5 4 4 -1 = 3 3 + 3 =
6 3 + 2= 5
5 4 ڑ͕4ͷͱ͖͚ͩܭࢉํ๏͕มΘΔ
1 2 4 8 16 32 64 128
2 8 16 64 1 2 3 2 1 4
32 128
21 23 24 26 1 2 3 2 20 22
25 27
21 23 24 26 1 2 3 2 20 22
25 27
21 23 24 26 1 2 3 2 20 22
25 27 ൪߸Λ2ͷྦྷͰද͢ͱࢦ෦ͷࠩͰڑΛٻΊΒΕΔ
21 23 24 26 2 3 2 22 25 Ұप͢Δͱۙͮ͘ߏͳͷͰ8ͷ༨Λ͑Αͦ͞͏✋
1 20 27
ೖྗͷύʔε
1 2 4 8 16 32 64 128
2 8 16 64 165 Λ 1 + 4 +
32 + 128 ʹղ͍ͨ͠ 1 4 32 128
2 8 16 64 1 4 32 128
21 23 24 26 20 22 25 27
165 = 27x1 + 26x0 + 25x1 + 24x0 +
23x0 + 22x1 + 21x0 + 20x1 21 23 24 26 20 22 25 27
165 = b10100101 21 23 24 26 20 22 25
27
21 23 24 26 20 22 25 27 ೖྗΛ2ਐͰද͢ͱɺ͕1ͷܻ͕࣮ઢͷҐஔΛࣔ͢
࣮ྫ
public function run(string $input): string { $lines = array_values(array_filter(range(0, 7),
function (int $i) use ($input) { return str_split(sprintf('%b', $input))[$i] ?? false; })); $vertices = []; for ($i = 0; $i < count($lines); $i++) { $distance = ($lines[($i + 1) % count($lines)] - $lines[$i] + 8) % 8; $vertices[] = ($distance === 4 ? 2 : 3) + $distance - 1; } sort($vertices); return implode('', $vertices); }
public function run(string $input): string { $lines = array_values(array_filter(range(0, 7),
function (int $i) use ($input) { return str_split(sprintf('%b', $input))[$i] ?? false; })); $vertices = []; for ($i = 0; $i < count($lines); $i++) { $distance = ($lines[($i + 1) % count($lines)] - $lines[$i] + 8) % 8; $vertices[] = ($distance === 4 ? 2 : 3) + $distance - 1; } sort($vertices); return implode('', $vertices); } ೖྗΛ2ਐʹมͯ͠ɺཱ͍ͬͯΔϏοτͷҐஔʢ0ʙ7ʣΛྻʹ͢Δɻ ྫͷ߹ $lines === [0, 2, 5, 7] ͱͳΔɻ͜Ε͕࣮ઢͷҐஔɻ ೖྗͷύʔε
public function run(string $input): string { $lines = array_values(array_filter(range(0, 7),
function (int $i) use ($input) { return str_split(sprintf('%b', $input))[$i] ?? false; })); $vertices = []; for ($i = 0; $i < count($lines); $i++) { $distance = ($lines[($i + 1) % count($lines)] - $lines[$i] + 8) % 8; $vertices[] = ($distance === 4 ? 2 : 3) + $distance - 1; } sort($vertices); return implode('', $vertices); } [0, 2, 5, 7] ͱ͍͏ྻʹରͯ͠ɺཁૉؒͷ͔ࠩΒ࣮ઢؒͷڑΛٻΊΔͱɺ (2-0+8)%8=2, (5-2+8)%8=3, (7-5+8)%8=2, (0-7+8)%8=1 ͱͳΔɻ ڑ͕4ͷ߹ 2+ڑ-1 ͕ɺڑ͕ͦΕҎ֎ͷ߹ 3+ڑ-1 ͕ɻ ͷܭࢉ
https://github.com/ ttskch/nagoyaphp15
@ttskch ʘThanks!ʗ