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
int read_msg_from_socket(int sock_fd,struct sm_msg *msg){ | |
char buffer[sizeof(struct sm_msg)] = {}; | |
size_t buffer_len = 0; | |
int nbytes = 0; | |
if( NULL == msg ){ | |
return -1; | |
} | |
do{ | |
nbytes = recv(sock_fd,buffer + buffer_len,sizeof(struct sm_msg) - buffer_len,MSG_WAITALL); |
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
void removeDot(char *str){ | |
int size = strlen(str); | |
char *memory = malloc(size); | |
memset(memory,0,size); | |
int i,j; | |
for( i=0;j=0;i<size;i++){ | |
if( str[i] != "." ){ | |
memory[j++] = str[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
int func(int number){ | |
long result = number * 0x4EC4EC4F; | |
int higher = result >> 34; | |
int lower = result & 0x00000000FFFFFFFF; | |
lower = lower >> 31; | |
return higher - lower; | |
} |
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
/* | |
* robotMaze.js | |
* | |
* The blue key is inside a labyrinth, and extracting | |
* it will not be easy. | |
* | |
* It's a good thing that you're a AI expert, or | |
* we would have to leave empty-handed. | |
*/ |
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
/*************** | |
* pointers.js * | |
*************** | |
* | |
* You! How are you still alive? | |
* | |
* Well, no matter. Good luck getting through this | |
* maze of rooms - you'll never see me or the Algorithm again! | |
*/ |
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
/********************** | |
* superDrEvalBros.js * | |
********************** | |
* | |
* You're still here?! Well, Dr. Eval, let's see | |
* how well you can operate with one less dimension. | |
* | |
* Give up now. Unless you have a magic mushroom | |
* up your sleeve, it's all over. | |
*/ |
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
/***************** | |
* bossFight.js * | |
***************** | |
* | |
* NO FARTHER, DR. EVAL!!!! | |
* YOU WILL NOT GET OUT OF HERE ALIVE!!!! | |
* IT'S TIME YOU SEE MY TRUE FORM!!!! | |
* FACE MY ROBOT WRATH!!!!! | |
*/ |
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
class doubleLinkedListNode(object): | |
def __init__(self,key=None,elem=None): | |
self.prev = None | |
self.next = None | |
self.key = key | |
self.elem = elem | |
def moveFront(self,headNode): | |
if self.prev != None: |
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
# Definition for singly-linked list. | |
# class ListNode: | |
# def __init__(self, x): | |
# self.val = x | |
# self.next = None | |
import math | |
class Solution: | |
def __init__(self,x): |
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
class Solution: | |
# @return a boolean | |
def isPalindrome(self, x): | |
if x < 0 : | |
return False | |
first_digit = rest_digit = x | |
res = 0 | |
while rest_digit != 0 : | |
first_digit = rest_digit % 10 |
OlderNewer