Fundamentals
Strings
The shortest thing ever XD
This is why you don't do this
import codewars_test as test @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals("cba", 'cba')
- import codewars_test as test
from solution import s as reverse_string- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
test.assert_equals(reverse_string('abc'), 'cba')test.assert_equals(reverse_string('123'), '321')test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')- test.assert_equals("cba", 'cba')
Fundamentals
Strings
Even shorter XD
import codewars_test as test from solution import stre as reverse_string @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals(reverse_string('abc'), 'cba') test.assert_equals(reverse_string('123'), '321') test.assert_equals(reverse_string('a1b2c3'), '3c2b1a') test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH') test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
- import codewars_test as test
from solution import reverse_string- from solution import stre as reverse_string
- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
- test.assert_equals(reverse_string('abc'), 'cba')
- test.assert_equals(reverse_string('123'), '321')
- test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')
- test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')
- test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
Fundamentals
Strings
Previous thing, but lambda
Strings
Fundamentals
I turned it into a lambda function
(not much)
Hinata = lambda Naruto, equals, cool: eval("{} {} {}".format(Naruto, equals, cool))
eval(compile((_ := __import__("ast")).fix_missing_locations(_.Module(body=[_.Expr(value=_.Call(func=_.Attribute(value=_.Call(func=_.Name(id='globals', ctx=_.Load()), args=[], keywords=[]), attr='update', ctx=_.Load()), args=[_.Dict(keys=[_.Constant(value='calc')], values=[_.Lambda(args=_.arguments(posonlyargs=[], args=[_.arg(arg='_')], kwonlyargs=[], kw_defaults=[], defaults=[]), body=_.Call(func=_.Name(id='eval', ctx=_.Load()), args=[_.Name(id='_', ctx=_.Load())], keywords=[]))])], keywords=[]))], type_ignores=[])), "your mom LOL!", "exec"))- Hinata = lambda Naruto, equals, cool: eval("{} {} {}".format(Naruto, equals, cool))
from random import randint, choice import codewars_test as test # TODO Write tests from solution import Hinata as calc # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(1 + 1, 2) """@test.describe("Random") def test_group(): @test.it("random tests for +") def test_case(): for x in range(10): n1 = randint(-100, 100) n2 = randint(-100, 100) test.assert_equals(calc("+", n1, n2), n1+n2) @test.it("random tests for -") def test_case(): for x in range(10): n1 = randint(-100, 100) n2 = randint(-100, 100) test.assert_equals(calc("-", n1, n2), n1-n2) @test.it("random tests for *") def test_case(): for x in range(10): n1 = randint(-100, 100) n2 = randint(-100, 100) test.assert_equals(calc("*", n1, n2), n1*n2) @test.it("random tests for /") def test_case(): for x in range(10): n1 = randint(-100, 100) n2 = randint(-100, 100) test.assert_equals(calc("/", n1, n2), n1/n2) @test.it("random tests for invalid operators") def test_case(): for x in range(10): n1 = randint(-100, 100) n2 = randint(-100, 100) op = choice(["**", "%", "$", "//", "^"]) test.assert_equals(calc(op, n1, n2), None)"""
- from random import randint, choice
- import codewars_test as test
- # TODO Write tests
from solution import calc # or from solution import example- from solution import Hinata as calc # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(1 + 1, 2)
- """@test.describe("Random")
- def test_group():
- @test.it("random tests for +")
- def test_case():
- for x in range(10):
- n1 = randint(-100, 100)
- n2 = randint(-100, 100)
- test.assert_equals(calc("+", n1, n2), n1+n2)
- @test.it("random tests for -")
- def test_case():
- for x in range(10):
- n1 = randint(-100, 100)
- n2 = randint(-100, 100)
- test.assert_equals(calc("-", n1, n2), n1-n2)
- @test.it("random tests for *")
- def test_case():
- for x in range(10):
- n1 = randint(-100, 100)
- n2 = randint(-100, 100)
- test.assert_equals(calc("*", n1, n2), n1*n2)
- @test.it("random tests for /")
- def test_case():
- for x in range(10):
- n1 = randint(-100, 100)
- n2 = randint(-100, 100)
- test.assert_equals(calc("/", n1, n2), n1/n2)
- @test.it("random tests for invalid operators")
- def test_case():
- for x in range(10):
- n1 = randint(-100, 100)
- n2 = randint(-100, 100)
- op = choice(["**", "%", "$", "//", "^"])
- test.assert_equals(calc(op, n1, n2), None)"""