7 kyu
T.T.T.27: Four piles of apples
209 of 518myjinxin2015
Loading description...
Puzzles
Games
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
python new test framework is required. updated in this fork
Approved
The
"Should work for random positive tests"
block in Haskell generates random inputs like this:which means the error messages will show the
x, y
values instead ofn, y
making them very misleading.Hi!
I'm tring to solve your kata in Haskell.
I wonder, why
[840,826,5831,119]
isn't the solution for the pair(7616, 7)
?Can you help me please?
Thank you.
in the random tests? might just be because the random tests seem to be broken (see issue below)
Thanks for your fast answer :)
Yes in the random tests.
So, I cannot not fix it myself, can I :(?
nope, you'll have to wait for someone who can update them... Sorry.
Ok, but thank you for your answers!
I will wait then.
The random tests for Haskell seem to be broken.
duplicate issue, closing
This comment has been hidden.
Replaced wrong reference solution.
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
JS needs an update as well
Ruby 3.0 enabled in this fork
Weird test cases after submitting
Code in Haskell
Problem According to the code I've submitted,
[]
should be returned instead of[1,2,3,4]
[2125,1955,173400,24]
is way more thann=24
I raised an issue.
I really like this kata. I would like to suggest some edits to the instructions to make them more grammatical in English:
Problem
There are n apples that need to be divided into four piles. We need two mystery numbers x and y. Let the size of the first pile equal x+y, the size of the second pile equal x-y, the size of the third pile equal x*y, and the size of the fourth pile equal x/y. We need to calculate how many apples there are in each pile.
Of course, there won't be so many unknowns. We know the total number of apples (n) and the second mystery number (y).
For example: there are 48 apples that need to be divided into four piles. y=3. That is, the size of the 1st pile should be x+3, the size of the 2nd pile should be x-3, the size of the 3rd pile should be x*3, and the size of the 4th pile should be x/3. Do you know the value of x? x should be 9, because:
(9 + 3) + (9 - 3) + (9 * 3) + (9 / 3) = 12 + 6 + 27 + 3 = 48 So, 48 apples should be divided into 12, 6, 27, 3.
Task
Complete the function fourPiles()/four_piles() that accepts two arguments n and y, and returns an array containing the sizes of the four piles. Each element in the result array should be a positive integer. In cases where division is not possible, please return [].
Haskell signature should be
fourPiles :: Int -> Int -> [Int]
instead of:
fourPiles :: Int -> Int -> Int
Fixed.
Cheers
I'm seeing some problems with the Python translation (both 2 and 3) during the random testing phase.
For example:
But the given answer cannot be right as
[13, 3, 40, 1]
sums to57
not64
.I'm also seeing what appear to be valid solutions being rejected because the test is expecting a
[]
response too.It seems
@GiacomoSorbi
corrected this issue last week. Can you give it a try again?I can't see what I'm missing about this kata. I'm failing some random tests, but it looks like the random tests are wrong. E.g., for parameters (75, 5), the test says the expected output is [15, 5, 50, 2]. But those numbers sum to 72, not 75.
Ruby? @GiacomoSorbi
Yes, Ruby - sorry, I should've specified that.
Nice catch, I forgot to plan for an edge case (when the random solution is close to the good one): thanks!
@GiacomoSorbi Python ;-)
Awesome, thanks!
Ruby and Crystal translations kumited; I would also gladly do the Pythonic one, which now seems stuck because of another one with failing tests, but unless you reject it, there is little I can do in that regard :(
Approved. The another python translation was rejected, you can continue your work now ;-)
Done, cheers :)
Done, too ;-)
Please check your translation. An issue was posted.
PHP Translation Kumited - please accept :D
Approved. Thanks ;-)
There's a problem with the old Haskell translation. Please se the modified one.
@myjinxin2015
Approved. ;-)
Haskell translation added!
Sorry, I can't approve it, because there is no "approve" button. Are you sure that you've published it as a translation? ;-)
Well, my fault... Is that OK now?
Ok. Approved. Thanks ;-)
LOL
There is an issue with the Haskell version. I get the error:
expected: [603,-603,0,0] but got: []
but all except the first element are not positive integers.
Wait
@colbydauph, I catched you.
@ZozoFouchtra,waiting for me ;-)
Some points to help you;-)... Next week i've again more time for coding (and surely WLAN access works again too:-))...
next week you will see more than 10 katas from myjinxin2015 ;-)
YEAH! Turbo-myjinxin2015!!
This number is very conservative, I would like to say 20, but I am afraid that can not achieve the goal.
My ultimate goal is: 1000 katas, now has completed 1/5, close to 1/4 ;-)