SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
プログラマ脳を鍛える会
vol.2β
2016/08/04 勉強会
タイムスケジュール
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
・問題紹介 [1min] ヒント1 [1min]
・問題を解く [15min]
・解答者 解説 1名 [5min]
・効率よく実⾏するについて考える [3min]
・ヒント2 [5min]
・解答開⽰&解説 [5min]
⽇付の2進数変換
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
年⽉⽇をYYYYMMDDの8桁の整数で表した時,これを2進数に変換して逆から並
べ,さらに10進数に戻した時,元の⽇付になるものを探して下さい.
期間は,
前回の東京オリンピック(1964年10⽉10⽇)から,次回の東京オリンピック
(2020年7⽉24⽇予定)とします.
ex) 1966年7⽉13⽇
1. YYYYMMDDフォーマット

-> 19600713
2. 2進数に変換

-> 1001010111111111110101001
3. 2進数を逆から並べる
-> 1001010111111111110101001
4. 逆から並べた2進数を10進数に戻す
-> 19660713
開始!
ヒント1: ⽇付を順番に出⼒する⽅法について考える
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
ggりましょう
解答者・解説
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
ヒント2: 効率よくする⽅法について考える
年⽉⽇をYYYYMMDDの8桁の整数で表した時,これを2進数に変換
して逆から並べ,さらに10進数に戻した時,元の⽇付になるもの
から法則を⾒つける
19660713
19660905
19770217
19950617
20020505
20130201
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
ヒント1: 効率よくする⽅法について考える
19641010 => 1001 010111011001010110010
20200724 => 1001 101000011110100010100
必ず左が1001になるなら,反転させたものの右側は1001
↓8 ↓1 ↓8
1001[xxxxxxxx][x][xxxxxxxx]1001 になるはず (xは17
つ)
残りの17桁について考える
残りの17桁ということは,左右の8⽂字ずつを⽐較して
中央の1桁の0 or 1で⽇付になるものを抽出すればいい
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
解答・解説
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
⾼速に実⾏できるコードが本当に良いコードなのか?
ベンチマーク
普通の解答 : 0.049416568006563466s
効率化した解答: 0.002531388003262691s
問題引⽤: https://codeiq.jp/magazine/2013/11/2397/
プログラマ脳を鍛える会 vol.2β
2016/08/04 勉強会
ご清聴ありがとうございました

Más contenido relacionado

Destacado

9espacioyvolumen1eso
9espacioyvolumen1eso9espacioyvolumen1eso
9espacioyvolumen1esoPablo Borrego
 
Destination weddings abroad
Destination weddings abroadDestination weddings abroad
Destination weddings abroadLamoreWeddings
 
Maltrato animal
Maltrato animalMaltrato animal
Maltrato animalflaka26
 
Tama river 201611
Tama river 201611Tama river 201611
Tama river 201611Nobuko Naka
 
Eloqua Master Certifications
Eloqua Master CertificationsEloqua Master Certifications
Eloqua Master CertificationsBeth Huffner, MBA
 
The Cougar Business Consulting Group 2003
The Cougar Business Consulting Group 2003The Cougar Business Consulting Group 2003
The Cougar Business Consulting Group 2003R. Jesse Johnson
 
Benzene argus - modified bitumen presentation
Benzene   argus - modified bitumen presentationBenzene   argus - modified bitumen presentation
Benzene argus - modified bitumen presentationSiva Subra
 

Destacado (8)

9espacioyvolumen1eso
9espacioyvolumen1eso9espacioyvolumen1eso
9espacioyvolumen1eso
 
Destination weddings abroad
Destination weddings abroadDestination weddings abroad
Destination weddings abroad
 
Maltrato animal
Maltrato animalMaltrato animal
Maltrato animal
 
Tama river 201611
Tama river 201611Tama river 201611
Tama river 201611
 
Eloqua Master Certifications
Eloqua Master CertificationsEloqua Master Certifications
Eloqua Master Certifications
 
The Cougar Business Consulting Group 2003
The Cougar Business Consulting Group 2003The Cougar Business Consulting Group 2003
The Cougar Business Consulting Group 2003
 
Introdução ao Azure Mobile Apps
Introdução ao Azure Mobile AppsIntrodução ao Azure Mobile Apps
Introdução ao Azure Mobile Apps
 
Benzene argus - modified bitumen presentation
Benzene   argus - modified bitumen presentationBenzene   argus - modified bitumen presentation
Benzene argus - modified bitumen presentation
 

Último

20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directoryosamut
 
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxAtomu Hidaka
 
プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価sugiuralab
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
プレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールプレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールsugiuralab
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000Shota Ito
 

Último (7)

20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory
 
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
 
プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
 
プレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールプレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツール
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000
 

プログラマ脳を鍛える会 Vol2β