Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize conditionals #201

Merged
merged 5 commits into from
Dec 8, 2016
Merged

Randomize conditionals #201

merged 5 commits into from
Dec 8, 2016

Conversation

moratorium08
Copy link
Contributor

通りました。レビューお願いします

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 92.084% when pulling 75ceeb4 on randomize-conditionals into cecca6f on master.

Copy link
Member

@hakatashi hakatashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

みました


conditional2-calc = (x) ->
if x is 5
then 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

インデントすればthenは不要なのでそうしてください

@@ -51,6 +54,16 @@ sum-of-digits = (n) -> n.to-string!split '' .map (parse-int _, 10) .reduce (+)
fibonacci-calc = (n, value = 1, prev = 0) ->
if n is 0 then prev else fibonacci-calc n - 1, value + prev, value

conditional1-calc = (x) ->
if (x % 2) is 0 then 2 * x else 3 * x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

括弧いらない気がする
(LiveScriptではなるべく括弧を殺していきたい)

expect io .to.satisfy io-spec

expect zip io.input, io.output .to.all.satisfy ([input, output]) ->
output is conditional1-calc input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputが200未満になる旨のテストもあったほうがよさそう

output: [10, 18, null, null],
ioGenerator: (random) => {
const generateAnswer = (input) => {
if (input === 5) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputが5か6のテストケースはすでに(固定で)あるので、5か6がランダムに生成されても嘘解法が通りやすくなるだけな気がするけど、どうだろう⋯⋯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ、めんどくさくてやってなかっただけなので、普通にやります

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 92.051% when pulling 74f59c4 on randomize-conditionals into cecca6f on master.

@moratorium08
Copy link
Contributor Author

各種、終わりました。レビューお願いします

}
return number + offset;
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

うーん、やりたいことは何となくわかるけど、ちょっと複雑になりすぎな感じがある。ここまで一般的なアルゴリズムを書かなくても、今回の場合は1から200までの数値を含む配列から5と6を除いたものから2個乱択する処理を書けば十分だと思う。

こんな感じ。

const candidates = Array.from({length: 200}, (item, index) => index + 1).filter(n => n !== 5 && n !== 6);

const input1 = candidates[Math.floor(random() * candidates.length)];
const input2 = candidates[Math.floor(random() * candidates.length)];

あと、5や6が生まれなくなるのでgenerateAnswer関数もいらないと思う。

Copy link
Contributor Author

@moratorium08 moratorium08 Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> 2個乱択する処理を書けば十分
わかりました・・・

> 5や6が生まれなくなるのでgenerateAnswer関数
たしかにそうですね・・・

@hakatashi hakatashi requested review from hakatashi and removed request for hakatashi December 8, 2016 08:58
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 92.287% when pulling 16d7616 on randomize-conditionals into cecca6f on master.

Copy link
Member

@hakatashi hakatashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OKです! お疲れさま! 引き続きデプロイお願いします。

@moratorium08
Copy link
Contributor Author

マージします

@moratorium08 moratorium08 merged commit c965524 into master Dec 8, 2016
@moratorium08 moratorium08 deleted the randomize-conditionals branch December 8, 2016 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants