- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想使用我熟悉的开发环境离线执行 Codewars Python 套路。然而,所提供的测试使用与 Python 的 Unittest 完全不同的语法。我在任何地方都找不到测试框架的源代码。
我试过 codewars-client npm 包 ( https://github.com/shime/codewars ) 但它让我很困惑。我还查看了 codewars-cli runner,但它看起来更难理解,并且涉及 Docker。
这很令人沮丧,因为我真的只想练习一些基本的编码,但我最终不得不尝试理解 json 和依赖项以及包管理,只是为了启动和运行基本的 TDD 环境。
任何人都可以建议如何简单地在本地使用 python katas 中提供的测试吗?示例如下:
test.describe("Basic tests")
test.it("A resistor under 1000 ohms and with only three bands")
test.assert_equals(decode_resistor_colors("yellow violet black"), "47 ohms, 20%")
test.it("A resistor between 1000 and 999999 ohms, with a gold fourth band")
test.assert_equals(decode_resistor_colors("yellow violet red gold"), "4.7k ohms, 5%")
test.it("A resistor of 1000000 ohms or above, with a silver fourth band")
test.assert_equals(decode_resistor_colors("brown black green silver"), "1M ohms, 10%")
最佳答案
我只是将测试用例转换为代码中的打印语句,然后注释掉其余部分。然后直观地比较答案。
见下文:
# test.describe("Basic tests")
# test.it("A resistor under 1000 ohms and with only three bands")
print(decode_resistor_colors("yellow violet black")) # "47 ohms, 20%"
# test.it("A resistor between 1000 and 999999 ohms, with a gold fourth band")
print(decode_resistor_colors("yellow violet red gold")) # "4.7k ohms, 5%"
# test.it("A resistor of 1000000 ohms or above, with a silver fourth band")
print(decode_resistor_colors("brown black green silver")) # "1M ohms, 10%"
关于python - Codewars Python TDD 离线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40996317/
我大约 2 周前才开始学习编码,遇到了以下问题。我最初将代码编写为双嵌套循环,但不出所料地超时了。我重新编译了我的代码,以便(我认为)具有 O(n) 的渐近运行时间而不是 O(n^2)。我正在寻找使我
问题如下:超市的自助收银台前排起了长队。您的任务是编写一个函数来计算所有客户结帐所需的总时间! 输入:客户:代表队列的正整数数组。每个整数代表一个客户,其值是他们结账所需的时间。n:正整数,收银台数量
我正在尝试解决 codewars 上的 6kyu 问题,并且偶然发现了一个恼人的错误,但我无法找到其根源。任务的快速解释:“给定两个数组 a 和 b 编写一个函数 comp(a, b) 来检查这两个数
所以我决定去 codewars 温习一下 java,我有这个问题需要解决: 给你一个包含整数的数组(长度至少为 3,但可能非常大)。该数组要么完全由奇数整数组成,要么完全由除单个整数 N 之外的偶数整
这个问题已经有答案了: Regex for password must contain at least eight characters, at least one number and both
CodeWars 问题: Create a function named divisors that takes an integer and returns anarray with all of
我被困在 Codewars Kata 中,我希望有人能帮助我(不要破坏解决方案)。事实上,问题是我没有完全理解它应该如何工作,我明白了练习的想法,但事情有点困惑,尤其是在示例测试中。 以下是说明: T
我被下面的任务卡住了,花了大约 3 个小时才弄明白。 任务描述:一个人有一辆值(value) 2000 美元的旧车。他看到一辆值(value) 8000 美元的二手车。他想保留他的旧车,直到他能买到二
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
接下来的挑战是: At a job interview, you are challenged to write an algorithm to check if a given string, s,
问题来了: 新的《复仇者联盟》电影刚刚上映!电影院售票处人山人海,排起了长队。他们每个人都有一张 100、50 或 25 美元的钞票。 “复仇者联盟”门票 25 美元。 Vasya 目前是一名文员。他
问题是: "My friend John and I are members of the "Fat to Fit Club (FFC)". Johnis worried because each m
关闭。这个问题需要details or clarity .它目前不接受答案。 想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题. 去年关闭。 Improve this
希望每个人都有美好的一天。 这是我在 Stackoverflow 上发表的第一篇文章! 我刚刚完成了 Codeacademy 上的 javascript 类(class),并且也阅读了几本相关书籍。现
This Codewars Challenge要求您 Choose exactly one element from the sequence and replace it with another
我正在解决以下代码 war 问题。问题如下所示: Instructions Write a function capitals that takes a single string (word) as
谁能找出这段代码有什么问题吗?我在 CodeWars 上运行代码并通过了除一个之外的所有测试...遗憾的是它没有显示该特定测试的输入内容,因此很难弄清楚。 以下是挑战说明: 新的《复仇者联盟》电影刚刚
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 6 年前。 Improve this ques
尝试解决this codewars challenge : Your job is to fix the parentheses so that all opening and closing par
简介 问题在 Link to challenge for best instructions 上有解释 据我所知,如果左侧的元素大于0。 即[2, -4, 6, -6] => [-6, -4, 6,
我是一名优秀的程序员,十分优秀!