text: (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1869],{2919:function(e,t,n){"use strict";n.d(t,{Z:function(){return y}});var r=n(5893),i=n(6156),o=(n(7294),n(2465)),l=n(9163);function a(){var e=(0,o.Z)(["\n  display: table-cell;\n"]);return a=function(){return e},e}function s(){var e=(0,o.Z)(["\n  display: table-cell;\n  text-align: right;\n  padding-right: 1em;\n  user-select: none;\n  opacity: 0.5;\n"]);return s=function(){return e},e}function c(){var e=(0,o.Z)(["\n  display: table-row;\n"]);return c=function(){return e},e}function u(){var e=(0,o.Z)(["\n  text-align: left;\n  margin: 1em 0;\n  padding: 0.5em;\n  overflow: scroll;\n\n  & .token-line {\n    line-height: 1.3em;\n    height: 1.3em;\n  }\n"]);return u=function(){return e},e}function f(){var e=(0,o.Z)(["\n  font-family: sans-serif;\n  text-align: center;\n"]);return f=function(){return e},e}var p=l.ZP.div(f()),d=l.ZP.pre(u()),m=l.ZP.div(c()),h=l.ZP.span(s()),j=l.ZP.span(a()),g=n(9235),v=n(5424);function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){(0,i.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var y=function(e){var t=e.children,n=e.language,i=void 0===n?"javascript":n;return(0,r.jsx)(p,{children:(0,r.jsx)(g.ZP,x(x({},g.lG),{},{theme:v.Z,code:t.trim(),language:i,children:function(e){var t=e.className,n=e.style,i=e.tokens,o=e.getLineProps,l=e.getTokenProps;return(0,r.jsx)(d,{className:t,style:n,children:i.map((function(e,t){return(0,r.jsxs)(m,x(x({},o({line:e,key:t})),{},{children:[(0,r.jsx)(h,{children:t+1}),(0,r.jsx)(j,{children:e.map((function(e,t){return(0,r.jsx)("span",x({},l({token:e,key:t})),t)}))})]}),t)}))})}}))})}},7610:function(e,t,n){"use strict";n.d(t,{F:function(){return l}});var r=n(5893),i=n(5988),o=n(1664),l=function(e){var t=e.meta,n=e.link,l=e.isBlogPost;return(0,r.jsxs)(r.Fragment,{children:[l?(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:t.title}):(0,r.jsx)(o.default,{href:n,children:(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:t.title})}),(0,r.jsxs)("div",{className:"jsx-4001257583 details",children:[l?null:(0,r.jsx)("p",{className:"jsx-4001257583",children:t.description}),(0,r.jsx)("span",{className:"jsx-4001257583",children:t.date}),(0,r.jsxs)("span",{role:"img","aria-label":"one coffee",className:"jsx-4001257583",children:["\u2615 ",t.readTime+" mins read"]})]}),(0,r.jsx)(i.default,{id:"4001257583",children:["h1.jsx-4001257583{font-size:1.5rem;font-weight:700;color:#f39c12;}",".great-title.jsx-4001257583{font-size:2rem;}",".details.jsx-4001257583 span.jsx-4001257583{color:#bdbdbd;margin-right:1rem;}",".details.jsx-4001257583{margin-bottom:1rem;}"]})]})}},2477:function(e,t,n){"use strict";var r=n(5893),i=n(2465),o=n(9008),l=n(9163),a=n(9232),s=n(1930);function c(){var e=(0,i.Z)(["\n  display: flex;\n  flex-direction: row;\n"]);return c=function(){return e},e}var u=l.ZP.div(c());t.Z=function(e){var t=e.title;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.default,{children:[(0,r.jsx)("title",{children:t}),(0,r.jsx)("meta",{name:"viewport",content:"initial-scale=1.0, width=device-width"})]}),(0,r.jsxs)(u,{children:[(0,r.jsx)(s.Z,{}),(0,r.jsx)(a.Z,{})]})]})}},2052:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(5893),i=n(2465),o=n(7610),l=n(2477);function a(){var e=(0,i.Z)(["\n  margin: 0 35px;\n"]);return a=function(){return e},e}var s=n(9163).ZP.div(a());function c(e){var t=e.children,n=e.meta;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.Z,{title:n.title}),(0,r.jsxs)(s,{children:[(0,r.jsx)(o.F,{meta:n,isBlogPost:!0}),(0,r.jsx)("article",{children:t})]})]})}},9087:function(e,t,n){"use strict";var r=n(6156),i=n(5893),o=n(2105);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}t.Z=function(e){var t=e.label,n=e.url,r=e.name,l=e.anchor,s={};return n?s.href=n:l?s.href="#".concat((0,o.Md)(t)):r&&(s.name="".concat((0,o.Md)(t))),(0,i.jsx)("a",a(a({},s),{},{children:t}))}},1930:function(e,t,n){"use strict";var r=n(5893),i=n(2465),o=n(1664);function l(){var e=(0,i.Z)(["\n  width: 18%;\n"]);return l=function(){return e},e}var a=n(9163).ZP.div(l());t.Z=function(e){var t=e.type,n=void 0===t?"header-logo":t;return n?(0,r.jsx)(a,{children:(0,r.jsx)(o.default,{href:"/",className:"link",children:(0,r.jsx)("img",{src:"/images/webslate.jpg",alt:"Web Slate.io",className:n})})}):(0,r.jsx)(a,{children:(0,r.jsx)("img",{src:"images/webslate.jpg",alt:"Web Slate.io"})})}},9232:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(5893),i=n(2465),o=n(7294),l=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e?"/blogs/".concat(e):"/"},a=[{label:"Home",url:"/"},{label:"JavaScript",url:l("js")},{label:"HTML5",url:l("html")},{label:"React",url:l("react")},{label:"Programming",url:l("programming")},{label:"About",url:"/about"}];function s(){var e=(0,i.Z)(["\n  width: 82%;\n  margin-top: 35px;\n"]);return s=function(){return e},e}var c=n(9163).ZP.div(s());var u=function(e){var t=e.noStyle,n=void 0===t||t?c:o.Fragment;return(0,r.jsx)(n,{children:a.map((function(e,t){return(0,r.jsxs)("span",{children:[t>0&&" | ",(null===e||void 0===e?void 0:e.label)&&(0,r.jsx)("a",{href:null===e||void 0===e?void 0:e.url,children:null===e||void 0===e?void 0:e.label})]},null===e||void 0===e?void 0:e.label)}))})}},6992:function(e,t,n){"use strict";n.r(t),n.d(t,{meta:function(){return f},default:function(){return m}});var r=n(6156),i=n(7375),o=(n(7294),n(4137)),l=n(2052),a=n(2919),s=n(9087);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var f={title:"Frog Jump Solution",description:"Count minimal number of jumps from position X to Y.",date:"Jul 21, 2020",readTime:2},p={meta:f},d=function(e){var t=e.children;return(0,o.kt)(l.Z,{meta:f},t)};function m(e){var t=e.components,n=(0,i.Z)(e,["components"]);return(0,o.kt)(d,u(u(u({},p),n),{},{components:t,mdxType:"MDXLayout"}),(0,o.kt)("p",null,"A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.  "),(0,o.kt)("p",null,"Count the minimal number of jumps that the small frog must perform to reach its target.  "),(0,o.kt)("p",null,"Write a function:  "),(0,o.kt)(a.Z,{mdxType:"CodeBlock"},"\nfunction solution(X, Y, D) {\n  // write your code in JavaScript (Node.js 8.9.4)\n}\n"),(0,o.kt)("p",null,"that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.  "),(0,o.kt)("p",null,"For example, given:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"X = 10"),(0,o.kt)("li",{parentName:"ul"},"Y = 85"),(0,o.kt)("li",{parentName:"ul"},"D = 30")),(0,o.kt)("p",null,"the function should return 3, because the frog will be positioned as follows:  "),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"after the first jump, at position 10 + 30 = 40"),(0,o.kt)("li",{parentName:"ul"},"after the second jump, at position 10 + 30 + 30 = 70"),(0,o.kt)("li",{parentName:"ul"},"after the third jump, at position 10 + 30 + 30 + 30 = 100")),(0,o.kt)("p",null,"Write an efficient algorithm for the following assumptions:  "),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"X, Y and D are integers within the range ","[1..1,000,000,000]",";"),(0,o.kt)("li",{parentName:"ul"},"X \u2264 Y.")),(0,o.kt)(a.Z,{mdxType:"CodeBlock"},"\nfunction solution(x, y, d) {\n    // write your code in JavaScript (Node.js 8.9.4)\n    if ((y - x) % d === 0) {\n       return (y - x) / d;\n    }\n    return Math.ceil((y - x) / d);\n}\n"),(0,o.kt)("h2",null,(0,o.kt)(s.Z,{label:"Points to be Taken",name:!0,mdxType:"AnchorLink"})),(0,o.kt)("ol",null,(0,o.kt)("li",{parentName:"ol"},"Solution need division check with modulo operator whether its remainder is zero."),(0,o.kt)("li",{parentName:"ol"})))}m.isMDXComponent=!0},590:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/blogs/problems/simple-frog-jump",function(){return n(6992)}])}},function(e){e.O(0,[1329,2358,4638,9774,2888,179],(function(){return t=590,e(e.s=t);var t}));var t=e.O();_N_E=t}]);