Skip to content

Instantly share code, notes, and snippets.

@alvaro-cuesta
Created February 6, 2013 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvaro-cuesta/4722062 to your computer and use it in GitHub Desktop.
Save alvaro-cuesta/4722062 to your computer and use it in GitHub Desktop.
Plugin Nerdobot para la kata #1 de MV Coders on Fire II: http://www.mediavida.com/foro/9/coding-katas-mv-coders-on-fire-ii-470850/2#2
module.exports = ->
@addCommand 'kata_rectangle_Code07_mamon',
args: '<texto>'
description: 'Imprime <texto> como un rectángulo. Dedicado al mamón de Code07.'
({nick}, text, to) =>
to ?= nick
n = text.length/4
if n % 2
@say to, 'El texto debe tener una longitud par'
return
l = Math.ceil n+1
s = ~~n-1
whitespace = Array(l-1).join ' '
u = l+s
v = 2*l + s
a = text[...l]
b = text[l...u]
c = text[u...v].split('').reverse().join ''
d = text[v..]
@say to, a
@say to, d[s-i] + whitespace + b[i-1] for i in [1..s]
@say to, c
name: 'Kata Rectangle'
description: "Code07 mamón!"
version: '0.1'
authors: ['kaoD']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment