{"id":163,"date":"2014-06-22T08:40:23","date_gmt":"2014-06-22T06:40:23","guid":{"rendered":"http:\/\/mheinzerling.de\/blog\/?p=163"},"modified":"2014-06-22T08:40:23","modified_gmt":"2014-06-22T06:40:23","slug":"code-kata-berlin-clock","status":"publish","type":"post","link":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/","title":{"rendered":"Code Kata: Berlin Clock"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-188 \" src=\"http:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg\" alt=\"Berlin Clock\" width=\"196\" height=\"235\" \/>Recently I discovered a nice &#8222;new&#8220; Code Kata &#8211; the Berlin Clock. This is a nice Kata for practising Test Driven Development. I&#8217;m neither going to explain the Code Katas in general nor Test Driven Development in this post &#8211; maybe this will become a separate post later.<\/p>\n<p><!--more--><\/p>\n<p>For a historical background please check the detailed description of the <a href=\"http:\/\/www.surveyor.in-berlin.de\/berlin\/uhr\/indexe.html\">Berlin Clock<\/a>. For implementing such a clock in the language of your choice, you need to know the following specification:<\/p>\n<blockquote><p>The time is calculated by adding the lit rectangular lamps. The top lamp is a pump which is blinking on\/off every two seconds. In the upper line of red lamps every lamp represents 5 hours. In the lower line of red lamps every lamp represents 1 hour. So if in the first line 2 lamps are lit and in the second line 3 lamps its 5+5+3=13h or 1 p.m. In the third line with tall lamps every lamp represents 5 minutes. There are 11 lamps, the 3rd, 6th, and 9th are red indicating the first quarter, half, and the last quarter of the hour. In the last line with yellow lamps every lamp represents 1 minute.<\/p><\/blockquote>\n<p><strong>Implement the clock as a function of the three parameter hours (24-based), minutes, seconds and return a multi line string. Find a reasonable representation for the colors and states.<\/strong><\/p>\n<p>If you don&#8217;t follow a test driven approach, try to find reasonable test cases.<\/p>\n<p>Below are two small change request. Implement the standard solution first. Evaluate how much effort it is to adapt your solution. (Hover to make the text readable.)<\/p>\n<div class=\"spoiler\">Build a ticking clock in a textual representation.<\/div>\n<div class=\"spoiler\">Use any graphic frame work supported by your language and implement the running clock with a nice visual representation.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recently I discovered a nice &#8222;new&#8220; Code Kata &#8211; the Berlin Clock. This is a nice Kata for practising Test Driven Development. I&#8217;m neither going to explain the Code Katas in general nor Test Driven Development in this post &#8211; maybe this will become a separate post later.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,20],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-code-kata","category-computer-science"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Code Kata: Berlin Clock - Martin Heinzerling<\/title>\n<meta name=\"description\" content=\"Code Kata - the Berlin Clock. This is a nice Kata for practising Test Driven Development.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Martin Heinzerling\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\"},\"author\":{\"name\":\"Martin Heinzerling\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0\"},\"headline\":\"Code Kata: Berlin Clock\",\"datePublished\":\"2014-06-22T06:40:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\"},\"wordCount\":292,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0\"},\"image\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg\",\"articleSection\":[\"Code Kata\",\"Computer Science\"],\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\",\"url\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\",\"name\":\"Code Kata: Berlin Clock - Martin Heinzerling\",\"isPartOf\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg\",\"datePublished\":\"2014-06-22T06:40:23+00:00\",\"description\":\"Code Kata - the Berlin Clock. This is a nice Kata for practising Test Driven Development.\",\"breadcrumb\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage\",\"url\":\"https:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg\",\"contentUrl\":\"https:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg\",\"width\":239,\"height\":287,\"caption\":\"Berlin Clock\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mheinzerling.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Code Kata: Berlin Clock\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/#website\",\"url\":\"https:\/\/mheinzerling.de\/blog\/\",\"name\":\"Martin Heinzerling\",\"description\":\"Blog eines kletternden Softwareingenieurs.\",\"publisher\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mheinzerling.de\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0\",\"name\":\"Martin Heinzerling\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dc45ec076193eff1627b201e54b32bdb46a6ae7331cb3449173e25986f85bd40?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dc45ec076193eff1627b201e54b32bdb46a6ae7331cb3449173e25986f85bd40?s=96&d=identicon&r=g\",\"caption\":\"Martin Heinzerling\"},\"logo\":{\"@id\":\"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/mheinzerling.de\"],\"url\":\"https:\/\/mheinzerling.de\/blog\/author\/mnhg\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Code Kata: Berlin Clock - Martin Heinzerling","description":"Code Kata - the Berlin Clock. This is a nice Kata for practising Test Driven Development.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/","twitter_misc":{"Verfasst von":"Martin Heinzerling","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#article","isPartOf":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/"},"author":{"name":"Martin Heinzerling","@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0"},"headline":"Code Kata: Berlin Clock","datePublished":"2014-06-22T06:40:23+00:00","mainEntityOfPage":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/"},"wordCount":292,"commentCount":0,"publisher":{"@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0"},"image":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage"},"thumbnailUrl":"http:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg","articleSection":["Code Kata","Computer Science"],"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/","url":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/","name":"Code Kata: Berlin Clock - Martin Heinzerling","isPartOf":{"@id":"https:\/\/mheinzerling.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage"},"image":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage"},"thumbnailUrl":"http:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg","datePublished":"2014-06-22T06:40:23+00:00","description":"Code Kata - the Berlin Clock. This is a nice Kata for practising Test Driven Development.","breadcrumb":{"@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#primaryimage","url":"https:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg","contentUrl":"https:\/\/mheinzerling.de\/blog\/wp-content\/uploads\/2014\/06\/berlin_clock.jpg","width":239,"height":287,"caption":"Berlin Clock"},{"@type":"BreadcrumbList","@id":"https:\/\/mheinzerling.de\/blog\/code-kata-berlin-clock\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mheinzerling.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Code Kata: Berlin Clock"}]},{"@type":"WebSite","@id":"https:\/\/mheinzerling.de\/blog\/#website","url":"https:\/\/mheinzerling.de\/blog\/","name":"Martin Heinzerling","description":"Blog eines kletternden Softwareingenieurs.","publisher":{"@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mheinzerling.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":["Person","Organization"],"@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/ac08e839cadad32f74e8c1fef0847ca0","name":"Martin Heinzerling","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dc45ec076193eff1627b201e54b32bdb46a6ae7331cb3449173e25986f85bd40?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc45ec076193eff1627b201e54b32bdb46a6ae7331cb3449173e25986f85bd40?s=96&d=identicon&r=g","caption":"Martin Heinzerling"},"logo":{"@id":"https:\/\/mheinzerling.de\/blog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/mheinzerling.de"],"url":"https:\/\/mheinzerling.de\/blog\/author\/mnhg\/"}]}},"_links":{"self":[{"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":7,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mheinzerling.de\/blog\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}