Skip to content

Instantly share code, notes, and snippets.

@ahmadalashtar
Last active January 17, 2024 01:08
Show Gist options
  • Save ahmadalashtar/a85ba68c82842721d5d3e9920fa43297 to your computer and use it in GitHub Desktop.
Save ahmadalashtar/a85ba68c82842721d5d3e9920fa43297 to your computer and use it in GitHub Desktop.
control of a rubik's cube received string
#include <stdio.h>
#include <string.h>
int main() {
char word[] = "a , b , c ,'d , f , ,f,'a, 'c";
int i;
while (i<strlen(word)){ //iterate each charachter
if (word[i] == 44 || word[i] == 32 || word[i] == 46) {//check if , or . or space
memmove(&word[i], &word[i + 1], strlen(word) - i);//delete character
i--;//go back one step in case it's ' or space
}
i++;//go forward one step
}
printf("%s",word);//print the word after removing , and space
// previous code for removing , and space
//next code is for sending orders to the arduino
i = 0;
while (i<strlen(word)){ //iterate each charachter
if (word[i] == 39){ // if it is '
i++; // go to the next char
if (word[i] == 'r'){ //do what you want
else if (word[i] == 'r'){} // do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
}
}
else {// normal rotation
if (word[i] == 'r'){ // do what you want
else if (word[i] == 'r'){} // do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
else if (word[i] == 'r'){}// do what you want
}
}
i++; // next char
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment