# caesar cipher shifted of 13 characters with maketrans for python 2.7
from string import maketrans
import string
def caesar(s):
print(s)
s=s.translate(maketrans(string.ascii_uppercase, string.ascii_uppercase[13:]+string.ascii_uppercase[:13]))
return s
test.assert_equals(caesar("Replace examples and use TDD development".upper()), "ERCYNPR RKNZCYRF NAQ HFR GQQ QRIRYBCZRAG")
import math
def is_prime(n):
if n % 2 == 0 and n > 2:
return False
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
test.expect(is_prime(7) == True)
test.expect(is_prime(17) == True)
test.expect(is_prime(15) == False)
test.expect(is_prime(21) == False)
[Please, leave a feedback when you complete it or this will always stay in beta and you will not earn language points].
Print all numbers up to 3rd
parameter which are multiple of both 1st
and 2nd
paramater.
#!/bin/bash
for i in $(eval echo {1..$3});
do
if [ `expr $i % $1` -eq 0 -a `expr $i % $2` -eq 0 ]
then
echo $i
fi
done
output = run_shell args: [3,4,120]
describe "Solution" do
it "should return proper results for 3,4,120" do
expect(output).to include("12\r\n24\r\n36\r\n48\r\n60\r\n72\r\n84\r\n96\r\n108\r\n120")
end
end
output2 = run_shell args: [2,7,85]
describe "Solution" do
it "should return proper results for 2,7,85" do
expect(output2).to include("14\r\n28\r\n42\r\n56\r\n70\r\n84")
end
end
output3 = run_shell args: [14,15,185]
describe "Solution" do
it "should return proper results for 14,15,185" do
expect(output3).to include("")
end
end
output4 = run_shell args: [14,17,480]
describe "Solution" do
it "should return proper results for 14,17,480" do
expect(output4).to include("238\r\n476")
end
end
output5 = run_shell args: [2,5,90]
describe "Solution" do
it "should return proper results for 2,5,90" do
expect(output5).to include("10\r\n20\r\n30\r\n40\r\n50\r\n60\r\n70\r\n80\r\n90")
end
end
output6 = run_shell args: [4,7,97]
describe "Solution" do
it "should return proper results for 4,7,97" do
expect(output6).to include("28\r\n56\r\n84")
end
end