-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
340 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "lists.h" | ||
#include <stdio.h> | ||
|
||
/** | ||
* print_dlistint - print all the elements of a dlistint_t list | ||
* @h: pointer to the start of the linked list | ||
* | ||
* Return: number of nodes | ||
*/ | ||
size_t print_dlistint(const dlistint_t *h) | ||
{ | ||
size_t i; | ||
|
||
for (i = 0; h != NULL; i++) | ||
{ | ||
printf("%d\n", h->n); | ||
h = h->next; | ||
} | ||
return (i); | ||
} |
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 @@ | ||
#include "lists.h" | ||
|
||
/** | ||
* dlistint_len - count the number of nodes in the linked list | ||
* @h: pointer to the beginning of a linked list | ||
* | ||
* Return: number of nodes | ||
*/ | ||
size_t dlistint_len(const dlistint_t *h) | ||
{ | ||
size_t i; | ||
|
||
for (i = 0; h != NULL; i++) | ||
h = h->next; | ||
return (i); | ||
} |
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 @@ | ||
en C Pyfo neZ |
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 @@ | ||
906609 |
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,45 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
/** | ||
* main - generate a key depending on a username for crackme5 | ||
* @argc: number of arguments passed | ||
* @argv: arguments passed to main | ||
* | ||
* Return: 0 on success, 1 on error | ||
*/ | ||
int main(int argc, char *argv[]) | ||
{ | ||
unsigned int i, b; | ||
size_t len, add; | ||
char *l = "A-CHRDw87lNS0E9B2TibgpnMVys5XzvtOGJcYLU+4mjW6fxqZeF3Qa1rPhdKIouk"; | ||
char p[7] = " "; | ||
|
||
if (argc != 2) | ||
{ | ||
printf("Correct usage: ./keygen5 username\n"); | ||
return (1); | ||
} | ||
len = strlen(argv[1]); | ||
p[0] = l[(len ^ 59) & 63]; | ||
for (i = 0, add = 0; i < len; i++) | ||
add += argv[1][i]; | ||
p[1] = l[(add ^ 79) & 63]; | ||
for (i = 0, b = 1; i < len; i++) | ||
b *= argv[1][i]; | ||
p[2] = l[(b ^ 85) & 63]; | ||
for (b = argv[1][0], i = 0; i < len; i++) | ||
if ((char)b <= argv[1][i]) | ||
b = argv[1][i]; | ||
srand(b ^ 14); | ||
p[3] = l[rand() & 63]; | ||
for (b = 0, i = 0; i < len; i++) | ||
b += argv[1][i] * argv[1][i]; | ||
p[4] = l[(b ^ 239) & 63]; | ||
for (b = 0, i = 0; (char)i < argv[1][0]; i++) | ||
b = rand(); | ||
p[5] = l[(b ^ 229) & 63]; | ||
printf("%s\n", p); | ||
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,27 @@ | ||
#include "lists.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* add_dnodeint - add a new node at the beginning of the linked list | ||
* @head: double pointer to the beginning of the linked list | ||
* @n: value to add to the new node | ||
* | ||
* Return: pointer to the new node, or NULL on failure | ||
*/ | ||
dlistint_t *add_dnodeint(dlistint_t **head, const int n) | ||
{ | ||
dlistint_t *new; | ||
|
||
if (head == NULL) | ||
return (NULL); | ||
new = malloc(sizeof(dlistint_t)); | ||
if (new == NULL) | ||
return (NULL); | ||
new->n = n; | ||
new->prev = NULL; | ||
new->next = *head; | ||
*head = new; | ||
if (new->next != NULL) | ||
(new->next)->prev = new; | ||
return (new); | ||
} |
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,34 @@ | ||
#include "lists.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* add_dnodeint_end - adds a node to the end of a linked list | ||
* @head: double pointer to the beginning of the linked list | ||
* @n: value to add to new node | ||
* | ||
* Return: pointer to the new node, or NULL on failure | ||
*/ | ||
dlistint_t *add_dnodeint_end(dlistint_t **head, const int n) | ||
{ | ||
dlistint_t *new, *tmp; | ||
|
||
if (head == NULL) | ||
return (NULL); | ||
new = malloc(sizeof(dlistint_t)); | ||
if (new == NULL) | ||
return (NULL); | ||
new->n = n; | ||
new->next = NULL; | ||
if (*head == NULL) | ||
{ | ||
new->prev = NULL; | ||
*head = new; | ||
return (new); | ||
} | ||
tmp = *head; | ||
while (tmp->next != NULL) | ||
tmp = tmp->next; | ||
tmp->next = new; | ||
new->prev = tmp; | ||
return (new); | ||
} |
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,20 @@ | ||
#include "lists.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* free_dlistint - free a dlistint_t list | ||
* @head: pointer to the beginning of the linked list | ||
* | ||
* Return: void | ||
*/ | ||
void free_dlistint(dlistint_t *head) | ||
{ | ||
dlistint_t *next; | ||
|
||
while (head != NULL) | ||
{ | ||
next = head->next; | ||
free(head); | ||
head = next; | ||
} | ||
} |
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,25 @@ | ||
#include "lists.h" | ||
|
||
/** | ||
* get_dnodeint_at_index - finds a specific node of a linked list | ||
* @head: pointer to the beginning of the list | ||
* @index: index of the node to retrieve | ||
* | ||
* Return: pointer to the indexed node, or NULL on failure | ||
*/ | ||
dlistint_t *get_dnodeint_at_index(dlistint_t *head, unsigned int index) | ||
{ | ||
unsigned int i; | ||
|
||
if (head == NULL) | ||
return (NULL); | ||
if (index == 0) | ||
return (head); | ||
for (i = 0; i < index; i++) | ||
{ | ||
if (head->next == NULL) | ||
return (NULL); | ||
head = head->next; | ||
} | ||
return (head); | ||
} |
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 @@ | ||
#include "lists.h" | ||
|
||
/** | ||
* sum_dlistint - sums all of the data of a dlistint_t linked list | ||
* @head: pointer to the beginning of the linked list | ||
* | ||
* Return: sum of all data, or 0 if the list is empty | ||
*/ | ||
int sum_dlistint(dlistint_t *head) | ||
{ | ||
int sum = 0; | ||
|
||
while (head != NULL) | ||
{ | ||
sum += head->n; | ||
head = head->next; | ||
} | ||
return (sum); | ||
} |
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,48 @@ | ||
#include "lists.h" | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
/** | ||
* insert_dnodeint_at_index - inserts a new node at a given position | ||
* @h: double pointer to the beginning of the linked list | ||
* @idx: index at which to insert the new node | ||
* @n: data to enter into new node | ||
* | ||
* Return: pointer to the new node, or NULL on failure | ||
*/ | ||
dlistint_t *insert_dnodeint_at_index(dlistint_t **h, unsigned int idx, int n) | ||
{ | ||
dlistint_t *new, *next, *current; | ||
unsigned int i; | ||
|
||
if (h == NULL) | ||
return (NULL); | ||
if (idx != 0) | ||
{ | ||
current = *h; | ||
for (i = 0; i < idx - 1 && current != NULL; i++) | ||
current = current->next; | ||
if (current == NULL) | ||
return (NULL); | ||
} | ||
new = malloc(sizeof(dlistint_t)); | ||
if (new == NULL) | ||
return (NULL); | ||
new->n = n; | ||
if (idx == 0) | ||
{ | ||
next = *h; | ||
*h = new; | ||
new->prev = NULL; | ||
} | ||
else | ||
{ | ||
new->prev = current; | ||
next = current->next; | ||
current->next = new; | ||
} | ||
new->next = next; | ||
if (new->next != NULL) | ||
new->next->prev = new; | ||
return (new); | ||
} |
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,40 @@ | ||
#include "lists.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* delete_dnodeint_at_index - deletes a node at a specific index | ||
* @head: double pointer to the linked list | ||
* @index: index at which to delete node | ||
* | ||
* Return: 1 on success, -1 on failure | ||
*/ | ||
int delete_dnodeint_at_index(dlistint_t **head, unsigned int index) | ||
{ | ||
dlistint_t *current; | ||
unsigned int i; | ||
|
||
if (head == NULL || *head == NULL) | ||
return (-1); | ||
current = *head; | ||
if (index == 0) | ||
{ | ||
*head = current->next; | ||
if (current->next != NULL) | ||
{ | ||
current->next->prev = NULL; | ||
} | ||
free(current); | ||
return (1); | ||
} | ||
for (i = 0; i < index; i++) | ||
{ | ||
if (current->next == NULL) | ||
return (-1); | ||
current = current->next; | ||
} | ||
current->prev->next = current->next; | ||
if (current->next != NULL) | ||
current->next->prev = current->prev; | ||
free(current); | ||
return (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 @@ | ||
0x17-doubly_linked_lists | ||
|
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 @@ | ||
#ifndef LIST_H | ||
#define LIST_H | ||
|
||
#include <stddef.h> | ||
/** | ||
* struct dlistint_s - doubly linked list | ||
* @n: integer | ||
* @prev: points to the previous node | ||
* @next: points to the next node | ||
* | ||
* Description: doubly linked list node structure | ||
* | ||
*/ | ||
typedef struct dlistint_s | ||
{ | ||
int n; | ||
struct dlistint_s *prev; | ||
struct dlistint_s *next; | ||
} dlistint_t; | ||
|
||
size_t print_dlistint(const dlistint_t *h); | ||
size_t dlistint_len(const dlistint_t *h); | ||
dlistint_t *add_dnodeint(dlistint_t **head, const int n); | ||
dlistint_t *add_dnodeint_end(dlistint_t **head, const int n); | ||
void free_dlistint(dlistint_t *head); | ||
dlistint_t *get_dnodeint_at_index(dlistint_t *head, unsigned int index); | ||
int sum_dlistint(dlistint_t *head); | ||
dlistint_t *insert_dnodeint_at_index(dlistint_t **h, unsigned int idx, int n); | ||
int delete_dnodeint_at_index(dlistint_t **head, unsigned int index); | ||
|
||
#endif/*LIST_H*/ |
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 @@ | ||
#!/usr/bin/python3 | ||
def ispalindrome(n): | ||
string = str(n) | ||
return string == string[::-1] | ||
|
||
array = [] | ||
for i in range(999, 99, -1): | ||
for j in range(i, 99, -1): | ||
if ispalindrome(i * j): | ||
array.append(i * j) | ||
print(max(array)) |