Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

primeiros

  • Loading branch information...
commit ab7bc8689ea82fe0fafc4dd543dbce6c1ffd3a5a 0 parents
@giggio giggio authored
47 2012/20120913 - sms - ruby/Sms.rb
@@ -0,0 +1,47 @@
+class Sms
+ def write(text)
+ i = 0
+ digitos = ""
+ ultimo = ""
+ while i != text.length do
+ letter = text[i]
+ if i != 0
+ if "ABC".index(letter) != nil and "ABC".index(ultimo) != nil
+ digitos += "_"
+ end
+ end
+ case letter
+ when "A"
+ digitos += "2"
+ when "B"
+ digitos += "22"
+ when "C"
+ digitos += "222"
+ when "D"
+ digitos += "3"
+ when "E"
+ digitos += "33"
+ when "F"
+ digitos += "333"
+ when "P"
+ digitos += "7"
+ when "R"
+ digitos += "777"
+ when "O"
+ digitos += "666"
+ when "J"
+ digitos += "5"
+ when "S"
+ digitos += "7777"
+ when "M"
+ digitos += "6"
+ when "L"
+ digitos += "555"
+
+ end
+ ultimo = letter
+ i += 1
+ end
+ digitos
+ end
+end
33 2012/20120913 - sms - ruby/specs/sms_spec.rb
@@ -0,0 +1,33 @@
+require_relative '../Sms'
+describe Sms do
+ it "writes A" do
+ subject.write('A').should=='2'
+ end
+ it "writes B" do
+ subject.write('B').should=='22'
+ end
+ it "writes C" do
+ subject.write('C').should=='222'
+ end
+ it "writes D" do
+ subject.write('D').should=='3'
+ end
+ it "writes AD" do
+ subject.write('AD').should=='23'
+ end
+ it "writes AA" do
+ subject.write('AA').should=='2_2'
+ end
+ it "writes AE" do
+ subject.write('AE').should=='233'
+ end
+ it "writes AB" do
+ subject.write('AB').should=='2_22'
+ end
+ it "writes DAB" do
+ subject.write('DAB').should=='32_22'
+ end
+ it "frase" do
+ subject.write('SEMPRE ACESSO O DOJOPUZZLES').should == '77773367_7773302_222337777_777766606660366656667889999_9999555337777'
+ end
+end
2  2012/20120925 - sudoku - boo/build
@@ -0,0 +1,2 @@
+#!/bin/bash
+booc -o:sudoku.dll -t:library sudoku.boo -r:nunit.framework.dll
83 2012/20120925 - sudoku - boo/sudoku.boo
@@ -0,0 +1,83 @@
+
+import System.Drawing
+[NUnit.Framework.TestFixture]
+class TestesSudoku:
+ [NUnit.Framework.Test]
+ def GridVazioPermiteQualquerNumero():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1,Point(0,0))
+ NUnit.Framework.Assert.AreEqual(1, tabuleiro.Grid()[0, 0])
+ [NUnit.Framework.Test]
+ def GridVazioRecebeNumeroNaPosicao55():
+ tabuleiro = Tabuleiro()
+ num = 3
+ tabuleiro.Entra(num, Point(5,5))
+ NUnit.Framework.Assert.AreEqual(num, tabuleiro.Grid()[5, 5])
+ [NUnit.Framework.Test]
+ [NUnit.Framework.ExpectedException()]
+ def TestaSeNumeroSeRepeteNaColuna():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1,Point(0,0))
+ tabuleiro.Entra(1,Point(1,0))
+ [NUnit.Framework.Test]
+ [NUnit.Framework.ExpectedException()]
+ def TestaSeNumeroSeRepeteNaLinha():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1, Point(0,0))
+ tabuleiro.Entra(1, Point(0,1))
+
+ [NUnit.Framework.Test]
+ def TestaSeNumeroSeRepeteEmQualquerLugarPermitido():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1, Point(5,5))
+ tabuleiro.Entra(1, Point(8,8))
+
+ [NUnit.Framework.Test]
+ def TestaSeNumeroSeRepeteEmQualquerLugarPermitidoDois():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1, Point(1,1))
+ tabuleiro.Entra(1, Point(5,5))
+
+ [NUnit.Framework.Test]
+ [NUnit.Framework.ExpectedException()]
+ def TestaSeNumeroSeRepeteNoQuadrante():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1, Point(1,1))
+ tabuleiro.Entra(1, Point(2,2))
+
+ [NUnit.Framework.Test]
+ [NUnit.Framework.ExpectedException()]
+ def TestaSeNumeroSeRepeteNoQuadranteDois():
+ tabuleiro = Tabuleiro()
+ tabuleiro.Entra(1, Point(4,4))
+ tabuleiro.Entra(1, Point(5,5))
+
+class Tabuleiro:
+ matriz = matrix(int, 9, 9)
+
+ def Entra(numero, posicao as Point):
+
+ # Testa linhas
+ for x in range(8):
+ if matriz[x,posicao.Y] == numero:
+ raise 'Linha repetida'
+
+ # Testa colunas
+ for y in range(8):
+ if matriz[posicao.X,y] == numero:
+ raise 'Coluna repetida'
+
+ for x in range(2):
+ for y in range(2):
+ if matriz[x,y] == numero:
+ raise 'Quadrante repetido'
+
+ for x in range(3,5):
+ for y in range(3,5):
+ if matriz[x,y] == numero:
+ raise 'Quadrante repetido'
+
+ matriz[posicao.X, posicao.Y] = numero
+
+ def Grid():
+ return matriz

0 comments on commit ab7bc86

Please sign in to comment.
Something went wrong with that request. Please try again.