Simple Fun #27: Rectangle Rotation
Description:
Task
A rectangle with sides equal to even integers a and b is drawn on the Cartesian plane. Its center (the intersection point of its diagonals) coincides with the point (0, 0), but the sides of the rectangle are not parallel to the axes; instead, they are forming 45 degree
angles with the axes.
How many points with integer coordinates are located inside the given rectangle (including on its sides)?
Example
For a = 6 and b = 4
, the output should be 23
The following picture illustrates the example, and the 23 points are marked green.
Input/Output
[input]
integera
A positive
even
integer.Constraints:
2 ≤ a ≤ 10000
.[input]
integerb
A positive
even
integer.Constraints:
2 ≤ b ≤ 10000
.[output]
an integerThe number of inner points with integer coordinates.
Similar Kata:
Stats:
Created | Jan 24, 2017 |
Published | Jan 24, 2017 |
Warriors Trained | 28882 |
Total Skips | 10906 |
Total Code Submissions | 34509 |
Total Times Completed | 5379 |
JavaScript Completions | 861 |
PHP Completions | 171 |
CoffeeScript Completions | 20 |
C# Completions | 401 |
Python Completions | 1721 |
Ruby Completions | 126 |
Java Completions | 525 |
Haskell Completions | 125 |
C++ Completions | 647 |
C Completions | 394 |
Elixir Completions | 30 |
Go Completions | 123 |
Dart Completions | 60 |
Elm Completions | 11 |
Erlang Completions | 15 |
Factor Completions | 9 |
Forth Completions | 7 |
Clojure Completions | 25 |
Crystal Completions | 16 |
F# Completions | 21 |
Julia Completions | 29 |
NASM Completions | 13 |
Prolog Completions | 9 |
PureScript Completions | 8 |
R Completions | 48 |
Racket Completions | 18 |
CFML Completions | 7 |
Fortran Completions | 10 |
Groovy Completions | 13 |
Nim Completions | 12 |
Objective-C Completions | 12 |
Reason Completions | 4 |
Rust Completions | 154 |
TypeScript Completions | 146 |
Kotlin Completions | 90 |
Scala Completions | 55 |
Lua Completions | 51 |
Haxe Completions | 13 |
COBOL Completions | 8 |
Total Stars | 994 |
% of votes with a positive feedback rating | 92% of 852 |
Total "Very Satisfied" Votes | 741 |
Total "Somewhat Satisfied" Votes | 88 |
Total "Not Satisfied" Votes | 23 |
Total Rank Assessments | 7 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 6 kyu |