Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions about-me
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ceci est un test conflit
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Challenge B: Credit Card Validator\n",
"\n",
"Description\n",
"\n",
"Your task is to write a program which reads credit card number prints the validation result ‘Valid’ or ‘Invalid’.\n",
"\n",
"A valid credit card has following features:\n",
"\n",
"It should start with 4, 5 or 6\n",
"It should have exactly 16 digits\n",
"It should only consist of digits (0-9)\n",
"It may have digits in groups of 4 and separated by one hyphen \"-\"\n",
"It should NOT use any other separator like ‘ ’,‘_’, etc.\n",
"It should NOT have 4 or more consecutive repeated digits\n",
"Valid Credit Card Numbers:\n",
"\n",
"4343253434463211\n",
"4263525778615786\n",
"5535535535559555\n",
"6344-2389-7542-9163\n",
"Invalid Credit Card Numbers:\n",
"\n",
"42536258796157867\n",
"66266666626662666\n",
"5122-2368-7954 -3214\n",
"44244x4424442444\n",
"0525362587961578"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"\n",
"# Check if sequence starts with 456 and has a total of 16 digits \n",
"# (can be 4 digits separated by -)\n",
"def checkFormat(sequence):\n",
" return re.search('^[456]\\d{15}$|^[456]\\d{3}-\\d{4}-\\d{4}-\\d{4}$', sequence) != None\n",
"\n",
"# Check if sequence dont have 4+ consecutive same digits\n",
"def checkConsecutiveNumbers(sequence):\n",
" return re.search(r\"([0-9])\\1{3,}\", sequence) == None\n",
"\n",
"def validSequence(sequence):\n",
" if checkFormat(sequence) and checkConsecutiveNumbers(sequence):\n",
" return \"Valid\"\n",
" return \"Invalid\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Valid Credit Card Numbers:\n",
"Valid\n",
"Valid\n",
"Valid\n",
"Valid\n",
"Invalid Credit Card Numbers:\n",
"Invalid\n",
"Invalid\n",
"Invalid\n",
"Invalid\n",
"Invalid\n"
]
}
],
"source": [
"\n",
"#sequence = input(\"Please enter a sequence of 16 digits: \")\n",
"\n",
"print('Valid Credit Card Numbers:')\n",
"print(validSequence(\"4343253434463211\"))\n",
"print(validSequence(\"4263525778615786\"))\n",
"print(validSequence(\"5535535535559555\")) \n",
"print(validSequence(\"6344-2389-7542-9163\")) \n",
"\n",
"print('Invalid Credit Card Numbers:')\n",
"print(validSequence(\"42536258796157867\"))\n",
"print(validSequence(\"66266666626662666\"))\n",
"print(validSequence(\"5122-2368-7954 -3214\")) \n",
"print(validSequence(\"44244x4424442444\")) \n",
"print(validSequence(\"0525362587961578\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Les solution listées en restant sur le même fichier:

1/ echo 'Hello World'
2/ mkdir new_dir
3/ rm -rf
4/ cp ./lorem/sed.txt ./lorem-copy
5/ cp ./lorem/*.txt .lorem-copy/
6/ cat ./lorem/sed.txt
7/ cat ./lorem/at.txt
8/ cat ./lorem/lorem.txt
9/ head -3 ./lorem-copy/sed.txt
10/ tail -3 ./lorem-copy/sed.txt
11/ echo $'\nhomo homini lupus'>> ./lorem_copy/sed.txt
12/sed -i -e "s/et/ET/g" ./lorem-copy/at.txt
13/ whoami
14/ echo $user
15/ pwd
16/ ls | grep.txt
17/ wc -l ./lorem/sed.txt
18/ find . -name "lorem*" | wc -l
19/ grep -o "et" at.txt | wc -l (-o = only matching)
20/ grep -o -r 'et' ./*.txt | wc -l

pipe = donne ce que t'as a gauche
Loading