Skip to content
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

Updated Single digits #292

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Automorphic
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// C++ program to check if a number is Authomorphic
#include <iostream>
using namespace std;

// Function to check Automorphic number
bool isAutomorphic(int N)
{
// Store the square
int sq = N * N;

// Start Comparing digits
while (N > 0) {
// Return false, if any digit of N doesn't
// match with its square's digits from last
if (N % 10 != sq % 10)
return false;

// Reduce N and square
N /= 10;
sq /= 10;
}

return true;
}

// Driver code
int main()
{
std::cout<<"Enter the number";
std::cin>>N;

isAutomorphic(N) ? cout << "Automorphic": cout << "Not Automorphic";

return 0;
}
42 changes: 42 additions & 0 deletions Balance - Cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

#include<bits/stdc++.h>
using namespace std;

int findSplitPoint(int arr[], int n)
{
int leftSum = 0 ;
for (int i = 0; i < n; i++)
{
leftSum += arr[i] ;
int rightSum = 0 ;
for (int j = i+1 ; j < n ; j++ )
rightSum += arr[j] ;

if (leftSum == rightSum)
return i+1 ;
}
return -1;
}

void printTwoParts(int arr[], int n)
{
int splitPoint = findSplitPoint(arr, n);

if (splitPoint == -1 || splitPoint == n )
{
cout << "False" <<endl;
return;
}
else
cout<< "True" <<endl;
}

int main()
{
int arr[1000]; //Max size taken 1000
for (int i = 0 ; i < n ; i++)
cin>>arr[i];
int n = sizeof(arr)/sizeof(arr[0]);
printTwoParts(arr, n);
return 0;
}
14 changes: 14 additions & 0 deletions Single digits - python
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n = int(input("Enter number: ")) #taking input from user
s = str(n)
count = 0
my_dict = {} #initialization
for i in range(0,len(s)): #loop through the integer
if s[i] in my_dict:
my_dict[s[i]] += 1
else:
my_dict[s[i]] = 1

for m in my_dict.values(): #traversing through dictionary values
if m == 1:
count+=1
print("Count of number of digits appearing exactly once: ", count)
14 changes: 14 additions & 0 deletions count of number of single terms in a integer
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n = int(input("Enter number: ")) """taking input from user"""
s = str(n)
count = 0
my_dict = {} """initialization"""
for i in range(0,len(s)): """loop through the integer"""
if s[i] in my_dict:
my_dict[s[i]] += 1
else:
my_dict[s[i]] = 1

for m in my_dict.values(): """traversing through dictionary values"""
if m == 1:
count+=1
print("Count of number of digits appearing exactly once: ", count)