Created
February 4, 2021 21:27
-
-
Save garethlewin/c9474bf084bcade98619719243591687 to your computer and use it in GitHub Desktop.
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
#include <cstdio> | |
using namespace std; | |
int main(int argc, char** argv) { | |
printf("["); | |
char* cur = argv[1]; | |
int count = 1; | |
for (;*cur;++cur, ++count) { | |
if (cur[0] != cur[1]) { | |
printf("(\"%c\", %ld)%s", cur[0], count, cur[1] ? " ,": ""); | |
count=0; | |
} | |
} | |
printf("]\n"); | |
} |
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
print('[("a", 4), ("b", 3), ("c", 2), ("a", 1)]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment