Skip to content

Solution next happy number added #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Vipullakum007
Copy link
Contributor

Related Issue

i want to add solution of "next happy number " problem #389
fixes : #389

Description

i have added solution of "next happy number " problem

Type of PR

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Other (specify): _______________

Screenshots / Videos (if applicable)

NextHappyNumber.mp4

Checklist

  • I have performed a self-review of my code.
  • I have read and followed the Contribution Guidelines.
  • I have tested the changes thoroughly before submitting this pull request.
  • I have provided relevant issue numbers, screenshots, and videos after making the changes.
  • I have commented my code, particularly in hard-to-understand areas.

Additional Context

[Include any additional information or context that might be helpful for reviewers.]

Resources for Guidance

Here are some resources that may be helpful as you contribute to CodeHarborHub:

Resources for DSA Features on Our Site:

Copy link

vercel bot commented Jun 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
codeharborhub-github-io ❌ Failed (Inspect) Jun 3, 2024 4:02pm

Copy link
Contributor

deepsource-io bot commented Jun 3, 2024

Here's the code health analysis summary for commits 24f918d..7dbfc79. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@ajay-dhangar ajay-dhangar added documentation Improvements or additions to documentation GSSOC'24 GirlScript Summer of Code | Contributor level2 GirlScript Summer of Code | Contributor's Levels gssoc GirlScript Summer of Code | Contributor labels Jun 3, 2024
Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change code based on suggestions for good practices

Since we have already reached 1, the process stops here. 1 is a happy number.

- **Number 2:**

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad Practice:

```
  $[2^2 = 4]$
  $[4^2 = 16]$
  $[1^2 + 6^2 = 37]$
  $[3^2 + 7^2 = 58]$
  $[5^2 + 8^2 = 89]$
  $[8^2 + 9^2 = 145]$
  $[1^2 + 4^2 + 5^2 = 42]$
  $[4^2 + 2^2 = 20]$
  $[2^2 + 0^2 = 4]$
  Since we have reached 4 again, the process will continue in an infinite loop. 2 is not a happy number.
```

Good Practice

 $[2^2 = 4]$
  $[4^2 = 16]$
  $[1^2 + 6^2 = 37]$
  $[3^2 + 7^2 = 58]$
  $[5^2 + 8^2 = 89]$
  $[8^2 + 9^2 = 145]$
  $[1^2 + 4^2 + 5^2 = 42]$
  $[4^2 + 2^2 = 20]$
  $[2^2 + 0^2 = 4]$

Since we have reached 4 again, the process will continue in an infinite loop. 2 is not a happy number.


- **Number 7:**

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad Practice:

```
  $[7^2 = 49]$
  $[4^2 + 9^2 = 97]$
  $[9^2 + 7^2 = 130]$
  $[1^2 + 3^2 + 0^2 = 10]$
  $[1^2 + 0^2 = 1]$
  
  Since we have reached 1, the process stops here. 7 is a happy number.
```

Good Practice

  $[7^2 = 49]$
  $[4^2 + 9^2 = 97]$
  $[9^2 + 7^2 = 130]$
  $[1^2 + 3^2 + 0^2 = 10]$
  $[1^2 + 0^2 = 1]$
  
  Since we have reached 1, the process stops here. 7 is a happy number.

Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change code based on suggestions


## Problem Description

Given a positive number N, find the value of f0 + f1 + f2 + ... + fN where fi indicates the ith Fibonacci number. Note that f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, and so on. Since the answer can be very large, return the result modulo 1000000007.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace f0 + f1 + f2 + ... + fN to $f0 + f1 + f2 + ... + fN$

f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, to $f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5,$

and 1000000007 to $1000000007$


## Constraints

1. $(1 \leq N \leq 10^5)$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace 1. $(1 \leq N \leq 10^5)$ to - $(1 \leq N \leq 10^5)$

@Vipullakum007
Copy link
Contributor Author

hey @ajay-dhangar , i updated as per your suggestion , you can merge it

Copy link

sonarqubecloud bot commented Jun 3, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Vipullakum007
Copy link
Contributor Author

Vipullakum007 commented Jun 3, 2024

hey @ajay-dhangar , what is this issue/problem? i did not get it

Screenshot 2024-06-03 214107

@ajay-dhangar
Copy link
Member

ajay-dhangar commented Jun 3, 2024

hey @ajay-dhangar , what is this issue/problem? i did not get it

Screenshot 2024-06-03 214107

@Vipullakum007 First, you need to run git pull origin main to ensure you have the latest code from the main branch. An error is occurring because the same file has been changed in two different ways, leading to a configuration conflict. Please resolve this issue. Additionally, can you close this PR? It appears that you have created two PRs for the same issue.

@ajay-dhangar
Copy link
Member

image

@ajay-dhangar ajay-dhangar merged commit 7dbfc79 into codeharborhub:main Jun 3, 2024
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation gssoc GirlScript Summer of Code | Contributor GSSOC'24 GirlScript Summer of Code | Contributor level2 GirlScript Summer of Code | Contributor's Levels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature Request]: i want to add solution of "next happy number " problem
2 participants