6 kyu

The Walker

325 of 1,145g964

Description:

alternative text

The walker

The walker starts from point O, walks along OA, AB and BC. When he is in C (C will be in the upper half-plane), what is the distance CO? What is the angle tOC in positive degrees, minutes, seconds?

Angle tOA is alpha (here 45 degrees), angle hAB is beta (here 30 degrees), angle uBC is gamma(here 60 degrees).

Task

function solve(a, b, c, alpha, beta, gamma) with parameters

  • a, b, c: positive integers in units of distance (stand for OA, AB, BC)
  • alpha, beta, gamma: positive integers in degrees (positive angles are anticlockwise)

returns an array:

  • first element: distance CO (rounded to the nearest integer)
  • then angle tOC with the third following elements:
  • second element of the array: number of degrees in angle tOC (truncated positive integer)
  • third element of the array: number of minutes in angle tOC (truncated positive integer)
  • fourth element of the array: number of seconds in angle tOC (truncated positive integer)

Example:

print(solve(12, 20, 18, 45, 30, 60)) -> [15, 135, 49, 18]
- CO is 14.661... rounded to 15
- angle tOC is 135.821...
so
- degrees = 135
- minutes = 49.308...
- seconds = 18.518...

hence [15, 135, 49, 18]

Note

If you need the constant pi you can use pi = 3.14159265358979323846

Fundamentals
Geometry

More By Author:

Check out these other kata created by g964

Stats:

CreatedJul 7, 2018
PublishedJul 7, 2018
Warriors Trained7248
Total Skips901
Total Code Submissions4826
Total Times Completed1145
Python Completions325
JavaScript Completions160
Java Completions117
Ruby Completions22
C# Completions89
C Completions74
C++ Completions109
Clojure Completions7
R Completions17
F# Completions10
PHP Completions16
Kotlin Completions26
Groovy Completions8
CoffeeScript Completions8
Lua Completions37
Go Completions36
Rust Completions47
Nim Completions5
Crystal Completions4
Swift Completions25
Elixir Completions8
Scala Completions22
Fortran Completions7
Julia Completions10
PowerShell Completions12
OCaml Completions11
Haskell Completions16
Reason Completions5
Racket Completions6
TypeScript Completions31
VB Completions12
Haxe Completions3
Dart Completions23
Pascal Completions4
Perl Completions5
Raku Completions3
Elm Completions5
D Completions6
Erlang Completions4
Prolog Completions6
Total Stars183
% of votes with a positive feedback rating86% of 229
Total "Very Satisfied" Votes180
Total "Somewhat Satisfied" Votes35
Total "Not Satisfied" Votes14
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • g964 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • Blind4Basics Avatar
  • monadius Avatar
  • hobovsky Avatar
  • user8436785 Avatar
  • Just4FunCoder Avatar
Ad