Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,191,542 members, 7,944,605 topics. Date: Monday, 09 September 2024 at 08:01 PM

Termacs2's Posts

Nairaland Forum / Termacs2's Profile / Termacs2's Posts

(1) (of 1 pages)

Programming / Re: Come And Solve This Coding Problem by termacs2: 5:13pm On Nov 13, 2023
turmacs:
sad

Wetin 😂😂
Programming / Re: Come And Solve This Coding Problem by termacs2: 11:03am On Nov 13, 2023
Javascript

1 function smallestPussyNumber(pussyNumber, to = 919) {
2 let smallestPNumber = pussyNumber;
3 for (let i = pussyNumber; i <= to; i++) {
4 if (isPussyNumber(i) === i && isPussyNumber(i) >= smallestPNumber) {
5 smallestPNumber = i;
6 break;
7 }
8 }
9
10 return smallestPNumber;
11 }

🤣 The problem is really tricky. the tricky part for me is that line 6. If you like no put that break statement e go dey return the maximum constraint i.e 919, you have to loop it once!(speaking for my logic only).

Here is the function I used, him work na to return back the number if it's pussy/vaginaNumber.

1 function isPussyNumber(numberValue) {
2 let isPussyNumber = numberValue;
3 if (typeof numberValue !== 'number') {
4 return 'Go And Sit Down!';
5 }
6
7 // Handle The Constraint Gently 🥰
8 const isThreeDigit = `${numberValue}`.length == 3;
9
10 if (!isThreeDigit) {
11 return 'Pussy Number is Three Digit Number Only!';
12 }
13
14 // we need some methods from string or array. Let me use string.
15 const stringifiedDigit = `${numberValue}`;
16
17 const lastDigit = +(stringifiedDigit.slice(stringifiedDigit.length - 1, stringifiedDigit.length));
18
19 const firstTwoDigit = +(stringifiedDigit.slice(0, 2));
20
21 const productOfFirstTwo = (+stringifiedDigit.slice(0, 1)) * (+stringifiedDigit.slice(1, 2));
22
23 if (productOfFirstTwo !== lastDigit) {
24 isPussyNumber = false;
25 }
26
27 return isPussyNumber;
28 }

29 console.log(smallestPussyNumber(516));



The whole code without number lines.
function smallestPussyNumber(pussyNumber, to = 919) {
let smallestPNumber = pussyNumber
for (let i = pussyNumber; i <= to; i++) {
if (isPussyNumber(i) === i && isPussyNumber(i) >= smallestPNumber) {
smallestPNumber = i
break
}
}

return smallestPNumber
}

function isPussyNumber(numberValue) {
let isPussyNumber = numberValue
if (typeof numberValue !== 'number') {
return 'Go And Sit Down!'
}

// Handle The Constraint Gently 🥰
const isThreeDigit = `${numberValue}`.length == 3

if (!isThreeDigit) {
return 'Pussy Number is Three Digit Number Only!'
}

// we need some methods from string or array. Let me use string.
const stringifiedDigit = `${numberValue}`

const lastDigit = +(stringifiedDigit.slice(stringifiedDigit.length - 1, stringifiedDigit.length))

const firstTwoDigit = +(stringifiedDigit.slice(0, 2))

const productOfFirstTwo = (+stringifiedDigit.slice(0, 1)) * (+stringifiedDigit.slice(1, 2))

if (productOfFirstTwo !== lastDigit) {
isPussyNumber = false
}

return isPussyNumber
}
console.log(smallestPussyNumber(516))

(1) (of 1 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.