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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
360
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
5
1.6k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
630
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
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.1k
AWSに止められる覚悟してますか?
morizo_1984
2
510
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
160
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
620
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
290
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
550
Heart of Swift Concurrency
koher
0
1.2k
Are APIs Still Relevant in the AI Era?
soyuka
0
420
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
470
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
620
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
Into the Great Unknown - MozCon
thekraken
41
2.8k
Making Projects Easy
brettharned
120
6.8k
The Cost Of JavaScript in 2023
addyosmani
55
10k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Test your architecture with Archunit
thirion
2
2.4k
Speed Design
sergeychernyshev
33
2.1k
Deep Space Network (abreviated)
tonyrice
0
350
Designing for humans not robots
tammielis
254
26k
Side Projects
sachag
456
43k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
840
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!ʗ