Submit Search
Upload
Code2013 コードゴルフ大会「JavaScriptでデジタル時計」
•
2 likes
•
2,553 views
Sato Yoshiaki
Follow
2013年8月3〜4日に開催されたCode 2013で出題された、JavaScriptのコードゴルフの問題です。
Read less
Read more
Technology
Report
Share
Report
Share
1 of 25
Download now
Download to read offline
Recommended
オセロゲームでコードゴルフ
オセロゲームでコードゴルフ
洸人 高橋
Code Golf
Code Golf
Shinichiro Hamaji
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
Recommended
オセロゲームでコードゴルフ
オセロゲームでコードゴルフ
洸人 高橋
Code Golf
Code Golf
Shinichiro Hamaji
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
taisei2219
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Yuma Ohgami
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
Toru Tamaki
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
Toru Tamaki
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
sugiuralab
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Toru Tamaki
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
danielhu54
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
Ryo Sasaki
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
iPride Co., Ltd.
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
More Related Content
Recently uploaded
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
taisei2219
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Yuma Ohgami
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
Toru Tamaki
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
Toru Tamaki
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
sugiuralab
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Toru Tamaki
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
danielhu54
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
Ryo Sasaki
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
iPride Co., Ltd.
Recently uploaded
(9)
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
Featured
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
ChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
Featured
(20)
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
ChatGPT webinar slides
ChatGPT webinar slides
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Code2013 コードゴルフ大会「JavaScriptでデジタル時計」
1.
Code-Golf with JS デジタル時計 Code
2013 2日目
2.
問題: デジタル時計を出力するclock.jsをできる だけ少ないバイト数で記述せよ! GitHubに問題のリポジトリを公開中 https://github.com/yoshiakist/codegolf
3.
チーム分け A 坂本さん、今野さん、牧野さん B normalianさん、前鼻さん、zeclさん C
tokibitoさん、柴田さん、Drewさん D ももさん、サスケさん、chakさん E 清野さん、工藤さん、石坂さん、長田さん
4.
Let’s Code!! A 坂本さん、今野さん、牧野さん B
normalianさん、前鼻さん、zeclさん C tokibitoさん、柴田さん、Drewさん D ももさん、サスケさん、chakさん E 清野さん、工藤さん、石坂さん、長田さん 制限時間:20分!!
5.
Time up!! お疲れ様でした!
6.
問題の確認 clock.js の特徴: - setTimeout(func,
1000) を再帰呼び出し - sec を分秒に変換 - pattern[‘■ ■’,’■ ■’,’■■■’, ...] から文字列を 生成(この配列が非常に冗長)
7.
JSのショートコーディング ・var 宣言の省略、変数名の短縮 ・for文のインクリメントをデクリメントに ・Math.floor関数の代替 ・setTimeout()を短縮
8.
JSのショートコーディング ・var 宣言の省略、変数名の短縮 ・for文のインクリメントをデクリメントに ・Math.floor関数の代替 ・setTimeout()を短縮 ・”■ ■” 文字列をどう生成するか!?
9.
var宣言の省略/変数名の短縮 var result =
“”; ↓ ↓ ↓ r=“”; ※ var 無しの変数はグローバルオブジェクトを汚 染するので、業務では使用厳禁!!
10.
for文の ++ /
-- for(var i = 0; i < 10; i++){ … } ↓ ↓ ↓ for(i=10;i--;){ … } ※ 業務でも場合によっては有用! (数値との比較より、0との比較の方が高速)
11.
Math.floor関数の代替 Math.floor(3.5) // 3と出力 ↓ ↓ ↓ 0|3.5
// 3と出力 ※ | はビットごとのORを取る
12.
setTimeout関数の短縮ot()を短縮 var repeatFunc =
function(){ // 処理 setTimeout(repeatFunc(), 1000); } ↓ ↓ ↓ setInterval(function(){ // 処理 }, 1000);
13.
AAの文字列”■ ■”の生成 メインディッシュ “■■■”, “■_■”, “■_■”, → これを何バイトで表現するか “■_■”, “■■■”,
14.
Case1. 数字を5バイトで表現 7: “■■■”, 5:
“■_■”, 5: “■_■”, 5: “■_■”, 7: “■■■” →75557 5: “■_■”, 5: “■_■”, 7: “■■■”, 4: “__■”, 4: “__■”, →55744
15.
Case1. 数字を5バイトで表現 str =
“”; for (var i = 0; i<3; i++) { str += 5&Math.pow(2,(i)) ? '■' : '_' ; } // str += (5&1) ? '■' : '_' ; // str += (5&2) ? '■' : '_' ; // str += (5&4) ? '■' : '_' ; → '■_■'
16.
Case2. 数字を4バイトで表現 数字の「4」の場合 “■_■”,”■_■”,”■■■”,”__■”,”__■” ↓ “■_■■_■■■■__■__■”
17.
Case2. 数字を4バイトで表現 数字の「4」の場合 “■_■”,”■_■”,”■■■”,”__■”,”__■” ↓ “■_■■_■■■■__■__■” ↓ (2進数だと)101101111001001
18.
Case2. 数字を4バイトで表現 数字の「4」の場合 “■_■”,”■_■”,”■■■”,”__■”,”__■” ↓ “■_■■_■■■■__■__■” ↓ (2進数だと)101101111001001 ↓ (16進数だと)5BC9
19.
Case2. 数字を4バイトで表現 var bit16
= '5BC9'; var number = parseInt(bit16, 16); console.log(number); //23497 23497 => 101101111001001
20.
Case3. 数字を2バイトで表現 A B C D E F G 7セグを使うと...
21.
Case3. 数字を2バイトで表現 A B C D E F G 7セグを使うと... A B
C D E F G 4F 1 0 0 1 1 1 1 ↓
22.
Case3. 数字を2バイトで表現 7セグを使うと... ここからの逆変換の実装は ご想像にお任せ致しますm(_ _)m
23.
結果発表!! 第2位: Dチーム(ももさん、サスケさん、chakさ ん) 容量:361文字 http://jsfiddle.net/yJ4Pp/1/
24.
結果発表!! 第1位: Bチーム normalianさん、前鼻さん、zecl さん 容量:359文字 http://jsfiddle.net/fjsCd/2/
25.
お疲れ様でした! ・それぞれの得意な言語だったらどう記述できる か? ・今日紹介したアプローチを試すとどうなるか? 沢山、Codeで語ってみてください!
Download now