text
stringlengths 2
104M
| meta
dict |
---|---|
# Day 6: Let's Review
# Characters and Strings
#
# https://www.hackerrank.com/challenges/30-review-loop/problem
#
for _ in range(int(input())):
s = input()
# pas tout à fait le but du challenge, mais Python est élégant!
print(s[::2], s[1::2])
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Day 5: Loops
# Let's talk about loops.
#
# https://www.hackerrank.com/challenges/30-loops/problem
#
n = int(input())
for i in range(1, 11):
print("{} x {} = {}".format(n, i, n * i))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 10: Binary Numbers
// Find the maximum number of consecutive 1's in the base-2 representation of a base-10 number.
//
// https://www.hackerrank.com/challenges/30-binary-numbers/problem
//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
int one = 0;
int answer = 0;
cin >> n;
while (n != 0)
{
if ((n & 1) == 1)
{
one++;
answer = max(answer, one);
}
else
one = 0;
n >>= 1;
}
cout << answer << endl;
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 11: 2D Arrays
// Find the maximum sum of any hourglass in a 2D-Array.
//
// https://www.hackerrank.com/challenges/30-2d-arrays/problem
//
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<vector<int>> arr(6, vector<int>(6));
for(int arr_i = 0; arr_i < 6; arr_i++)
{
for(int arr_j = 0; arr_j < 6; arr_j++)
{
cin >> arr[arr_i][arr_j];
}
}
int sum, max = -100;
for (int x = 1; x < 5; ++x)
{
for (int y = 1; y < 5; ++y)
{
sum = arr[x-1][y-1] + arr[x-1][y] + arr[x-1][y+1]
+ arr[x][y] +
arr[x+1][y-1] + arr[x+1][y] + arr[x+1][y+1];
if (sum > max) max = sum;
}
}
cout << max << endl;
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 23: BST Level-Order Traversal
// Implement a breadth-first search!
//
// https://www.hackerrank.com/challenges/30-binary-trees/problem
//
#include <iostream>
#include <cstddef>
#include <queue>
#include <string>
#include <cstdlib>
using namespace std;
class Node{
public:
int data;
Node *left,*right;
Node(int d){
data=d;
left=right=NULL;
}
};
class Solution{
public:
Node* insert(Node* root, int data){
if(root==NULL){
return new Node(data);
}
else{
Node* cur;
if(data<=root->data){
cur=insert(root->left,data);
root->left=cur;
}
else{
cur=insert(root->right,data);
root->right=cur;
}
return root;
}
}
// (skeliton_head) ----------------------------------------------------------------------
void levelOrder(Node * root)
{
queue<Node *> q;
q.push(root);
while (! q.empty())
{
auto n = q.front();
q.pop();
if (n)
{
cout << n->data << " ";
q.push(n->left);
q.push(n->right);
}
}
cout << endl;
}
// (skeliton_tail) ----------------------------------------------------------------------
};//End of Solution
int main(){
Solution myTree;
Node* root=NULL;
int T,data;
cin>>T;
while(T-->0){
cin>>data;
root= myTree.insert(root,data);
}
myTree.levelOrder(root);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 25: Running Time and Complexity
// Determine if a number is prime in optimal time!
//
// https://www.hackerrank.com/challenges/30-running-time-and-complexity/problem
//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool is_prime(int n)
{
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
int d = 3;
while (d * d <= n)
{
if (n % d == 0) return false;
d += 2;
}
return true;
}
int main()
{
int q;
cin >> q;
while (q--)
{
int n;
cin >> n;
cout << (is_prime(n) ? "Prime" : "Not prime") << endl;
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 20: Sorting
// Find the minimum number of conditional checks taking place in Bubble Sort
//
// https://www.hackerrank.com/challenges/30-sorting/problem
//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
vector<int> arr;
cin >> n;
arr.resize(n);
for (int i = 0; i < n; ++i) cin >> arr[i];
int swaps = 0;
bool swapped;
do {
swapped = false;
for (int i = 0; i < n - 1; ++i)
{
if (arr[i] > arr[i + 1])
{
swap(arr[i], arr[i + 1]);
swaps++; // compteur de swap
swapped = true; // on devra recommencer...
}
}
} while (swapped);
cout << "Array is sorted in " << swaps << " swaps." << endl;
cout << "First Element: " << arr[0] << endl;
cout << "Last Element: " << arr[n - 1] << endl;
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 19: Interfaces
// Welcome to Day 19! Learn about interfaces in this challenge!
//
// https://www.hackerrank.com/challenges/30-interfaces/problem
//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
class AdvancedArithmetic{
public:
virtual int divisorSum(int n)=0;
};
// (skeliton_head) ----------------------------------------------------------------------
class Calculator : public AdvancedArithmetic
{
public:
virtual int divisorSum(int n) override
{
int sum = 0;
for (int i = 1; i <= n; ++i)
{
if (n % i == 0) sum += i;
}
return sum;
}
};
// (skeliton_tail) ----------------------------------------------------------------------
int main(){
int n;
cin >> n;
AdvancedArithmetic *myCalculator = new Calculator();
int sum = myCalculator->divisorSum(n);
cout << "I implemented: AdvancedArithmetic\n" << sum;
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Day 2: Operators
# Start using arithmetic operators.
#
# https://www.hackerrank.com/challenges/30-operators/problem
#
#!/bin/python3
import sys
if __name__ == "__main__":
meal_cost = float(input().strip())
tip_percent = int(input().strip())
tax_percent = int(input().strip())
cost = meal_cost * (1 + tip_percent / 100 + tax_percent / 100)
print("The total meal cost is {:.0f} dollars.".format(cost))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Tutorials > 30 Days of Code > Day 28: RegEx, Patterns, and Intro to Databases
# Review Pattern documentation and start using Regular Expressions
#
# https://www.hackerrank.com/challenges/30-regex-patterns/problem
#
# où sont les regex ?...
gmail = {}
for _ in range(int(input())):
firstName, emailID = input().split()
if emailID.endswith("@gmail.com"):
gmail[emailID] = firstName
for i in sorted(gmail.values()):
print(i)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Tutorials](https://www.hackerrank.com/domains/tutorials)
#### [30 Days of Code](https://www.hackerrank.com/domains/tutorials/30-days-of-code)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Day 0: Hello, World.](https://www.hackerrank.com/challenges/30-hello-world)|Practice reading from stdin and printing to stdout.|[C](30-hello-world.c) [Python](30-hello-world.py)|Easy
[Day 1: Data Types](https://www.hackerrank.com/challenges/30-data-types)|Get started with data types.|[C++](30-data-types.cpp) [Python](30-data-types.py)|Easy
[Day 2: Operators](https://www.hackerrank.com/challenges/30-operators)|Start using arithmetic operators.|[C++](30-operators.cpp) [Python](30-operators.py)|Easy
[Day 3: Intro to Conditional Statements](https://www.hackerrank.com/challenges/30-conditional-statements)|Get started with conditional statements.|[C++](30-conditional-statements.cpp)|Easy
[Day 4: Class vs. Instance](https://www.hackerrank.com/challenges/30-class-vs-instance)|Learn the difference between class variables and instance variables.|[Python](30-class-vs-instance.py)|Easy
[Day 5: Loops](https://www.hackerrank.com/challenges/30-loops)|Let's talk about loops.|[Python](30-loops.py)|Easy
[Day 6: Let's Review](https://www.hackerrank.com/challenges/30-review-loop)|Characters and Strings|[C++](30-review-loop.cpp) [Python](30-review-loop.py)|Easy
[Day 7: Arrays](https://www.hackerrank.com/challenges/30-arrays)|Getting started with Arrays.|[C++](30-arrays.cpp) [Python](30-arrays.py)|Easy
[Day 8: Dictionaries and Maps](https://www.hackerrank.com/challenges/30-dictionaries-and-maps)|Mapping Keys to Values using a Map or Dictionary.|[Python](30-dictionaries-and-maps.py)|Easy
[Day 9: Recursion](https://www.hackerrank.com/challenges/30-recursion)|Use recursion to compute the factorial of number.|[Python](30-recursion.py)|Easy
[Day 10: Binary Numbers](https://www.hackerrank.com/challenges/30-binary-numbers)|Find the maximum number of consecutive 1's in the base-2 representation of a base-10 number.|[C++](30-binary-numbers.cpp) [Python](30-binary-numbers.py)|Easy
[Day 11: 2D Arrays](https://www.hackerrank.com/challenges/30-2d-arrays)|Find the maximum sum of any hourglass in a 2D-Array.|[C++](30-2d-arrays.cpp) [Python](30-2d-arrays.py)|Easy
[Day 12: Inheritance](https://www.hackerrank.com/challenges/30-inheritance)|Learn about inheritance.|[C++](30-inheritance.cpp)|Easy
[Day 13: Abstract Classes](https://www.hackerrank.com/challenges/30-abstract-classes)|Build on what you've already learned about Inheritance with this Abstract Classes challenge|[C++](30-abstract-classes.cpp) [Python](30-abstract-classes.py)|Easy
[Day 14: Scope](https://www.hackerrank.com/challenges/30-scope)|Learn about the scope of an identifier.|[C++](30-scope.cpp) [Python](30-scope.py)|Easy
[Day 15: Linked List](https://www.hackerrank.com/challenges/30-linked-list)|Complete the body of a function that adds a new node to the tail of a Linked List.|[C++](30-linked-list.cpp) [Python](30-linked-list.py)|Easy
[Day 16: Exceptions - String to Integer](https://www.hackerrank.com/challenges/30-exceptions-string-to-integer)|Can you determine if a string can be converted to an integer?|[C++](30-exceptions-string-to-integer.cpp) [Python](30-exceptions-string-to-integer.py)|Easy
[Day 17: More Exceptions](https://www.hackerrank.com/challenges/30-more-exceptions)|Throw an exception when user sends wrong parameters to a method.|[C++](30-more-exceptions.cpp)|Easy
[Day 18: Queues and Stacks](https://www.hackerrank.com/challenges/30-queues-stacks)|Use stacks and queues to determine if a string is a palindrome.|[Python](30-queues-stacks.py)|Easy
[Day 19: Interfaces](https://www.hackerrank.com/challenges/30-interfaces)|Welcome to Day 19! Learn about interfaces in this challenge!|[C++](30-interfaces.cpp)|Easy
[Day 20: Sorting](https://www.hackerrank.com/challenges/30-sorting)|Find the minimum number of conditional checks taking place in Bubble Sort|[C++](30-sorting.cpp)|Easy
[Day 21: Generics](https://www.hackerrank.com/challenges/30-generics)|Welcome to Day 21! Review generics in this challenge!|[C++](30-generics.cpp)|Easy
[Day 22: Binary Search Trees](https://www.hackerrank.com/challenges/30-binary-search-trees)|Given a binary tree, print its height.|[Python](30-binary-search-trees.py)|Easy
[Day 23: BST Level-Order Traversal](https://www.hackerrank.com/challenges/30-binary-trees)|Implement a breadth-first search!|[C++](30-binary-trees.cpp) [Python](30-binary-trees.py)|Easy
[Day 24: More Linked Lists](https://www.hackerrank.com/challenges/30-linked-list-deletion)|Welcome to Day 24! Review everything we've learned so far and learn more about Linked Lists in this challenge.|[C++](30-linked-list-deletion.cpp)|Easy
[Day 25: Running Time and Complexity](https://www.hackerrank.com/challenges/30-running-time-and-complexity)|Determine if a number is prime in optimal time!|[C++](30-running-time-and-complexity.cpp) [Python](30-running-time-and-complexity.py)|Medium
[Day 26: Nested Logic](https://www.hackerrank.com/challenges/30-nested-logic)|Test your understanding of layered logic by calculating a library fine!|[C++](30-nested-logic.cpp)|Easy
[Day 27: Testing](https://www.hackerrank.com/challenges/30-testing)|Welcome to Day 27! Review testing in this challenge!|[Python](30-testing.py)|Easy
[Day 28: RegEx, Patterns, and Intro to Databases](https://www.hackerrank.com/challenges/30-regex-patterns)|Review Pattern documentation and start using Regular Expressions|[Python](30-regex-patterns.py)|Medium
[Day 29: Bitwise AND](https://www.hackerrank.com/challenges/30-bitwise-and)|Apply everything we've learned in this bitwise AND challenge.|[C++](30-bitwise-and.cpp)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Tutorials > 30 Days of Code > Day 16: Exceptions - String to Integer
// Can you determine if a string can be converted to an integer?
//
// https://www.hackerrank.com/challenges/30-exceptions-string-to-integer/problem
//
#include <bits/stdc++.h>
using namespace std;
int main()
{
try
{
string s;
cin >> s;
cout << stoi(s) << endl;
}
catch (invalid_argument& e)
{
cout << "Bad String" << endl;
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Distributed Systems](https://www.hackerrank.com/domains/distributed-systems)
#### [Multiple Choice](https://www.hackerrank.com/domains/distributed-systems/distributed-mcq)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Distributed Objects - 1](https://www.hackerrank.com/challenges/mcq-challenge-7)|Distributed Objects - 1|[text](distributed-mcq/mcq-challenge-7.txt)|Easy
[Distributed Objects - 2](https://www.hackerrank.com/challenges/mcq-challenge-8)|Distributed Objects - 2|[text](distributed-mcq/mcq-challenge-8.txt)|Easy
[Distributed Objects - 3](https://www.hackerrank.com/challenges/mcq-challenge-9)|Distributed Objects - 3|[text](distributed-mcq/mcq-challenge-9.txt)|Easy
[Distributed Objects - 4](https://www.hackerrank.com/challenges/mcq-challenge-10)|Distributed Objects - 4|[text](distributed-mcq/mcq-challenge-10.txt)|Easy
[Distributed Objects - 5](https://www.hackerrank.com/challenges/mcq-challenge-11)|Distributed Objects - 5|[text](distributed-mcq/mcq-challenge-11.txt)|Easy
[MapReduce - 2](https://www.hackerrank.com/challenges/mcq-challenge-13)|MapReduce - 2|[text](distributed-mcq/mcq-challenge-13.txt)|Easy
[MapReduce - 3](https://www.hackerrank.com/challenges/mcq-challenge-14)|MapReduce - 3|[text](distributed-mcq/mcq-challenge-14.txt)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > Distributed Objects - 3
#
# https://www.hackerrank.com/challenges/mcq-challenge-9/problem
# challenge id: 8460
#
Jt
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > Distributed Objects - 1
#
# https://www.hackerrank.com/challenges/mcq-challenge-7/problem
# challenge id: 8458
#
DCOM
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > MapReduce - 2
#
# https://www.hackerrank.com/challenges/mcq-challenge-13/problem
# challenge id: 8464
#
True
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > Distributed Objects - 4
#
# https://www.hackerrank.com/challenges/mcq-challenge-10/problem
# challenge id: 8461
#
JavaSpaces
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# https://www.hackerrank.com/domains/distributed-systems?filters%5Bsubdomains%5D%5B%5D=distributed-mcq
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > MapReduce - 3
#
# https://www.hackerrank.com/challenges/mcq-challenge-14/problem
# challenge id: 8465
#
False
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > Distributed Objects - 2
#
# https://www.hackerrank.com/challenges/mcq-challenge-8/problem
# challenge id: 8459
#
DDObjects
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Distributed Systems > Multiple Choice > Distributed Objects - 5
#
# https://www.hackerrank.com/challenges/mcq-challenge-11/problem
# challenge id: 8462
#
Pyro
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Distributed Systems](https://www.hackerrank.com/domains/distributed-systems)
#### [Multiple Choice](https://www.hackerrank.com/domains/distributed-systems/distributed-mcq)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Distributed Objects - 1](https://www.hackerrank.com/challenges/mcq-challenge-7)|Distributed Objects - 1|[text](mcq-challenge-7.txt)|Easy
[Distributed Objects - 2](https://www.hackerrank.com/challenges/mcq-challenge-8)|Distributed Objects - 2|[text](mcq-challenge-8.txt)|Easy
[Distributed Objects - 3](https://www.hackerrank.com/challenges/mcq-challenge-9)|Distributed Objects - 3|[text](mcq-challenge-9.txt)|Easy
[Distributed Objects - 4](https://www.hackerrank.com/challenges/mcq-challenge-10)|Distributed Objects - 4|[text](mcq-challenge-10.txt)|Easy
[Distributed Objects - 5](https://www.hackerrank.com/challenges/mcq-challenge-11)|Distributed Objects - 5|[text](mcq-challenge-11.txt)|Easy
[MapReduce - 2](https://www.hackerrank.com/challenges/mcq-challenge-13)|MapReduce - 2|[text](mcq-challenge-13.txt)|Easy
[MapReduce - 3](https://www.hackerrank.com/challenges/mcq-challenge-14)|MapReduce - 3|[text](mcq-challenge-14.txt)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Databases](https://www.hackerrank.com/domains/databases)
Check your Database skills
#### [Relational Algebra](https://www.hackerrank.com/domains/databases/relational-algebra)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Basics of Sets and Relations #1](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-1)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-1.txt)|Easy
[Basics of Sets and Relations #2](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-2)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-2.txt)|Easy
[Basics of Sets and Relations #3](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-3)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-3.txt)|Easy
[Basics of Sets and Relations #4](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-4)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-4.txt)|Easy
[Basics of Sets and Relations #5](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-5)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-5.txt)|Easy
[Basics of Sets and Relations #6](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-6)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-6.txt)|Easy
[Basics of Sets and Relations #7](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-7)|Problems based on the basics of sets and relations.|[text](relational-algebra/basics-of-sets-and-relational-algebra-7.txt)|Easy
[Relational Algebra - 3](https://www.hackerrank.com/challenges/relational-algebra-3)|Relational Algebra - 3|[text](relational-algebra/relational-algebra-3.txt)|Easy
[Relational Algebra - 4](https://www.hackerrank.com/challenges/relational-algebra-4)|Relational Algebra - 4|[text](relational-algebra/relational-algebra-4.txt)|Easy
[Database Query Languages](https://www.hackerrank.com/challenges/database-query-languages)|Database Query Languages|[text](relational-algebra/database-query-languages.txt)|Easy
[Procedural Language](https://www.hackerrank.com/challenges/procedural-language)|Procedural Language|[text](relational-algebra/procedural-language.txt)|Easy
[Relations - 1](https://www.hackerrank.com/challenges/relations-1)|Relations - 1|[text](relational-algebra/relations-1.txt)|Easy
[Relations - 2](https://www.hackerrank.com/challenges/relations-2)|Relations - 2|[text](relational-algebra/relations-2.txt)|Easy
#### [Database Normalization](https://www.hackerrank.com/domains/databases/database-normalization)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Database Normalization #1 - 1NF](https://www.hackerrank.com/challenges/database-normalization-1-1nf)|The first normal form.|[text](database-normalization/database-normalization-1-1nf.txt)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #5
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-5/problem
#
2
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Relations - 2
#
# https://www.hackerrank.com/challenges/relations-2/problem
#
Cartesian product
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Relational Algebra - 3
#
# https://www.hackerrank.com/challenges/relational-algebra-3/problem
#
Equijoins
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Database Query Languages
#
# https://www.hackerrank.com/challenges/database-query-languages/problem
#
Query
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Relational Algebra - 4
#
# https://www.hackerrank.com/challenges/relational-algebra-4/problem
#
Left to right
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #7
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-7/problem
#
2
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Procedural Language
#
# https://www.hackerrank.com/challenges/procedural-language/problem
#
Relational algebra
# (question vaseuse)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #6
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-6/problem
#
2
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Relations - 1
#
# https://www.hackerrank.com/challenges/relations-1/problem
#
Join
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #4
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-4/problem
#
# c'est le nombre de combinaisons entre A et B: 6 éléments de A avec 7 éléments de B
42
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #1
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-1/problem
#
# union: résultat de l'union: 1,2,3,4,5,6,7,8
8
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #3
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-3/problem
#
# les éléments de A moins les éléments de B: il ne reste que 1
1
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Relational Algebra > Basics of Sets and Relations #2
# Problems based on the basics of sets and relations.
#
# https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-2/problem
#
# intersection: les éléments 2,3,4,5,6 sont présents dans les deux listes
5
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Databases](https://www.hackerrank.com/domains/databases)
Check your Database skills
#### [Relational Algebra](https://www.hackerrank.com/domains/databases/relational-algebra)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Basics of Sets and Relations #1](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-1)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-1.txt)|Easy
[Basics of Sets and Relations #2](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-2)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-2.txt)|Easy
[Basics of Sets and Relations #3](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-3)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-3.txt)|Easy
[Basics of Sets and Relations #4](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-4)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-4.txt)|Easy
[Basics of Sets and Relations #5](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-5)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-5.txt)|Easy
[Basics of Sets and Relations #6](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-6)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-6.txt)|Easy
[Basics of Sets and Relations #7](https://www.hackerrank.com/challenges/basics-of-sets-and-relational-algebra-7)|Problems based on the basics of sets and relations.|[text](basics-of-sets-and-relational-algebra-7.txt)|Easy
[Relational Algebra - 3](https://www.hackerrank.com/challenges/relational-algebra-3)|Relational Algebra - 3|[text](relational-algebra-3.txt)|Easy
[Relational Algebra - 4](https://www.hackerrank.com/challenges/relational-algebra-4)|Relational Algebra - 4|[text](relational-algebra-4.txt)|Easy
[Database Query Languages](https://www.hackerrank.com/challenges/database-query-languages)|Database Query Languages|[text](database-query-languages.txt)|Easy
[Procedural Language](https://www.hackerrank.com/challenges/procedural-language)|Procedural Language|[text](procedural-language.txt)|Easy
[Relations - 1](https://www.hackerrank.com/challenges/relations-1)|Relations - 1|[text](relations-1.txt)|Easy
[Relations - 2](https://www.hackerrank.com/challenges/relations-2)|Relations - 2|[text](relations-2.txt)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Databases > Database Normalization > Database Normalization #1 - 1NF
# The first normal form.
#
# https://www.hackerrank.com/challenges/database-normalization-1-1nf/problem
#
3
5
2
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Databases](https://www.hackerrank.com/domains/databases)
Check your Database skills
#### [Database Normalization](https://www.hackerrank.com/domains/databases/database-normalization)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Database Normalization #1 - 1NF](https://www.hackerrank.com/challenges/database-normalization-1-1nf)|The first normal form.|[text](database-normalization-1-1nf.txt)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_subdirectory(re-introduction)
add_subdirectory(re-character-class)
add_subdirectory(re-repetitions)
add_subdirectory(grouping-and-capturing)
add_subdirectory(backreferences)
add_subdirectory(assertions)
add_subdirectory(re-applications)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Introduction](https://www.hackerrank.com/domains/regex/re-introduction)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Specific String](https://www.hackerrank.com/challenges/matching-specific-string)|Match a specific string using regex.|[Python](re-introduction/matching-specific-string.py)|Easy
[Matching Anything But a Newline](https://www.hackerrank.com/challenges/matching-anything-but-new-line)|Use [.] in the regex expression to match anything but a newline character.|[Python](re-introduction/matching-anything-but-new-line.py)|Easy
[Matching Digits & Non-Digit Characters](https://www.hackerrank.com/challenges/matching-digits-non-digit-character)|Use the expression \d to match digits and \D to match non-digit characters.|[Python](re-introduction/matching-digits-non-digit-character.py)|Easy
[Matching Whitespace & Non-Whitespace Character](https://www.hackerrank.com/challenges/matching-whitespace-non-whitespace-character)|Use \s to match whitespace and \S to match non whitespace characters in this challenge.|[Python](re-introduction/matching-whitespace-non-whitespace-character.py)|Easy
[Matching Word & Non-Word Character](https://www.hackerrank.com/challenges/matching-word-non-word)|Use \w to match any word and \W to match any non-word character.|[Python](re-introduction/matching-word-non-word.py)|Easy
[Matching Start & End](https://www.hackerrank.com/challenges/matching-start-end)|Use the ^ symbol to match the start of a string, and the $ symbol to match the end characters.|[Python](re-introduction/matching-start-end.py)|Easy
#### [Character Class](https://www.hackerrank.com/domains/regex/re-character-class)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Specific Characters](https://www.hackerrank.com/challenges/matching-specific-characters)|Use the [ ] expression to match specific characters.|[Python](re-character-class/matching-specific-characters.py)|Easy
[Excluding Specific Characters](https://www.hackerrank.com/challenges/excluding-specific-characters)|Use the [^] character class to exclude specific characters.|[Python](re-character-class/excluding-specific-characters.py)|Easy
[Matching Character Ranges](https://www.hackerrank.com/challenges/matching-range-of-characters)|Write a RegEx matching a range of characters.|[Python](re-character-class/matching-range-of-characters.py)|Easy
#### [Repetitions](https://www.hackerrank.com/domains/regex/re-repetitions)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching {x} Repetitions](https://www.hackerrank.com/challenges/matching-x-repetitions)|Match exactly x repetitions using the tool {x}.|[Python](re-repetitions/matching-x-repetitions.py)|Easy
[Matching {x, y} Repetitions](https://www.hackerrank.com/challenges/matching-x-y-repetitions)|Match between a range of x and y repetitions using the {x,y} tool.|[Python](re-repetitions/matching-x-y-repetitions.py)|Easy
[Matching Zero Or More Repetitions](https://www.hackerrank.com/challenges/matching-zero-or-more-repetitions)|Match zero or more repetitions of character/character class/group using the * symbol in regex.|[Python](re-repetitions/matching-zero-or-more-repetitions.py)|Easy
[Matching One Or More Repetitions](https://www.hackerrank.com/challenges/matching-one-or-more-repititions)|Match zero or more repetitions of character/character class/group with the + symbol.|[Python](re-repetitions/matching-one-or-more-repititions.py)|Easy
[Matching Ending Items](https://www.hackerrank.com/challenges/matching-ending-items)|Match the end of the string using the $ boundary matcher.|[Python](re-repetitions/matching-ending-items.py)|Easy
#### [Grouping and Capturing](https://www.hackerrank.com/domains/regex/grouping-and-capturing)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Word Boundaries](https://www.hackerrank.com/challenges/matching-word-boundaries)|Using \b to match word boundaries.|[Python](grouping-and-capturing/matching-word-boundaries.py)|Easy
[Capturing & Non-Capturing Groups](https://www.hackerrank.com/challenges/capturing-non-capturing-groups)|Creating capturing and non-capturing group.|[Python](grouping-and-capturing/capturing-non-capturing-groups.py)|Easy
[Alternative Matching](https://www.hackerrank.com/challenges/alternative-matching)|Matching single regex out of several regex.|[Python](grouping-and-capturing/alternative-matching.py)|Easy
#### [Backreferences](https://www.hackerrank.com/domains/regex/backreferences)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Same Text Again & Again](https://www.hackerrank.com/challenges/matching-same-text-again-again)|Match the same text as previously matched by the capturing group.|[Python](backreferences/matching-same-text-again-again.py)|Easy
[Backreferences To Failed Groups](https://www.hackerrank.com/challenges/backreferences-to-failed-groups)|Backreference to a capturing group that match nothing.|[Python](backreferences/backreferences-to-failed-groups.py)|Easy
[Branch Reset Groups](https://www.hackerrank.com/challenges/branch-reset-groups)|Alternatives having same capturing group|[Perl](backreferences/branch-reset-groups.pl)|Easy
[Forward References](https://www.hackerrank.com/challenges/forward-references)|Back reference to a group which appear later in regex.|[Java](backreferences/forward-references.java)|Easy
#### [Assertions](https://www.hackerrank.com/domains/regex/assertions)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Positive Lookahead](https://www.hackerrank.com/challenges/positive-lookahead)|A positive lookahead asserts the regex to match if the regexp ahead is matching.|[Python](assertions/positive-lookahead.py)|Easy
[Negative Lookahead](https://www.hackerrank.com/challenges/negative-lookahead)|It asserts the regex to match if regexp ahead is not matching.|[Python](assertions/negative-lookahead.py)|Easy
[Positive Lookbehind](https://www.hackerrank.com/challenges/positive-lookbehind)|It asserts the regex to match if regexp behind is matching.|[Python](assertions/positive-lookbehind.py)|Easy
[Negative Lookbehind](https://www.hackerrank.com/challenges/negative-lookbehind)|It asserts the regex to match if regexp behind is not matching.|[Python](assertions/negative-lookbehind.py)|Easy
#### [Applications](https://www.hackerrank.com/domains/regex/re-applications)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Detect HTML links](https://www.hackerrank.com/challenges/detect-html-links)|Use Regular Expressions to detect links in a given HTML fragment.|[Python](re-applications/detect-html-links.py)|Medium
[Detect HTML Tags](https://www.hackerrank.com/challenges/detect-html-tags)|Given N lines of HTML source, print the HTML tags found within it.|[Python](re-applications/detect-html-tags.py)|Easy
[Find A Sub-Word](https://www.hackerrank.com/challenges/find-substring)|Use RegEx to count the number of times a sub-word appears in a given set of sentences.|[Python](re-applications/find-substring.py)|Easy
[Alien Username](https://www.hackerrank.com/challenges/alien-username)|Validate the usernames from an alien planet.|[Python](re-applications/alien-username.py)|Easy
[IP Address Validation](https://www.hackerrank.com/challenges/ip-address-validation)|Validate possible IP Addresses with regex.|[Python](re-applications/ip-address-validation.py)|Easy
[Find a Word](https://www.hackerrank.com/challenges/find-a-word)|Find a given word in a sentence using regex special characters.|[Python](re-applications/find-a-word.py)|Medium
[Detect the Email Addresses](https://www.hackerrank.com/challenges/detect-the-email-addresses)|Use Regular Expressions to detect the email addresses embedded in a given chunk of text.|[Python](re-applications/detect-the-email-addresses.py)|Medium
[Detect the Domain Name](https://www.hackerrank.com/challenges/detect-the-domain-name)|Use Regular Expressions to detect domain names from a chunk of HTML Markup provided to you.|[Python](re-applications/detect-the-domain-name.py)|Medium
[Building a Smart IDE: Identifying comments](https://www.hackerrank.com/challenges/ide-identifying-comments)|A Text Processing Challenge. Identify the comments in program source codes.|[Python](re-applications/ide-identifying-comments.py)|Medium
[Detecting Valid Latitude and Longitude Pairs](https://www.hackerrank.com/challenges/detecting-valid-latitude-and-longitude)|Can you detect the Latitude and Longitude embedded in text snippets, using regular expressions?|[Python](re-applications/detecting-valid-latitude-and-longitude.py)|Easy
[HackerRank Tweets](https://www.hackerrank.com/challenges/hackerrank-tweets)|Write a regex to identify the tweets that has the string *hackerrank* in it|[Python](re-applications/hackerrank-tweets.py)|Easy
[Build a Stack Exchange Scraper](https://www.hackerrank.com/challenges/stack-exchange-scraper)|Use Regular Expression to Scrape Questions from Stack Exchange.|[Python](re-applications/stack-exchange-scraper.py)|Easy
[Utopian Identification Number](https://www.hackerrank.com/challenges/utopian-identification-number)|Can you use regular expressions to check if the Utopian Identification Number is valid or not?|[Python](re-applications/utopian-identification-number.py)|Easy
[Valid PAN format](https://www.hackerrank.com/challenges/valid-pan-format)|Use regex to determine the validity of a given set of characters.|[Python](re-applications/valid-pan-format.py)|Easy
[Find HackerRank](https://www.hackerrank.com/challenges/find-hackerrank)|Write a regex to find out if conversations start/end or both start and end with hackerrank|[Python](re-applications/find-hackerrank.py)|Easy
[Saying Hi](https://www.hackerrank.com/challenges/saying-hi)|Use a regex to print all the lines that start with "hi " but are not immediately followed by a 'd' or 'D'.|[Python](re-applications/saying-hi.py)|Easy
[HackerRank Language](https://www.hackerrank.com/challenges/hackerrank-language)|Use regex if an api request has a valid language string set or not|[Python](re-applications/hackerrank-language.py)|Easy
[Building a Smart IDE: Programming Language Detection](https://www.hackerrank.com/challenges/programming-language-detection)|You are provided with a set of programs in Java, C and Python and you are also told which of the languages each program is in. Now, given a program written in one of these languages, can you identify which of the languages it is written in?|[Python](re-applications/programming-language-detection.py)|Medium
[Split the Phone Numbers](https://www.hackerrank.com/challenges/split-number)|This problem introduces you to the concept of matching groups in regular expressions.|[Python](re-applications/split-number.py)|Easy
[Detect HTML Attributes](https://www.hackerrank.com/challenges/html-attributes)|Use Regular Expressions to detect HTML Attributes corresponding to various tags.|[Python](re-applications/html-attributes.py)|Easy
[The British and American Style of Spelling](https://www.hackerrank.com/challenges/uk-and-us)|Use regular expression to find the count of a given word that ends with either *ze* or *se*|[Python](re-applications/uk-and-us.py)|Easy
[UK and US: Part 2](https://www.hackerrank.com/challenges/uk-and-us-2)|Use regular expression to count the number of occurrences of a given word with either *our* or *or* in it.|[Python](re-applications/uk-and-us-2.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Find a Word
# Find a given word in a sentence using regex special characters.
#
# https://www.hackerrank.com/challenges/find-a-word/problem
# challenge id: 733
#
import re
s = " ".join(input() for _ in range(int(input())))
for _ in range(int(input())):
w = input()
print(len(re.findall(r"(^|(?<=\W))" + w + r"(?=\W)", s, re.I)))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detecting Valid Latitude and Longitude Pairs
# Can you detect the Latitude and Longitude embedded in text snippets, using regular expressions?
#
# https://www.hackerrank.com/challenges/detecting-valid-latitude-and-longitude/problem
# https://www.hackerrank.com/contests/regex-practice-1/challenges/detecting-valid-latitude-and-longitude
# challenge id: 1086
#
import re
for _ in range(int(input())):
s = input()
ok = re.match(r'''
^\( # ( au début
[+-]? # signe optionnel
(90(\.0+)? # 90 ou 90.0000...
| ( ([0-9]|[0-8][0-9]) # 0 à 89
(\.\d+)? # .1234567890
)
)
,\s? # ", " ou ","
[+-]? # signe optionnel
(180(\.0+)? # 180 ou 180.000...
| ( ([0-9]|[1-9][0-9]|1[0-7][0-9]) # 0 à 179
(\.\d+)? # décimales
)
)
\)$ # ) finale
''', s, re.VERBOSE)
print('Valid' if ok else 'Invalid')
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > UK and US: Part 2
# Use regular expression to count the number of occurrences of a given word with either *our* or *or* in it.
#
# https://www.hackerrank.com/challenges/uk-and-us-2/problem
# challenge id: 718
#
import re
words = (' '.join(input() for _ in range(int(input())))).lower().split()
for _ in range(int(input())):
s = input().lower()
us = re.sub(r'(\w+)(ou?r)(\w*)', r'\1or\3', s)
uk = re.sub(r'(\w+)(ou?r)(\w*)', r'\1our\3', s)
count = 0
for w in words:
if us == w or uk == w:
count += 1
print(count)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Build a Stack Exchange Scraper
# Use Regular Expression to Scrape Questions from Stack Exchange.
#
# https://www.hackerrank.com/challenges/stack-exchange-scraper/problem
# https://www.hackerrank.com/contests/regex-practice-2/challenges/stack-exchange-scraper
# challenge id: 849
#
import re
import sys
s = sys.stdin.read()
m = re.findall(r'''
href="/questions/(\d+)/.*?class="question-hyperlink">(.+?)</a>
.*?
class="relativetime">(.+?)</span>
''', s, re.MULTILINE | re.VERBOSE | re.DOTALL)
for i in m:
print(';'.join(i))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > HackerRank Tweets
# Write a regex to identify the tweets that has the string *hackerrank* in it
#
# https://www.hackerrank.com/challenges/hackerrank-tweets/problem
# https://www.hackerrank.com/contests/regex-practice-2/challenges/hackerrank-tweets
# challenge id: 714
#
import re
n = 0
for _ in range(int(input())):
if re.search(r'\bhackerrank\b', input(), re.I):
n += 1
print(n)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Valid PAN format
# Use regex to determine the validity of a given set of characters.
#
# https://www.hackerrank.com/challenges/valid-pan-format/problem
# challenge id: 712
#
import re
for _ in range(int(input())):
s = input()
# <char><char><char><char><char><digit><digit><digit><digit><char>
ok = re.match(r'''
^
[A-Z]{5} # <char><char><char><char><char>
\d{4} # <digit><digit><digit><digit>
[A-Z]{1} # <char>
$
''', s, re.VERBOSE)
print("YES" if ok else "NO")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detect HTML Tags
# Given N lines of HTML source, print the HTML tags found within it.
#
# https://www.hackerrank.com/challenges/detect-html-tags/problem
# https://www.hackerrank.com/contests/regex-practice-2/challenges/detect-html-tags
# challenge id: 722
#
import re
html = ''.join([input() for _ in range(int(input()))])
find_tags = r'<\s*(\w+).*?>'
match = re.findall(find_tags, html, re.I)
if bool(match):
print(';'.join(sorted(set(tag for tag in match))))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detect the Email Addresses
# Use Regular Expressions to detect the email addresses embedded in a given chunk of text.
#
# https://www.hackerrank.com/challenges/detect-the-email-addresses/problem
# challenge id: 895
#
import re
ad = []
for _ in range(int(input())):
s = input()
a = re.findall(r"\b[\w\.]+@(?:\w+\.)+\w+\b", s)
ad.extend(a)
print(';'.join(sorted(set(ad))))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Split the Phone Numbers
# This problem introduces you to the concept of matching groups in regular expressions.
#
# https://www.hackerrank.com/challenges/split-number/problem
# challenge id: 711
#
import re
for _ in range(int(input())):
s = input()
m = re.match(r'''
(\d{1,3})[\s\-]
(\d{1,3})[\s\-]
(\d{4,10})
''', s, re.VERBOSE)
CountryCode, LocalAreaCode, Number = m.group(1), m.group(2), m.group(3)
print('CountryCode={},LocalAreaCode={},Number={}'.format(CountryCode, LocalAreaCode, Number))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Building a Smart IDE: Programming Language Detection
# You are provided with a set of programs in Java, C and Python and you are also told which of the languages each program is in. Now, given a program written in one of these languages, can you identify which of the languages it is written in?
#
# https://www.hackerrank.com/challenges/programming-language-detection/problem
# challenge id: 672
#
import sys
src = sys.stdin.read()
if '#include' in src:
print("C")
elif 'import java' in src:
print("Java")
else:
print("Python")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Saying Hi
# Use a regex to print all the lines that start with "hi " but are not immediately followed by a 'd' or 'D'.
#
# https://www.hackerrank.com/challenges/saying-hi/problem
# challenge id: 713
#
import re
for _ in range(int(input())):
s = input()
if re.match(r"^hi\s[^d]", s, re.I):
print(s)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detect the Domain Name
# Use Regular Expressions to detect domain names from a chunk of HTML Markup provided to you.
#
# https://www.hackerrank.com/challenges/detect-the-domain-name/problem
# challenge id: 894
#
import re
ad = []
for _ in range(int(input())):
s = input()
a = re.findall(r"""https?://(?:ww[w2]\.){0,1}([\w\d\-\.]*\.\w+)[/?"]""", s)
ad.extend(a)
print(';'.join(sorted(set(ad))))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Alien Username
# Validate the usernames from an alien planet.
#
# https://www.hackerrank.com/challenges/alien-username/problem
# challenge id: 720
#
import re
for _ in range(int(input())):
s = input()
ok = re.match(r"^[_\.]\d+[a-z]*_?$", s, re.I)
print("VALID" if ok else "INVALID")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(uk-and-us.py)
add_hackerrank_py(detect-html-links.py)
add_hackerrank_py(detect-html-tags.py)
add_hackerrank_py(ip-address-validation.py)
add_hackerrank_py(find-substring.py)
add_hackerrank_py(alien-username.py)
add_hackerrank_py(find-a-word.py)
add_hackerrank_py(saying-hi.py)
add_hackerrank_py(detect-the-email-addresses.py)
add_hackerrank_py(detect-the-domain-name.py)
add_hackerrank_py(ide-identifying-comments.py)
add_hackerrank_py(detecting-valid-latitude-and-longitude.py)
add_hackerrank_py(hackerrank-tweets.py)
add_hackerrank_py(stack-exchange-scraper.py)
add_hackerrank_py(utopian-identification-number.py)
add_hackerrank_py(valid-pan-format.py)
add_hackerrank_py(find-hackerrank.py)
add_hackerrank_py(hackerrank-language.py)
add_hackerrank_py(split-number.py)
add_hackerrank_py(uk-and-us-2.py)
add_hackerrank_py(html-attributes.py)
add_hackerrank_py(programming-language-detection.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Utopian Identification Number
# Can you use regular expressions to check if the Utopian Identification Number is valid or not?
#
# https://www.hackerrank.com/challenges/utopian-identification-number/problem
# challenge id: 721
#
import re
for _ in range(int(input())):
s = input()
ok = re.match(r'''
^
[a-z]{0,3} # The string must begin with between 0-3 (inclusive) lowercase letters
\d{2,8} # sequence of digits, length between 2 and 8
[A-Z]{3,} # 3 uppercase letters or more
$
''', s, re.VERBOSE)
print("VALID" if ok else "INVALID")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Find A Sub-Word
# Use RegEx to count the number of times a sub-word appears in a given set of sentences.
#
# https://www.hackerrank.com/challenges/find-substring/problem
# challenge id: 734
#
import re
s = " ".join(input() for _ in range(int(input())))
for _ in range(int(input())):
sw = input()
print(len(re.findall(r"\b[\d\w]+" + sw + r"[\d\w]+\b", s)))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detect HTML Attributes
# Use Regular Expressions to detect HTML Attributes corresponding to various tags.
#
# https://www.hackerrank.com/challenges/html-attributes/problem
# https://www.hackerrank.com/contests/codesprint-practice/challenges/html-attributes
# challenge id: 724
#
import sys
import re
s = ' '.join(input() for _ in range(int(input())))
tags = {}
for tag, p in re.findall(r'<(\w+)\s?(.*?)>', s):
attr = set(a for a in re.findall(r'(\w+)=[\'\"]', p))
if tag not in tags:
tags[tag] = attr
else:
tags[tag] |= attr
for tag in sorted(tags.keys()):
print(tag + ':' + ','.join(sorted(tags[tag])))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > The British and American Style of Spelling
# Use regular expression to find the count of a given word that ends with either *ze* or *se*
#
# https://www.hackerrank.com/challenges/uk-and-us/problem
# challenge id: 710
#
import re
text = ''
for _ in range(int(input())):
text += input() + ' '
for _ in range(int(input())):
w = input()
print(len(re.findall(w[:len(w) - 2] + r'[sz]e\b', text)))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Detect HTML links
# Use Regular Expressions to detect links in a given HTML fragment.
#
# https://www.hackerrank.com/challenges/detect-html-links/problem
# challenge id: 725
#
import re
html = ''.join([input() for _ in range(int(input()))])
find_href = r'<a\s+href="(.*?)".*?>(.*?)</a>'
remove_tags = r'</?(\w+).*?>'
match = re.findall(find_href, html, re.I)
if bool(match):
for link, title in match:
title = re.sub(remove_tags, "", title)
print(link + ',' + title.strip())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > IP Address Validation
# Validate possible IP Addresses with regex.
#
# https://www.hackerrank.com/challenges/ip-address-validation/problem
# https://www.hackerrank.com/contests/programming-interviews-practice-session/challenges/ip-address-validation
# challenge id: 896
#
import re
def check_ip(a):
m = re.match(r"^(\d+)\.(\d+)\.(\d+).(\d+)$", a)
if m:
if all(map(lambda x: 0 <= int(x) <= 255, m.groups())):
return "IPv4"
else:
m = re.match(r"^([a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$", a, re.I)
if m:
return "IPv6"
return "Neither"
for _ in range(int(input())):
print(check_ip(input()))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Building a Smart IDE: Identifying comments
# A Text Processing Challenge. Identify the comments in program source codes.
#
# https://www.hackerrank.com/challenges/ide-identifying-comments/problem
# https://www.hackerrank.com/contests/regex-practice-1/challenges/ide-identifying-comments
# challenge id: 670
#
import re
import sys
s = sys.stdin.read()
p = r'(/\*.*?\*/|//.*?$)'
for i in re.findall(p, s, re.DOTALL | re.MULTILINE):
for j in re.split(r'\n', i):
print(j.strip())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > HackerRank Language
# Use regex if an api request has a valid language string set or not
#
# https://www.hackerrank.com/challenges/hackerrank-language/problem
# https://www.hackerrank.com/contests/regex-practice-2/challenges/hackerrank-language
# challenge id: 715
#
L = "C:CPP:JAVA:PYTHON:PERL:PHP:RUBY:CSHARP:HASKELL:CLOJURE:BASH:SCALA:ERLANG:CLISP:LUA:BRAINFUCK:JAVASCRIPT:GO:D:OCAML:R:PASCAL:SBCL:DART:GROOVY:OBJECTIVEC".split(':')
for _ in range(int(input())):
ok = input().split()[1].upper() in L
print("VALID" if ok else "INVALID")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Applications > Find HackerRank
# Write a regex to find out if conversations start/end or both start and end with hackerrank
#
# https://www.hackerrank.com/challenges/find-hackerrank/problem
# challenge id: 709
#
import re
for _ in range(int(input())):
s = input().lower()
a = s.startswith('hackerrank')
b = s.endswith('hackerrank')
if a and b:
print(0)
elif a:
print(1)
elif b:
print(2)
else:
print(-1)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Applications](https://www.hackerrank.com/domains/regex/re-applications)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Detect HTML links](https://www.hackerrank.com/challenges/detect-html-links)|Use Regular Expressions to detect links in a given HTML fragment.|[Python](detect-html-links.py)|Medium
[Detect HTML Tags](https://www.hackerrank.com/challenges/detect-html-tags)|Given N lines of HTML source, print the HTML tags found within it.|[Python](detect-html-tags.py)|Easy
[Find A Sub-Word](https://www.hackerrank.com/challenges/find-substring)|Use RegEx to count the number of times a sub-word appears in a given set of sentences.|[Python](find-substring.py)|Easy
[Alien Username](https://www.hackerrank.com/challenges/alien-username)|Validate the usernames from an alien planet.|[Python](alien-username.py)|Easy
[IP Address Validation](https://www.hackerrank.com/challenges/ip-address-validation)|Validate possible IP Addresses with regex.|[Python](ip-address-validation.py)|Easy
[Find a Word](https://www.hackerrank.com/challenges/find-a-word)|Find a given word in a sentence using regex special characters.|[Python](find-a-word.py)|Medium
[Detect the Email Addresses](https://www.hackerrank.com/challenges/detect-the-email-addresses)|Use Regular Expressions to detect the email addresses embedded in a given chunk of text.|[Python](detect-the-email-addresses.py)|Medium
[Detect the Domain Name](https://www.hackerrank.com/challenges/detect-the-domain-name)|Use Regular Expressions to detect domain names from a chunk of HTML Markup provided to you.|[Python](detect-the-domain-name.py)|Medium
[Building a Smart IDE: Identifying comments](https://www.hackerrank.com/challenges/ide-identifying-comments)|A Text Processing Challenge. Identify the comments in program source codes.|[Python](ide-identifying-comments.py)|Medium
[Detecting Valid Latitude and Longitude Pairs](https://www.hackerrank.com/challenges/detecting-valid-latitude-and-longitude)|Can you detect the Latitude and Longitude embedded in text snippets, using regular expressions?|[Python](detecting-valid-latitude-and-longitude.py)|Easy
[HackerRank Tweets](https://www.hackerrank.com/challenges/hackerrank-tweets)|Write a regex to identify the tweets that has the string *hackerrank* in it|[Python](hackerrank-tweets.py)|Easy
[Build a Stack Exchange Scraper](https://www.hackerrank.com/challenges/stack-exchange-scraper)|Use Regular Expression to Scrape Questions from Stack Exchange.|[Python](stack-exchange-scraper.py)|Easy
[Utopian Identification Number](https://www.hackerrank.com/challenges/utopian-identification-number)|Can you use regular expressions to check if the Utopian Identification Number is valid or not?|[Python](utopian-identification-number.py)|Easy
[Valid PAN format](https://www.hackerrank.com/challenges/valid-pan-format)|Use regex to determine the validity of a given set of characters.|[Python](valid-pan-format.py)|Easy
[Find HackerRank](https://www.hackerrank.com/challenges/find-hackerrank)|Write a regex to find out if conversations start/end or both start and end with hackerrank|[Python](find-hackerrank.py)|Easy
[Saying Hi](https://www.hackerrank.com/challenges/saying-hi)|Use a regex to print all the lines that start with "hi " but are not immediately followed by a 'd' or 'D'.|[Python](saying-hi.py)|Easy
[HackerRank Language](https://www.hackerrank.com/challenges/hackerrank-language)|Use regex if an api request has a valid language string set or not|[Python](hackerrank-language.py)|Easy
[Building a Smart IDE: Programming Language Detection](https://www.hackerrank.com/challenges/programming-language-detection)|You are provided with a set of programs in Java, C and Python and you are also told which of the languages each program is in. Now, given a program written in one of these languages, can you identify which of the languages it is written in?|[Python](programming-language-detection.py)|Medium
[Split the Phone Numbers](https://www.hackerrank.com/challenges/split-number)|This problem introduces you to the concept of matching groups in regular expressions.|[Python](split-number.py)|Easy
[Detect HTML Attributes](https://www.hackerrank.com/challenges/html-attributes)|Use Regular Expressions to detect HTML Attributes corresponding to various tags.|[Python](html-attributes.py)|Easy
[The British and American Style of Spelling](https://www.hackerrank.com/challenges/uk-and-us)|Use regular expression to find the count of a given word that ends with either *ze* or *se*|[Python](uk-and-us.py)|Easy
[UK and US: Part 2](https://www.hackerrank.com/challenges/uk-and-us-2)|Use regular expression to count the number of occurrences of a given word with either *our* or *or* in it.|[Python](uk-and-us-2.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Grouping and Capturing > Matching Word Boundaries
# Using \b to match word boundaries.
#
# https://www.hackerrank.com/challenges/matching-word-boundaries/problem
# challenge id: 14619
#
Regex_Pattern = r'\b[aeiouAEIOU][a-zA-Z]*\b' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Grouping and Capturing > Capturing & Non-Capturing Groups
# Creating capturing and non-capturing group.
#
# https://www.hackerrank.com/challenges/capturing-non-capturing-groups/problem
# challenge id: 14621
#
Regex_Pattern = r'(?:ok){3,}' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(matching-word-boundaries.py)
add_hackerrank_py(capturing-non-capturing-groups.py)
add_hackerrank_py(alternative-matching.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Grouping and Capturing > Alternative Matching
# Matching single regex out of several regex.
#
# https://www.hackerrank.com/challenges/alternative-matching/problem
# challenge id: 14623
#
Regex_Pattern = r'^(Mr|Ms|Mrs|Dr|Er)\.[a-zA-Z]+$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Grouping and Capturing](https://www.hackerrank.com/domains/regex/grouping-and-capturing)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Word Boundaries](https://www.hackerrank.com/challenges/matching-word-boundaries)|Using \b to match word boundaries.|[Python](matching-word-boundaries.py)|Easy
[Capturing & Non-Capturing Groups](https://www.hackerrank.com/challenges/capturing-non-capturing-groups)|Creating capturing and non-capturing group.|[Python](capturing-non-capturing-groups.py)|Easy
[Alternative Matching](https://www.hackerrank.com/challenges/alternative-matching)|Matching single regex out of several regex.|[Python](alternative-matching.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Assertions > Negative Lookahead
# It asserts the regex to match if regexp ahead is not matching.
#
# https://www.hackerrank.com/challenges/negative-lookahead/problem
# challenge id: 14902
#
Regex_Pattern = r"(.)(?!\1)" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
Test_String = input()
match = re.findall(Regex_Pattern, Test_String)
print("Number of matches :", len(match))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Assertions > Positive Lookahead
# A positive lookahead asserts the regex to match if the regexp ahead is matching.
#
# https://www.hackerrank.com/challenges/positive-lookahead/problem
# https://www.hackerrank.com/contests/regular-expresso/challenges/positive-lookahead
# challenge id: 14901
#
Regex_Pattern = r'o(?=oo)' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
Test_String = input()
match = re.findall(Regex_Pattern, Test_String)
print("Number of matches :", len(match))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(positive-lookahead.py)
add_hackerrank_py(negative-lookahead.py)
add_hackerrank_py(positive-lookbehind.py)
add_hackerrank_py(negative-lookbehind.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Assertions > Positive Lookbehind
# It asserts the regex to match if regexp behind is matching.
#
# https://www.hackerrank.com/challenges/positive-lookbehind/problem
# challenge id: 14903
#
Regex_Pattern = r"(?<=[13579])\d" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
Test_String = input()
match = re.findall(Regex_Pattern, Test_String)
print("Number of matches :", len(match))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Assertions](https://www.hackerrank.com/domains/regex/assertions)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Positive Lookahead](https://www.hackerrank.com/challenges/positive-lookahead)|A positive lookahead asserts the regex to match if the regexp ahead is matching.|[Python](positive-lookahead.py)|Easy
[Negative Lookahead](https://www.hackerrank.com/challenges/negative-lookahead)|It asserts the regex to match if regexp ahead is not matching.|[Python](negative-lookahead.py)|Easy
[Positive Lookbehind](https://www.hackerrank.com/challenges/positive-lookbehind)|It asserts the regex to match if regexp behind is matching.|[Python](positive-lookbehind.py)|Easy
[Negative Lookbehind](https://www.hackerrank.com/challenges/negative-lookbehind)|It asserts the regex to match if regexp behind is not matching.|[Python](negative-lookbehind.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Assertions > Negative Lookbehind
# It asserts the regex to match if regexp behind is not matching.
#
# https://www.hackerrank.com/challenges/negative-lookbehind/problem
# challenge id: 14904
#
Regex_Pattern = r"(?<![aeiouAEIOU])." # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
Test_String = input()
match = re.findall(Regex_Pattern, Test_String)
print("Number of matches :", len(match))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(matching-specific-characters.py)
add_hackerrank_py(excluding-specific-characters.py)
add_hackerrank_py(matching-range-of-characters.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Character Class > Excluding Specific Characters
# Use the [^] character class to exclude specific characters.
#
# https://www.hackerrank.com/challenges/excluding-specific-characters/problem
# challenge id: 14273
#
Regex_Pattern = r'^\D[^aeiou][^bcDF]\S[^AEIOU][^\.,]$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Character Class > Matching Specific Characters
# Use the [ ] expression to match specific characters.
#
# https://www.hackerrank.com/challenges/matching-specific-characters/problem
# challenge id: 14272
#
Regex_Pattern = r'^[123][012][xs0][30Aa][xsu][\.,]$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Character Class > Matching Character Ranges
# Write a RegEx matching a range of characters.
#
# https://www.hackerrank.com/challenges/matching-range-of-characters/problem
# challenge id: 14274
#
Regex_Pattern = r'^[a-z][1-9][^a-z][^A-Z][A-Z]' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Character Class](https://www.hackerrank.com/domains/regex/re-character-class)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Specific Characters](https://www.hackerrank.com/challenges/matching-specific-characters)|Use the [ ] expression to match specific characters.|[Python](matching-specific-characters.py)|Easy
[Excluding Specific Characters](https://www.hackerrank.com/challenges/excluding-specific-characters)|Use the [^] character class to exclude specific characters.|[Python](excluding-specific-characters.py)|Easy
[Matching Character Ranges](https://www.hackerrank.com/challenges/matching-range-of-characters)|Write a RegEx matching a range of characters.|[Python](matching-range-of-characters.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Repetitions > Matching {x} Repetitions
# Match exactly x repetitions using the tool {x}.
#
# https://www.hackerrank.com/challenges/matching-x-repetitions/problem
# challenge id: 14525
#
Regex_Pattern = r'^[a-zA-Z02468]{40}[13579\s]{5}$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Repetitions > Matching {x, y} Repetitions
# Match between a range of x and y repetitions using the {x,y} tool.
#
# https://www.hackerrank.com/challenges/matching-x-y-repetitions/problem
# challenge id: 14522
#
Regex_Pattern = r'^\d{1,2}[A-Za-z]{3,}\.{0,3}$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Repetitions > Matching Ending Items
# Match the end of the string using the $ boundary matcher.
#
# https://www.hackerrank.com/challenges/matching-ending-items/problem
# challenge id: 14620
#
Regex_Pattern = r'^[a-zA-Z]*s$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Repetitions > Matching Zero Or More Repetitions
# Match zero or more repetitions of character/character class/group using the * symbol in regex.
#
# https://www.hackerrank.com/challenges/matching-zero-or-more-repetitions/problem
# challenge id: 14523
#
Regex_Pattern = r'^\d\d\d*[a-z]*[A-Z]*$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(matching-x-repetitions.py)
add_hackerrank_py(matching-x-y-repetitions.py)
add_hackerrank_py(matching-zero-or-more-repetitions.py)
add_hackerrank_py(matching-one-or-more-repititions.py)
add_hackerrank_py(matching-ending-items.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Repetitions > Matching One Or More Repetitions
# Match zero or more repetitions of character/character class/group with the + symbol.
#
# https://www.hackerrank.com/challenges/matching-one-or-more-repititions/problem
# challenge id: 14524
#
Regex_Pattern = r'^\d+[A-Z]+[a-z]+$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Repetitions](https://www.hackerrank.com/domains/regex/re-repetitions)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching {x} Repetitions](https://www.hackerrank.com/challenges/matching-x-repetitions)|Match exactly x repetitions using the tool {x}.|[Python](matching-x-repetitions.py)|Easy
[Matching {x, y} Repetitions](https://www.hackerrank.com/challenges/matching-x-y-repetitions)|Match between a range of x and y repetitions using the {x,y} tool.|[Python](matching-x-y-repetitions.py)|Easy
[Matching Zero Or More Repetitions](https://www.hackerrank.com/challenges/matching-zero-or-more-repetitions)|Match zero or more repetitions of character/character class/group using the * symbol in regex.|[Python](matching-zero-or-more-repetitions.py)|Easy
[Matching One Or More Repetitions](https://www.hackerrank.com/challenges/matching-one-or-more-repititions)|Match zero or more repetitions of character/character class/group with the + symbol.|[Python](matching-one-or-more-repititions.py)|Easy
[Matching Ending Items](https://www.hackerrank.com/challenges/matching-ending-items)|Match the end of the string using the $ boundary matcher.|[Python](matching-ending-items.py)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Backreferences > Backreferences To Failed Groups
# Backreference to a capturing group that match nothing.
#
# https://www.hackerrank.com/challenges/backreferences-to-failed-groups/problem
# challenge id: 14743
#
Regex_Pattern = r"^\d\d(-?)\d\d\1\d\d\1\d\d$" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Backreferences > Matching Same Text Again & Again
# Match the same text as previously matched by the capturing group.
#
# https://www.hackerrank.com/challenges/matching-same-text-again-again/problem
# https://www.hackerrank.com/contests/regular-expresso/challenges/matching-same-text-again-again
# challenge id: 14740
#
Regex_Pattern = r'^([a-z])(\w)(\s)(\W)(\d)(\D)([A-Z])([a-zA-Z])([aeiouAEIOU])(\S)\1\2\3\4\5\6\7\8\9\10$' # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(matching-same-text-again-again.py)
add_hackerrank_py(backreferences-to-failed-groups.py)
add_hackerrank_java(forward-references.java) | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Backreferences > Branch Reset Groups
# Alternatives having same capturing group
#
# https://www.hackerrank.com/challenges/branch-reset-groups/problem
# challenge id: 14816
#
$Regex_Pattern = '^\d\d(?|(---)|(-)|(:)|(\.))\d\d\1\d\d\1\d\d$';
# (skeliton_tail) ----------------------------------------------------------------------
$Test_String = <STDIN> ;
if($Test_String =~ /$Regex_Pattern/){
print "true";
} else {
print "false";
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// Regex > Backreferences > Forward References
// Back reference to a group which appear later in regex.
//
// https://www.hackerrank.com/challenges/forward-references/problem
// challenge id: 14820
//
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
// (skeliton_head) ----------------------------------------------------------------------
public class Solution {
public static void main(String[] args) {
Regex_Test tester = new Regex_Test();
tester.checker("^(\\2tic|(tac))+$"); // Use \\ instead of using \
}
}
// (skeliton_tail) ----------------------------------------------------------------------
class Regex_Test {
public void checker(String Regex_Pattern){
Scanner Input = new Scanner(System.in);
String Test_String = Input.nextLine();
Pattern p = Pattern.compile(Regex_Pattern);
Matcher m = p.matcher(Test_String);
System.out.println(m.find());
}
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Regex](https://www.hackerrank.com/domains/regex)
Explore the power of regular expressions
#### [Backreferences](https://www.hackerrank.com/domains/regex/backreferences)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Matching Same Text Again & Again](https://www.hackerrank.com/challenges/matching-same-text-again-again)|Match the same text as previously matched by the capturing group.|[Python](matching-same-text-again-again.py)|Easy
[Backreferences To Failed Groups](https://www.hackerrank.com/challenges/backreferences-to-failed-groups)|Backreference to a capturing group that match nothing.|[Python](backreferences-to-failed-groups.py)|Easy
[Branch Reset Groups](https://www.hackerrank.com/challenges/branch-reset-groups)|Alternatives having same capturing group|[Perl](branch-reset-groups.pl)|Easy
[Forward References](https://www.hackerrank.com/challenges/forward-references)|Back reference to a group which appear later in regex.|[Java](forward-references.java)|Easy
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Introduction > Matching Whitespace & Non-Whitespace Character
# Use \s to match whitespace and \S to match non whitespace characters in this challenge.
#
# https://www.hackerrank.com/challenges/matching-whitespace-non-whitespace-character/problem
# challenge id: 14233
#
Regex_Pattern = r"(\S\S\s){2}\S\S" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Introduction > Matching Digits & Non-Digit Characters
# Use the expression \d to match digits and \D to match non-digit characters.
#
# https://www.hackerrank.com/challenges/matching-digits-non-digit-character/problem
# challenge id: 14186
#
Regex_Pattern = r"(\d\d\D){2}\d{4}" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Introduction > Matching Start & End
# Use the ^ symbol to match the start of a string, and the $ symbol to match the end characters.
#
# https://www.hackerrank.com/challenges/matching-start-end/problem
# challenge id: 14268
#
Regex_Pattern = r"^\d\w{4}\.$" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Introduction > Matching Anything But a Newline
# Use [.] in the regex expression to match anything but a newline character.
#
# https://www.hackerrank.com/challenges/matching-anything-but-new-line/problem
# challenge id: 14095
#
regex_pattern = r"^...\....\....\....$" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
import sys
test_string = input()
match = re.match(regex_pattern, test_string) is not None
print(str(match).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Regex > Introduction > Matching Word & Non-Word Character
# Use \w to match any word and \W to match any non-word character.
#
# https://www.hackerrank.com/challenges/matching-word-non-word/problem
# challenge id: 14140
#
Regex_Pattern = r"\w{3}\W\w{10}\W\w{3}" # Do not delete 'r'.
# (skeliton_tail) ----------------------------------------------------------------------
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(matching-specific-string.py)
add_hackerrank_py(matching-anything-but-new-line.py)
add_hackerrank_py(matching-whitespace-non-whitespace-character.py)
add_hackerrank_py(matching-word-non-word.py)
add_hackerrank_py(matching-start-end.py)
add_hackerrank_py(matching-digits-non-digit-character.py)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.