Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2000 katas later @cylicon

2000 katas later @cylicon

Talk about what I learned after implementing 2000 thousand katas, deliberate practice and how to receive impersonal feedback

Javier Gamarra

December 17, 2016
Tweet

More Decks by Javier Gamarra

Other Decks in Programming

Transcript

  1. “the practise of kata without learning to apply them in

    live situations is useless” --Gichin Funakoshi
  2. def apply_discount(item) @count[item] += 1 if (details = DISCOUNT[item]) if

    @count[item] % details[:quantity] == 0 @total -= details[:discount] end end end PRICE = { 'A' => 50, 'B' => 30, 'C' => 20, 'D' => 15 } DISCOUNT = { 'A' => {:quantity => 3, :discount => 20 }, 'B' => { :quantity => 2, :discount => 15 } }
  3. def create_array(n): res=[] i=1 while i<=n: res+=[i] return res def

    create_array(n): res=[] i=1 while i<=n: res+=[i] i+= 1 return res Fix this infinite loop
  4. def playerRankUp(pts): if pts >= 100: return ("Win!") else: return

    False def playerRankUp(pts): return "Win!" if pts >=100 else False How do you write conditionals?
  5. function loop_size(node){ var nodes = []; while(nodes.indexOf(node) == -1) {

    nodes.push(node); node = node.getNext(); } return nodes.length - (nodes.indexOf(node)); }
  6. How many ways can you make the sum of a

    number? function sum(n, m = n) { if (n == 0) return 1; if (n < 0 || m == 0) return 0; let total = sum(n, m - 1) + sum(n - m, m); return total; }
  7. // solution based on Euler decomposition with pentagonal numbers function

    sum(num) { var p = new Array p[0] = 1 var j = 0 var k = 0 var s = 0 if (num<=0){return 0} for (var i = 1; i<num+1;i++) { j=1 k=1 s=0 while (j>0){ j = i-(3*k*k+k)/2 if (j>=0) {s -= Math.pow(-1,k)*p[j]} j = i-(3*k*k-k)/2 if (j>=0) {s -= Math.pow(-1,k)*p[j]} k = k+1 } p[i] = s } return p[num] }
  8. How many ways can you make the sum of a

    number? function sum(n, m = n) { if (n == 0) return 1; if (n < 0 || m == 0) return 0; let total = sum(n, m - 1) + sum(n - m, m); return total; }
  9. How many ways can you make the sum of a

    number? var memo = []; function sum(n, m = n) { if (n == 0) return 1; if (n < 0 || m == 0) return 0; if (memo[n] && memo[n][m]) return memo[n][m]; let total = sum(n, m - 1) + sum(n - m, m); if (!memo[n]) { memo[n] = []; } memo[n][m] = total; return total; }
  10. read someone else's code learn your favorite programming tools ask

    programming questions read about pioneers
  11. are you looking for a job? • HackerRank (hackerrank.com) •

    Codeeval (www.codeeval.com) • Kaggle (kaggle.com)
  12. do you want to have learn having fun? • Codewars

    (codewars.com) • Exercism (exercism.io) • Solveet (solveet.com) (ES) • 12 meses 12 katas (github.com/12meses12katas) (ES) • Codefight (codefights.com)
  13. do you want to play a videogame? • Checkio (checkio.org)

    • CodeCombat (codecombat.com) • Coding Game (codingame.com)
  14. some kata recommendations • Refactoring: Gilded Rose || Trip Service

    • Iterations: Lean Code (with facilitator) • You already know a lot: Calisthenics • You don’t want to be alone: Code Retreat • Architecture/Design: PacMan (any game kata) • Messy logic: Bowling, Poker Hands • Learn a language: Codewars
  15. references • Kata is more than Karate • Benefits of

    code katas • Life code katas • "Old" Code Katas (codekatas.org) • Solid Gear (youtube.com)