-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jspowerset
- Loading branch information
Showing
48 changed files
with
366 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,3 +253,4 @@ Module.symvers | |
Mkfile.old | ||
dkms.conf | ||
/.vs | ||
.Rproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,6 +366,11 @@ Coding Experience: Discord Bot Developer (Java) + misc. wrappers. <br> | |
Programming Languages: Python 2/3, Java 8<br> | ||
Email: [email protected] | ||
|
||
Name: [Shubham Patil](https://github.com/shubhamdpatil) | ||
Place: Pune, India | ||
Coding Experience: C, python | ||
Email: [email protected] | ||
|
||
Name: [Lizard Morrow] (https://github.com/onlyasmalllizard) </br> | ||
Place: UK </br> | ||
Coding Experience: Ruby, Python, C, HTML/CSS </br> | ||
|
@@ -444,3 +449,45 @@ Name:[Caden Mccauley](https://github.com/DiscoTiger) </br> | |
Place: United States </br> | ||
Coding Experience: CS Student primarily focusing on Javascript and C++ | ||
Email: [email protected] </br> | ||
|
||
Name: [Roger Seekell](https://github.com/rpstester) <br /> | ||
Place: Earth<br /> | ||
Coding Experience: C++, C#, Java, PowerShell<br /> | ||
Email: [email protected]<br /> | ||
|
||
Name: [Abhay yadav](https://github.com/predator21x) </br> | ||
place: India. </br> | ||
Coding Experience: a newbie in this field. Programming language: C, python. </br> | ||
Email: [email protected] </br> | ||
|
||
Name: [Abhishek Singh](https://github.com/n6wbi6) </br> | ||
Place: India </br> | ||
Coding Experience: C and python. </br> | ||
Email: [email protected] </br> | ||
|
||
Name: [Isak Rabin](https://github.com/sgirabin) | ||
Place: Singapore | ||
Coding Experience: Java | ||
Email: [email protected] | ||
|
||
Name: [Zombie Chibi XD](https://github.com/ZombieChibiXD) </br> | ||
Place: Bali, Indonesia </br> | ||
Field Experience: System Administrator, Junior web developer, beta-tester, and debugger </br> | ||
Coding Experience: 3 years of learning & coding experience in C++, Java, Javascript/NodeJS, PHP, Vue.js, Laravel Framework, GoLang and python. </br> | ||
Email: [email protected] </br> | ||
|
||
Name: [Oyvind Nilsen](https://github.com/turbosnute) </br> | ||
Place: Trondheim, Norway </br> | ||
Field Experience: System Admin </br> | ||
Coding Experience: 10 years of Powershell scripting. Also some experience with Java, Js, PHP, Python and C#. </br> | ||
Email: [email protected] </br> | ||
|
||
Name: [Jay](https://github.com/TacticalTechJay) </br> | ||
Place: Milky Way Galaxy </br> | ||
Coding Experience: Semi-noob in JS. </br> | ||
Email: [email protected] </br> | ||
|
||
Name: [David](https://github.com/Xander1233) </br> | ||
Place: Frankfurt, Germany </br> | ||
Coding Experience: TS, JS/NodeJS, Java, C, C++, C#, Assembly, React | ||
Email: [email protected] </br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BEGIN {printf "Enter a temperature of format ##f or ##c to get the opposing value\n"; getline < "-"} BEGIN { if ( $1 ~ /f/ ) { print (((substr($1, 1, length($1)-1) - 32) * 5/9))"C"} else if ( $1 ~ /c/ ) { print (substr($1, 1, length($1)-1) * 9 / 5 + 32"F")} else {print "Usage: ##f to convert to celcius ##c to convert to fahrenheit"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
void main() | ||
{ | ||
int a,b; | ||
printf("enter a and b\n"); | ||
scanf("%d%d",&a,&b); | ||
a=(a+b)-(b=a); // one line code | ||
printf("a=%d and b=%d",a,b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* @file: shubhamdpatil_gcd.c | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
int gcd(int x, int y) | ||
{ | ||
return (y == 0) ? x : gcd(y, x % y); | ||
} | ||
|
||
int main() | ||
{ | ||
int a, b; | ||
scanf("%d %d", &a, &b); | ||
printf("GCD of %d and %d: %d\n", a, b, gcd(a, b)); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
|
||
printf("Hello, world!"); | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* @file: shubhamdpatil_swap.c | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#define swap(x, y) ((x ^= y), (y ^= x), (x ^= y)) | ||
|
||
int main() | ||
{ | ||
int a, b; | ||
scanf("%d %d", &a, &b); | ||
printf("Before swap: %d, %d\n", a, b); | ||
|
||
swap(a, b); | ||
printf("After swap: %d, %d\n", a, b); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add = (a, b) -> a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
subtract = (a, b) -> +a - +b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
bool isPalindrome(std::string input) { return input == std::string(input.rbegin(), input.rend()); } | ||
|
||
int main() | ||
{ | ||
std::string input = "able was I ere I saw elba" ; | ||
//std::cout << "Input : "; | ||
//getline (std::cin, input); | ||
std::cout << "It is " << (isPalindrome(input) ? "" : "not ") << "a palindrome"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
func add(a, b int) int { return a + b } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
void issquare(long long int a){ | ||
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"; | ||
} | ||
|
||
int main(){ | ||
long long int a; | ||
cin>>a; | ||
issquare(a); | ||
return 0; | ||
} |
31 changes: 31 additions & 0 deletions
31
...ine-wonders/cplusplus/yashagarwal1999_Largest _sum_of_consecutive_numbers_in_an_array.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long int ll; | ||
pair<ll,ll> maxsum(ll arr[],ll n) | ||
{ | ||
ll sum=0; | ||
ll max=0; | ||
pair<ll,ll>p; | ||
ll x=0,y=0; | ||
for(ll i=0;i<n;i++) | ||
{ | ||
sum+=arr[i]; | ||
if(sum>max){max=sum;y=i;} | ||
if(sum<0){sum=0;x=i+1;} | ||
|
||
} | ||
p.first=x; | ||
p.second=y; | ||
return p; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
cin>>n; | ||
ll arr[n]; | ||
for(ll i=0;i<n;i++)cin>>arr[i]; | ||
pair<ll,ll>p=maxsum(arr,n); | ||
cout<<p.first<<" "<<p.second<<endl; | ||
return 0; | ||
} |
30 changes: 30 additions & 0 deletions
30
honorary-one-line-wonders/cplusplus/yashagarwal1999_countingValley.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long int ll; | ||
int countingValleys(int n, string s) { | ||
|
||
|
||
int sum=0; | ||
if(s[0]=='U')sum++; | ||
else sum--; | ||
int count=0; | ||
if(sum<0)count++; | ||
for(int i=1;i<n;i++) | ||
{ | ||
if(s[i]=='D')sum--; | ||
else sum++; | ||
if(s[i]=='D' && sum==-1)count++; | ||
} | ||
return count; | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
cin>>n; | ||
string s; | ||
cin>>s; | ||
cout<<countingValleys(n,s)<<endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const map = (arr, cb) => { | ||
let i = arr.length, result = Array(i); | ||
while (i--) result[i] = cb(arr[i], i, arr); | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
class Max2Digit { | ||
|
||
public static int max(int a, int b) { | ||
return Math.max(a,b); | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println(Max2Digit.max(5,10)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const collatz = x => x <= 1 ? x : collatz((x % 2) === 0 ? x / 2 : x * 3 + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This will check if a number is 0 or smaller and then converts it. If 0, to 1. If n < 0, to -n | ||
const convert = (n) => { return (-(~(n ^ 0))) < 0 ? (-(~(n ^ 0))) != -1 ? (-(-(~(n ^ 0)))) + 1 : (-(-(~(n ^ 0)))) : (-(~(n ^ 0))) != 1 ? (-(~(n ^ 0))) - 1 : (-(~(n ^ 0))); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const palindrome = (text) => text.toLowerCase() == text.toLowerCase().split("").reverse().join(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const add = (a, b) => a + b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const subtract = (a, b) => a - b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const values = [1, 2, 3, 4, 5, 1, 1, 1, 3]; | ||
|
||
const unique = [void(0)].map((e, i, arr) => new Set(values).forEach(v => arr.push(v)) || arr)[0].slice(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const deepFlat = arr => arr.flat(Infinity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const empty = arr => arr.length = 0; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void(process.stdout.write('Hello, world!\r\n\0')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Math.floor(Math.random() * 2) === 1 ? console.log('Heads!') : console.log('Tails!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(t = 1000) && Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(Invoke-WebRequest "http://api.open-notify.org/astros.json" | ConvertFrom-Json).people | ||
#note, I got the idea from PowerShell.com a while ago, but I cannot find it now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generates a random strong 20 chars long password. | ||
# If you want to change the length of the password you can cange 20 inside the brackets before the -join to somethin else. | ||
([char[]]([char]33..[char]95) + ([char[]]([char]97..[char]126)) + 0..9 | Sort-Object {Get-Random})[0..20] -join '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pi=lambda get_approx_pi:4 * sum(-float(k%4 - 2) / k for k in range(1, 2*val+1, 2)) | ||
val=int(input('Number of iterations')) | ||
print(pi(val)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fact = lambda x: 1 if x == 0 else x * fact(x-1) | ||
#testing it | ||
print(fact(25)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import __hello__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[elemento**2 for elemento in range(11) if elemento%2==0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
par = lambda x:True if x%2==0 else False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Returns a positive number if x is > y, 0 if they are equal, or a negative number if x is < y | ||
def greaterThan(x, y): | ||
return (x-y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def mean(list): | ||
return sum(list)/len(list) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#Consider the program that takes in a string and a list of numbers. | ||
#It will prepend the string to each of the numbers and return a string of this new list separated by commas. | ||
#For example, foo('$', range(5)) would return '$0, $1, $2, $3, $4'. | ||
#A naive coder will do this- | ||
# | ||
#def foo(string, numbers): | ||
# output = '' | ||
# for i in range(len(numbers)): | ||
# if i > 0: | ||
# output += ', ' | ||
# output += string + str(numbers[i]) | ||
# return output | ||
# | ||
# Here is an elegant way with Output $0, $1, $2, $3, $4- | ||
|
||
def foo(string, numbers): return ', '.join(map(lambda s,n:s+str(n), [string for i in numbers], numbers)) |
1 change: 1 addition & 0 deletions
1
python/predator21x_The-largest_number_that_can_be_represented_by_8_Byte.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dec = 344 | ||
|
||
print("The decimal value of",dec,"is:") | ||
print(bin(dec),"in binary.") | ||
print(oct(dec),"in octal.") | ||
print(hex(dec),"in hexadecimal.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
''' | ||
Bogosort created using lambda. | ||
@author: ngweihow (github.com/ngweihow) | ||
''' | ||
from random import sample | ||
|
||
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))) | ||
|
||
# Tests (PLEASE DO NOT TEST WITH LARGE LIST INPUT, BOGOSORT IS HIGHLY INEFFICIENT) | ||
print(b_sort([4,3,2,1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
list1 = [1,10,7,1,4] | ||
|
||
[x for idx, x in enumerate(list1) if x not in list1[:idx]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Given two lists, find elements not present in both | ||
# Effectively, a join + delete duplicates. Conversion to set means it nukes repeated elements | ||
s1 = [1,9,23,4] | ||
s2 = [1,4,8,3,7] | ||
|
||
# XOR operation on sets | ||
print(set(s1) ^ set(s2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def uni(arr): | ||
li=[] | ||
[li.append(i) for i in arr if not li.count(i)] | ||
return li | ||
|
||
list1 = [10, 20, 10, 30, 40, 40] | ||
print(getunique(list1)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
is.prime <- function(n) n == 2L || all(n %% 2L:ceiling(sqrt(n)) != 0) | ||
|
||
# test | ||
test_vec <- 0:10 | ||
sapply(test_vec, is.prime) |
Oops, something went wrong.