Praxis is the process by which a theory, lesson, or skill is enacted, practiced, embodied and realized.
The best people in any field are those who devote the most hours to what the researchers call “deliberate practice”. It’s activity that’s explicitly intended to improve performance, that reaches for objectives just beyond one’s level of competence, provides feedback on results and involves high levels of repetition and reflection.
– Geoffrey Colvin
Kata (方 literally: form) is a Japanese word describing a way of doing something or a pattern of behaviour that is practiced to various levels of mastery.
A Code Kata is an exercise in programming which helps hone your skills through practice and repetition.
Overlearning the basics allows our students to excel at the more difficult tasks.
Ruby is a dynamically-typed scripting language similar to Perl, PHP, or Python.
Try reading the following Ruby code out loud:
4.times { puts "Chunky Bacon!" }
The Ruby challenges must enable students need to master:
Coding Challenges are mini "assignments" that must be completed during class time.
Challenge Guidelines:
The first Ruby coding challenge might look something like this:
Create a program that prints your initials to the console using nine rows of asterisks.
** *** * ******* ** *** *** ********* ** *** ** ** ** ** ** *** ** ** ** ***** ********* ** *** ** *** *********** ** ***** ** *** ** ** ** ** ** *** ** ** ********** ** *** * * ********
Simple, but ensures that students can run code and print strings.
carl = { :start => 'We are a way', :middle => ' for the cosmos ', :punctuation => [ ',', '.', '?' ] } sagan = [ "to ", "know ", "itself" ]
Use the provided Hash and Array to print out:
“We are a way for the cosmos to know itself.”
Solution:
sentence = carl[:start] + carl[:middle] sentence += sagan[0] + sagan[1] + sagan[2] sentence += carl[:punctuation][1] puts sentence
Generate an array that contains 20 random numbers.
Once the array is built, iterate through its elements printing out the value of twice each number.
Solution:
random_numbers = Array.new 20.times { random_numbers << rand(100) } random_numbers.each { |num| puts 2 * num }
Start by coding a program that print every number from 1 to 100 to seperate lines in the console.
Next, modify your code so that:
See: Fizz Buzz Posters
Solution:
1.upto(100) do |n| print "Wowza" if wowza = (n % 3).zero? print "Cowza" if cowza = (n % 5).zero? print n unless (wowza || cowza) puts end
There is a famous mathematical sequence of numbers called the Fibonacci sequence.
The beginning of the sequence goes like this:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144…
Starting with the first two numbers (zero and one) the rest of the sequence can be calculated:
Each number (after the first two) is calculated by summing the previous two numbers.
Solution:
# Recursive def fib(n) return n if (0..1).include? n fib(n-1) + fib(n-2) end # Iterative def fib(n) curr, succ = 0, 1 n.times do |i| curr, succ = succ, curr + succ end curr end
A Secret Code:
rwpeitg x. sdlc iwt gpqqxi-wdat paxrt lph qtvxccxcv id vti ktgn ixgts du hxiixcv qn wtg hxhitg dc iwt qpcz, pcs du wpkxcv cdiwxcv id sd: dcrt dg ilxrt hwt wps ettets xcid iwt qddz wtg hxhitg lph gtpsxcv, qji xi wps cd exrijgth dg rdcktghpixdch xc xi, 'pcs lwpi xh iwt jht du p qddz,' iwdjvwi paxrt 'lxiwdji exrijgth dg rdcktghpixdc?' hd hwt lph rdchxstgxcv xc wtg dlc bxcs (ph ltaa ph hwt rdjas, udg iwt wdi spn bpst wtg utta ktgn hatten pcs hijexs), lwtiwtg iwt eatphjgt du bpzxcv p spxhn-rwpxc ldjas qt ldgiw iwt igdjqat du vtiixcv je pcs exrzxcv iwt spxhxth, lwtc hjsstcan p lwxit gpqqxi lxiw excz tnth gpc radht qn wtg.
Write a program that can automatically decode "encrypted" files, where every character has been shifted by a set number of alphabet positions.
Terse Obfuscated Solution (Assumptions):
s = IO.read('cipher.txt') shift = ('e'.ord - ('a'..'z').reduce(['',0]) do |m, l| s.count(l) > m[1] ? [l, s.count(l)] : m end[0].ord) % 26 puts s.tr('a-z', (('a'..'z').to_a*2)[shift...shift+26].join)
Full cipher file here.
As instructors we should be practicing what we teach on a regular basis.
An easy way to practice programming is to live code during lectures. Your students will want to code along which means super engagement.
YOU WILL MAKE MISTAKES.
THIS IS AWESOME FOR TEACHING DEBUGGING!
If you do any coding outside of work, share your successes with your students.
For example: You could maintain a Github Repo.
Oodles of coding challenge examples: