Created
February 6, 2013 11:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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