Skip to content

Instantly share code, notes, and snippets.

@KoStard
Created April 17, 2018 17:42
Show Gist options
  • Save KoStard/1397cd5d22c2f97043662d81066ffc90 to your computer and use it in GitHub Desktop.
Save KoStard/1397cd5d22c2f97043662d81066ffc90 to your computer and use it in GitHub Desktop.
Task 86 of UniLecs Telegram
function calculations(a, b){
if (a >= b*3) { // When a is so big, that a/3 don't fit into b, so we get one row of squares with width b
return b;
/*
* ###.
*/
}else if (a < b*3 && a > b*3/2) { // This is when a/3 is smaller than b, so it fit's into the b, but is bigger than b/2, so we still get one row with width a/3
return a/3;
/*
* ###
* ```
*/
}else if (a < b*3/2 && a >= b){ // This time a/3 is finally smaller than a/2, so we get L like structure with width b/2
return b/2;
/*
* #-.
* ##.
*/
}else{
return calculations(b, a); // If the a is smaller than b, then we reverse the variables and try again
}
}
function task86 (a, b){
console.log(calculations(a, b));
}
task86(210, 297); // 105
task86(250, 100); // 83.3333
task86(3,1); // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment