コード例 #1
0
def palindromeprime(N, M):
    if N > M:
        quit()
    elif palindrome(str(N)):
        if prime(int(N), int(N - 1)) > 0:
            print(N)
            return palindromeprime(N + 1, M)
        else:
            return palindromeprime(N + 1, M)
    else:
        return palindromeprime(N + 1, M)
コード例 #2
0
def palindrome_case(x):
    assert palindrome("racecar") == 1
    assert palindrome("") == 1
    assert palindrome("hello") == 0
    assert palindrome("mom") == 1
    assert palindrome("a") == 1
    assert palindrome("h a h a") == 0
コード例 #3
0
 def test_correct_output(self):
     self.assertEqual(palindrome("racecar"), True)
     self.assertEqual(palindrome("tacocat"), True)
     self.assertEqual(palindrome("level"), True)
     self.assertEqual(palindrome("banana"), False)
コード例 #4
0
 def setup(self):
     self.palindrome = palindrome()
コード例 #5
0
 def test_empty(self):
     self.assertTrue (palindrome (""))
コード例 #6
0
def test_five():
    assert palindrome(42) == -1
コード例 #7
0
def test_seven():
    assert palindrome(False) == -1
コード例 #8
0
 def test_two_letters(self):
     self.assertTrue (palindrome ("vv"))
コード例 #9
0
def test_three():
    assert palindrome("level") == True
コード例 #10
0
 def test_not(self):
     self.assertFalse (palindrome (remove_spaces ("i'm not a palindrome")))
コード例 #11
0
 def test_hard_1(self):
     s = "abacabadabacaba"
     self.assertEqual(palindrome(s), "abacabadabacaba")
コード例 #12
0
 def test_rat(self):
     self.assertTrue (palindrome (remove_spaces ("Was It a Rat I saW")))
コード例 #13
0
 def test_rat_diff_case(self):
     self.assertFalse (palindrome (remove_spaces ("was It a Rat I saW")))
コード例 #14
0
 def test_odd_even(self):
     self.assertTrue (palindrome (remove_spaces ("never odd or even")))
コード例 #15
0
 def test_toyota_with_spaces(self):
     self.assertTrue (palindrome (remove_spaces ("a toyota")))
コード例 #16
0
 def test_toyota(self):
     self.assertTrue (palindrome ("atoyota"))
コード例 #17
0
 def test_type_handling(self):
     self.assertEqual(palindrome(42), -1)
     self.assertEqual(palindrome(26.4), -1)
     self.assertEqual(palindrome(False), -1)
コード例 #18
0
def test_one():
    assert palindrome("racecar") == True
コード例 #19
0
 def test_special_characters_palindrome(self):
     self.assertTrue (palindrome (remove_spaces ("! 9 & 9 !")))
コード例 #20
0
 def test_one_letter(self):
     self.assertTrue (palindrome ("v"))
コード例 #21
0
 def test_hard_2(self):
     s = "abacabazzzzzzz"
     self.assertEqual(palindrome(s), "abacaba")
コード例 #22
0
 def test_special_characters_no_palindrome(self):
     self.assertFalse (palindrome (remove_spaces ("! 9 & 8 !")))
コード例 #23
0
def test_two():
    assert palindrome("tacocat") == True
コード例 #24
0
 def test_raise_typerror_float(self):
     self.assertRaises (TypeError, lambda: palindrome (1.0))
コード例 #25
0
def test_four():
    assert palindrome("banana") == False
コード例 #26
0
 def test_raise_typerror_list(self):
     self.assertRaises (TypeError, lambda: palindrome ([1,2,3]))
コード例 #27
0
def test_six():
    assert palindrome(26.4) == -1
コード例 #28
0
def test_palindrome():
    expected_result = bool(input('What is the expected_result[1 or 0]: '))
    assert (palindrome() == expected_result)
コード例 #29
0
 def test_palindrome(self):
     expected_result = bool(input('What is the expected_result[1 or 0]: '))
     self.assertEqual(palindrome(), expected_result)
コード例 #30
0
        try_except_demo()
    elif choice == 0 or choice == 13:
        print("========read file Example========")
        write_file_demo()
        read_file_demo()
        append_file_demo()
        read_file_demo()
    elif choice == 0 or choice == 14:
        print("========Class Example========")
        class_demo()
    elif choice == 0 or choice == 15:
        print("========String format Example========")
        string_format_demo()
    elif choice == 0 or choice == 16:
        print("======== rock paper scissor Example========")
        play_game()
    elif choice == 0 or choice == 17:
        print("========generate Password Example========")
        print(gen_password(8))
    elif choice == 0 or choice == 18:
        print("========guessing Example========")
        guessing_game()
    elif choice == 0 or choice == 19:
        print("========palindrome Example========")
        palindrome()
    elif choice == 0 or choice == 20:
        print("========tic tac toe========")
        play_tic_tac_toe()
    else:
        print("Exiting...!!")
コード例 #31
0
ファイル: main.py プロジェクト: Marwacoding/test_algo_ci
from reverse_digit import *
from reverse_number import *
from reverse_string import *
from number_of_word import *
from palindrome import *

reverse_digit(56)
reverse_num(5)
reverse_str('hello')
a_word('hello you')
palindrome("ressasser")
コード例 #32
0
 def test_none(self):
     self.assertFalse (palindrome (None))