6 kyu

Tank Truck

1,285 of 4,961g964

Description:

To introduce the problem think to my neighbor who drives a tanker truck. The level indicator is down and he is worried because he does not know if he will be able to make deliveries. We put the truck on a horizontal ground and measured the height of the liquid in the tank.

Fortunately the tank is a perfect cylinder and the vertical walls on each end are flat. The height of the remaining liquid is h, the diameter of the cylinder base is d, the total volume is vt (h, d, vt are positive or null integers). You can assume that h <= d.

Could you calculate the remaining volume of the liquid? Your function tankvol(h, d, vt) returns an integer which is the truncated result (e.g floor) of your float calculation.

Examples:

tankvol(40,120,3500) should return 1021 (calculation gives about: 1021.26992027)

tankvol(60,120,3500) should return 1750

tankvol(80,120,3500) should return 2478 (calculation gives about: 2478.73007973)

Tank vertical section:

alternative text

Mathematics
Geometry

Similar Kata:

More By Author:

Check out these other kata created by g964

Stats:

CreatedSep 12, 2015
PublishedSep 12, 2015
Warriors Trained25361
Total Skips7107
Total Code Submissions26250
Total Times Completed4961
Ruby Completions89
Python Completions1285
JavaScript Completions959
CoffeeScript Completions14
Haskell Completions68
C# Completions279
Java Completions536
Clojure Completions30
C++ Completions510
PHP Completions153
Crystal Completions8
F# Completions32
C Completions348
TypeScript Completions112
Rust Completions192
Swift Completions119
Go Completions100
R Completions56
Shell Completions21
OCaml Completions19
Kotlin Completions106
Fortran Completions24
Elixir Completions33
Julia Completions26
Scala Completions39
PowerShell Completions22
Nim Completions12
Reason Completions3
Racket Completions20
Forth Completions12
Lua Completions39
Pascal Completions11
Perl Completions11
Haxe Completions7
Elm Completions4
D Completions7
COBOL Completions3
Erlang Completions5
Prolog Completions9
Total Stars516
% of votes with a positive feedback rating83% of 863
Total "Very Satisfied" Votes629
Total "Somewhat Satisfied" Votes169
Total "Not Satisfied" Votes65
Ad
Contributors
  • g964 Avatar
  • myjinxin2015 Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad