6 kyu

Tank Truck

1,286 of 4,965g964
Description
Loading description...
Mathematics
Geometry
  • Please sign in or sign up to leave a comment.
  • 3au4onok Avatar

    This comment has been hidden.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Harekk Avatar

    Hello Sorry for my English, I'm writing through a translator. the solution algorithm seems to have understood, hopefully correctly. Find the area of the base of the cylinder -> find the area of the triangle AOB -> the area of the large triangle - AOB*2 -> subtract the area of the large triangle from the area of the circle and get the area of the segment with water -> the area of the volume is equal - multiply the area of the segment with water by the length of the cylinder (we find from the volume of the cylinder and the area of the base) - the answer is far from the result in the example. I have been working on this task for the second day. I can't understand, do I have the wrong algorithm or calculations?

  • trashy_incel Avatar

    suggested tag: geometry

  • trashy_incel Avatar
  • ilikechocolat Avatar

    I was struggling cuz I named my function tankvol lol. That one hyphen wasted so much time it isnt even funny.

  • adabaed Avatar

    I love @g964 katas 🥰

  • cuadchris Avatar

    I consider solving this kata a personal achievement. It took me a day and a half. Fun as hell, though. I wish I paid more attention in school.

  • Szymalsky Avatar

    Had so much fun with this kata, nice one.

  • v2kom Avatar

    In my solution I handle when h less than radius and h more than radius, but I don't handle when h=radius and still pass all the tests.. I mean I think the kata author might wanr to add testcases, maybe

  • Amel  Haracic Avatar

    Great kata! :)

  • galp76 Avatar

    Made me remember university days. Great kata.

  • echo1337 Avatar

    Hey, I need some help with the powershell version of this.

    I ran the tests on my function and it passes the tests, but when I click attempt I get the error below.I thought maybe it was an issue with how I truncated the return. But other than [math]::Truncate I just get seemingly an oppostite error like "Expected: {2940} But was: {2941}"

    Can someone take a look and give me a heads up if I caculated something wrong?

    Test Results:
    tank-vol
    Fixed Tests
    Should Pass Fixed Tests
    Expected: {3848}
    But was:  {3847}
    Stack Trace
    Completed in 667ms
    Completed in 667ms
    Random Tests
    Should pass Random Tests
    Completed in 579ms
    Completed in 1245ms 
    
    function tank-vol([int]$h, [int]$d, [int]$vt){
        $radius = $d/2
        $radSQD = $radius*$radius
        $length = ($vt/$radSQD)/[MATH]::PI
        $volume = $length*($radSQD*[MATH]::Acos(($radius-$h)/$radius)-(($radius-$h)*[MATH]::Sqrt(2*$radius*$h-$h*$h)))
    
        return [math]::Floor($volume)
    
  • The_Paradox Avatar

    Great Kata!!!

  • alwanadi17 Avatar

    This comment has been hidden.

  • ByteEater Avatar

    the diameter of the cylinder

    Diameter is defined as the supremum of distances over pairs of points of a set. So for a cylinder it's the distance between a point on the edge of one base and the farthest point on the other base. You probably had the diameter of the cylider's base in mind.

  • xakep71k Avatar

    This comment has been hidden.

  • QKiryu Avatar

    was it bad to use calculus for this question :|?

  • Triest Avatar

    I really liked this Kata! Had to freshen up my math theory a bit. But it was well worth it. :)

  • sk-rp-ta Avatar

    Is "vt" necessary?

  • ShadowRider Avatar

    Thanks for this kata!

  • icaro0104 Avatar

    do i need caulculus for this kata? i just can seem to find a way to solve this without integration, AM I DUMB????

  • user2289789 Avatar

    This comment has been hidden.

  • salihnacar Avatar

    can some tell me why my code gives very differnt output when the diameter is odd number ? (i did divide d by 2 and make it double but still doesnt work )

  • chrisstoneking Avatar

    This comment has been hidden.

  • HafintoN Avatar

    If I do the test without trunc for the input as shown in the details I get exactly the same result as shown for every decimal place but when I do the real test with truncated numbers, sometimes I got everything right except one which is off by 2 or I get every test off by aroud 2. I am pretty sure my math is correct (otherwise I doubt I would randomly get every decimal place right) but I can't pass the test for some reason. Any help?

  • dfhwze Avatar

    This comment has been hidden.

  • MikChan Avatar

    Illustration is gone

  • Rud1 Avatar

    Fun kata :)

  • TYZILLA Avatar

    can anyone tell me what formula to look up to solve this lol i am terrible at math

  • 2nd_rob Avatar

    This comment has been hidden.

  • Youngseok0001 Avatar

    I did not learn anything about programming language from this kata. It was more like a middle school math revision.

  • Tammy123 Avatar

    I enjoy it!!

  • Voile Avatar

    Forth: Shouldn't M-PI be given as a constant in initial code? That's the convention in every other Forth kata.

  • cfwal5134 Avatar

    Really good math problem, I very much enjoyed solving it :)

  • JohanWiltink Avatar

    I had a mathematically correct solution that failed one fixed test because of floating point representation inaccuracy.

    I know it's much too late for this kata, but please, kata authors, do not test floating point values for equality, do not round, truncate or otherwise assimilate them, please please please, compare with an error margin.

  • chrisgrazioli Avatar

    This comment has been hidden.

  • macnick Avatar

    This comment has been hidden.

  • bluworld Avatar

    float/double/int? The rounding error is killing me! :( always getting one-off!

  • th3oth3rjak3 Avatar

    Great kata! Use of slightly complex math and different data types makes you think!

  • metalim Avatar

    Go translation needs update. Gives "Caution: This kata does not currently have any known supported versions for Go. It may not be completable due to dependencies on out-dated libraries/language versions."

  • Phil157 Avatar

    Fortran 95 - Something is very odd. I couldn't re-create the answers I got with my submitted solution. I finally noticed that the supplied value of Pi was missing the 1st decimal place digit of "1" (so Pi = 3.4xxxxx)! This is true of all the submitted solutions (and remember how "1_ikind" had become "_ikind" - Pi is the same type).

  • Jomopipi Avatar

    This comment has been hidden.

  • gerber Avatar

    Those examples don't make any sense:

    "tankvol(40,120,3500) should return 1021"

    how the total volume can be 3500 when the diameter is 120? Thea area of the circle alone is PI*(60^2) which is about 11304, way above the total volume. Can somebody explain what did I get wrong?

  • Tblxnblx Avatar

    For some reason, I can't get it to output the exact needed value -- its always some other value in range of ~20 from the needed one. To be quite honest, I'm at a loss here.

  • lorinczpeter94 Avatar

    Hey, I have runned tests for the examples in the instructions and it's all right, but when I attempt, it expects totally different values?!?!?!

  • Vadimkatr Avatar

    why I can't solve this kata on golang??! sadly(

  • MoriRem Avatar

    i had an value difference that actually made this longer than it should have been by using 3.14159265358979323846264 as pi, but passed all tests when changed to only 3.14159

  • user4188001 Avatar

    Do I need to return the remaining air in the tank, or the liquid? Also, is the tank standing upright?

  • Dorteel Avatar

    This comment has been hidden.

  • Jomonsugi Avatar

    This comment has been hidden.

  • bkaes Avatar

    The C++ version is non-idiomatic. If you want to write a function in C++, write a function.

  • Igg_meister Avatar

    This comment has been hidden.

  • strawmelon Avatar

    This comment has been hidden.

  • BazichenkoKos Avatar

    Hi! i have problems with round the final number... it passes the tests, but when i submit - i always get near 5% of errors, the number is wrong with 1 point. I tried all ways to round i know in JS but always the same.

  • MikeG1t Avatar

    Ok, but might be wrong here. But, if we are talking anout volume, aint cylinder length not a factor. I've managed to factorise a number of variables in the formula to the 3 we are allowed. But when it comes to finally calulating the volume, we would need the length of the cyclinder.

    Since volume of a cylinder is = pi * r^2 * cylinder_length.

    Please advise.

  • user3012216 Avatar

    One significant problem I encountered was the terminology:

    "The height of the remaining liquid is h, ..."

    I was given the impression that this meant that h represented the height of the liquid that remained in the tank as opposed to the height of the empty space. I only discovered why i was having trouble with this Kata when I looked at the examples- as h increased, so did the remaining volume, contrary to my expectations. I would recommend changing the wordng to reflect this:

    "The height of the empty space in the cylinder is h, ..."

  • Insti Avatar

    The description is missing some words.

  • Insti Avatar

    This is a math problem, the kata tags should be updated to reflect this.

  • Unnamed Avatar

    This comment has been hidden.

  • Unnamed Avatar

    This comment has been hidden.