Skip to content

Commit 12082e0

Browse files
authored
Merge branch 'master' into feature/ZombieChibiXD_Palindrome_JAVA
2 parents b4d6679 + 51bfd05 commit 12082e0

File tree

48 files changed

+359
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+359
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,4 @@ Module.symvers
253253
Mkfile.old
254254
dkms.conf
255255
/.vs
256+
.Rproj.user

CONTRIBUTORS.md

+43-2

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
awk -F '"' '{print $6}' access.log | sort -nr | uniq -c | sort -nr | head -n10

c/HarshitaArun_Swap.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdio.h>
2+
void main()
3+
{
4+
int a,b;
5+
printf("enter a and b\n");
6+
scanf("%d%d",&a,&b);
7+
a=(a+b)-(b=a); // one line code
8+
printf("a=%d and b=%d",a,b);
9+
}

c/gcd/shubhamdpatil_gcd.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* @file: shubhamdpatil_gcd.c
3+
*/
4+
5+
#include <stdio.h>
6+
7+
int gcd(int x, int y)
8+
{
9+
return (y == 0) ? x : gcd(y, x % y);
10+
}
11+
12+
int main()
13+
{
14+
int a, b;
15+
scanf("%d %d", &a, &b);
16+
printf("GCD of %d and %d: %d\n", a, b, gcd(a, b));
17+
return 0;
18+
}

c/swap/shubhamdpatil_swap.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* @file: shubhamdpatil_swap.c
3+
*/
4+
5+
#include <stdio.h>
6+
7+
#define swap(x, y) ((x ^= y), (y ^= x), (x ^= y))
8+
9+
int main()
10+
{
11+
int a, b;
12+
scanf("%d %d", &a, &b);
13+
printf("Before swap: %d, %d\n", a, b);
14+
15+
swap(a, b);
16+
printf("After swap: %d, %d\n", a, b);
17+
return 0;
18+
}
19+

coffeescript/wzhouwzhou_add.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add = (a, b) -> a + b
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subtract = (a, b) -> +a - +b
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
bool isPalindrome(std::string input) { return input == std::string(input.rbegin(), input.rend()); }
5+
6+
int main()
7+
{
8+
std::string input = "able was I ere I saw elba" ;
9+
//std::cout << "Input : ";
10+
//getline (std::cin, input);
11+
std::cout << "It is " << (isPalindrome(input) ? "" : "not ") << "a palindrome";
12+
}
13+

go/wzhouwzhou_add.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
func add(a, b int) int { return a + b }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
void issquare(long long int a){
6+
int flag=1; for(long long i=1;i<=a/2+1;i++){ if(i*i==a) {cout<<"it is a square number\n";flag=0;} }if(flag==1) cout<<"Not a square number\n";
7+
}
8+
9+
int main(){
10+
long long int a;
11+
cin>>a;
12+
issquare(a);
13+
return 0;
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
pair<ll,ll> maxsum(ll arr[],ll n)
5+
{
6+
ll sum=0;
7+
ll max=0;
8+
pair<ll,ll>p;
9+
ll x=0,y=0;
10+
for(ll i=0;i<n;i++)
11+
{
12+
sum+=arr[i];
13+
if(sum>max){max=sum;y=i;}
14+
if(sum<0){sum=0;x=i+1;}
15+
16+
}
17+
p.first=x;
18+
p.second=y;
19+
return p;
20+
}
21+
22+
int main()
23+
{
24+
int n;
25+
cin>>n;
26+
ll arr[n];
27+
for(ll i=0;i<n;i++)cin>>arr[i];
28+
pair<ll,ll>p=maxsum(arr,n);
29+
cout<<p.first<<" "<<p.second<<endl;
30+
return 0;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
int countingValleys(int n, string s) {
5+
6+
7+
int sum=0;
8+
if(s[0]=='U')sum++;
9+
else sum--;
10+
int count=0;
11+
if(sum<0)count++;
12+
for(int i=1;i<n;i++)
13+
{
14+
if(s[i]=='D')sum--;
15+
else sum++;
16+
if(s[i]=='D' && sum==-1)count++;
17+
}
18+
return count;
19+
20+
}
21+
22+
int main()
23+
{
24+
int n;
25+
cin>>n;
26+
string s;
27+
cin>>s;
28+
cout<<countingValleys(n,s)<<endl;
29+
return 0;
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const map = (arr, cb) => {
2+
let i = arr.length, result = Array(i);
3+
while (i--) result[i] = cb(arr[i], i, arr);
4+
return result;
5+
};

java/sgirabin_Max2Digit.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
class Max2Digit {
4+
5+
public static int max(int a, int b) {
6+
return Math.max(a,b);
7+
}
8+
9+
public static void main(String[] args) {
10+
System.out.println(Max2Digit.max(5,10));
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const collatz = x => x <= 1 ? x : collatz((x % 2) === 0 ? x / 2 : x * 3 + 1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This will check if a number is 0 or smaller and then converts it. If 0, to 1. If n < 0, to -n
2+
const convert = (n) => { return (-(~(n ^ 0))) < 0 ? (-(~(n ^ 0))) != -1 ? (-(-(~(n ^ 0)))) + 1 : (-(-(~(n ^ 0)))) : (-(~(n ^ 0))) != 1 ? (-(~(n ^ 0))) - 1 : (-(~(n ^ 0))); }
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const palindrome = (text) => text.toLowerCase() == text.toLowerCase().split("").reverse().join("");

javascript/rpxs_add.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const add = (a, b) => a + b;

javascript/rpxs_subtract.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const subtract = (a, b) => a - b
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const values = [1, 2, 3, 4, 5, 1, 1, 1, 3];
2+
3+
const unique = [void(0)].map((e, i, arr) => new Set(values).forEach(v => arr.push(v)) || arr)[0].slice(1);

javascript/vetlix_deepflat_array.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const deepFlat = arr => arr.flat(Infinity);

javascript/vetlix_empty_array.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const empty = arr => arr.length = 0;

javascript/wzhouwzhou_check_brackets.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void(process.stdout.write('Hello, world!\r\n\0'));

nodejs/tacticaltechjay_coinFlip.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Math.floor(Math.random() * 2) === 1 ? console.log('Heads!') : console.log('Tails!')

nodejs/wzhouwzhou_delay.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(t = 1000) && Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, t)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(Invoke-WebRequest "http://api.open-notify.org/astros.json" | ConvertFrom-Json).people
2+
#note, I got the idea from PowerShell.com a while ago, but I cannot find it now.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Generates a random strong 20 chars long password.
2+
# If you want to change the length of the password you can cange 20 inside the brackets before the -join to somethin else.
3+
([char[]]([char]33..[char]95) + ([char[]]([char]97..[char]126)) + 0..9 | Sort-Object {Get-Random})[0..20] -join ''
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pi=lambda get_approx_pi:4 * sum(-float(k%4 - 2) / k for k in range(1, 2*val+1, 2))
2+
val=int(input('Number of iterations'))
3+
print(pi(val))

python/bhavikb07_Factors.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from functools import reduce
2+
3+
def factors(n):
4+
return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
5+

python/hello/antonio32a_world.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import __hello__
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[elemento**2 for elemento in range(11) if elemento%2==0]

python/mirandars_parity-test.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
par = lambda x:True if x%2==0 else False

python/mspatel927_Greater_Than.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Returns a positive number if x is > y, 0 if they are equal, or a negative number if x is < y
2+
def greaterThan(x, y):
3+
return (x-y)

python/mspatel927_Mirror_List.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def mirrorList(list):
2+
return list[::-1]
3+

python/mspatel927_Random_Card_Draw.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def mean(list):
2+
return sum(list)/len(list)
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Consider the program that takes in a string and a list of numbers.
2+
#It will prepend the string to each of the numbers and return a string of this new list separated by commas.
3+
#For example, foo('$', range(5)) would return '$0, $1, $2, $3, $4'.
4+
#A naive coder will do this-
5+
#
6+
#def foo(string, numbers):
7+
# output = ''
8+
# for i in range(len(numbers)):
9+
# if i > 0:
10+
# output += ', '
11+
# output += string + str(numbers[i])
12+
# return output
13+
#
14+
# Here is an elegant way with Output $0, $1, $2, $3, $4-
15+
16+
def foo(string, numbers): return ', '.join(map(lambda s,n:s+str(n), [string for i in numbers], numbers))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print '\n'.join("%i Byte = %i Bit = largest number: %i" % (j, j*8, 256**j-1) for j in (1 << i for i in xrange(8)))
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dec = 344
2+
3+
print("The decimal value of",dec,"is:")
4+
print(bin(dec),"in binary.")
5+
print(oct(dec),"in octal.")
6+
print(hex(dec),"in hexadecimal.")

python/sorting/ngweihow_bogosort.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'''
2+
Bogosort created using lambda.
3+
4+
@author: ngweihow (github.com/ngweihow)
5+
'''
6+
from random import sample
7+
8+
b_sort = lambda ls: ls if all(ls[i] <= ls[i+1] for i in range(len(ls)-1)) else b_sort(sample(ls, len(ls)))
9+
10+
# Tests (PLEASE DO NOT TEST WITH LARGE LIST INPUT, BOGOSORT IS HIGHLY INEFFICIENT)
11+
print(b_sort([4,3,2,1]))

python/unique/RaInta_unique_array.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
list1 = [1,10,7,1,4]
2+
3+
[x for idx, x in enumerate(list1) if x not in list1[:idx]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Given two lists, find elements not present in both
2+
# Effectively, a join + delete duplicates. Conversion to set means it nukes repeated elements
3+
s1 = [1,9,23,4]
4+
s2 = [1,4,8,3,7]
5+
6+
# XOR operation on sets
7+
print(set(s1) ^ set(s2))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def uni(arr):
2+
li=[]
3+
[li.append(i) for i in arr if not li.count(i)]
4+
return li
5+
6+
list1 = [10, 20, 10, 30, 40, 40]
7+
print(getunique(list1))
8+
9+

r/prime/KKulma_find-prime-number.R

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
is.prime <- function(n) n == 2L || all(n %% 2L:ceiling(sqrt(n)) != 0)
2+
3+
# test
4+
test_vec <- 0:10
5+
sapply(test_vec, is.prime)

0 commit comments

Comments
 (0)