int *pointer = 0;
int **pointer_to_pointer = &pointer;
int pointer[10] = {0};
int **pointer_to_pointer = ??;
int var = 0; // takes 4 bytes
int *ptr = 0; // takes 8 bytes
int array1[64] = {0}; // takes 256 bytes
int array2[1] = {0}; // takes 4 bytes
array2
, an array can't be a pointer, pointers take more spacevar
, by writing &var
array2
, by writing array2
which C automatically rewrites to &array2[0]
.
into ->
array
parameter into &array[0]
, a poitner to the first element.
and ->
if I don't have any help from lsp or other tools and just .
if I have all the good stuff.
and ->
if I don't have any help from lsp or other tools and just .
if I have all the good stuff array
parameter into &array[0]
, a poitner to the first element 4[ptr]
(edited)array
to &array[0]
wasnt a good ideaint main(){return0;}
main
#define _ F-->00 || F-OO--;
long F=00,OO=00;
main(){F_OO();printf("%1.3f\n", 4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_
}
#define X
#define XX
#define XXX
#define XXXX
#define XXXXX
#define XXXXXX
#define XXXXXXX
#define orfa for
#define XXXXXXXXX
#define archa char
#define ainma main
#define etcharga getchar
#define utcharpa putchar
X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X X X
X XX X X XX X
X XXX X XXXXXXXXX X XXX X
X XXX X XXXX XXXX X XXX X
X XXXX X XX ainma(){ archa XX X XXXX X
X XXXX X oink[9],*igpa, X XXXX X
X XXXXXX atinla=etcharga(),iocccwa XXXXXX X
X XXXX ,apca='A',owla='a',umna=26 XXXX X
X XXX ; orfa(; (atinla+1)&&(!((( XXX X
X XX atinla-apca)*(apca+umna-atinla) XX X
X X >=0)+((atinla-owla)*(owla+umna- X X
X atinla)>=0))); utcharpa(atinla), X
X X atinla=etcharga()); orfa(; atinla+1; X X
X X ){ orfa( igpa=oink ,iocccwa=( X X
X X (atinla- XXX apca)*( XXX apca+umna- X X
X atinla)>=0) XXX XXX ; (((( X
X atinla-apca XXXXX XXXXXXX XXXXX )*(apca+ X
X umna-atinla XXXXXX )>=0) XXXXXX +((atinla- X
X owla)*(owla+ XXXX umna- XXXX atinla)>=0)) X
X &&"-Pig-" XX "Lat-in" XX "COb-fus" X
X "ca-tion!!"[ X (((atinla- X apca)*(apca+ X
X umna-atinla) X >=0)?atinla- X apca+owla: X
X atinla)-owla X ]-'-')||((igpa== X oink)&&!(*( X
X igpa++)='w') X )||! X (*( X igpa X ++)=owla); * X
X (igpa++)=(( X ( XXX XXX X atinla-apca X
X )*(apca+ X umna XXX - XXX X atinla)>=0) X
X ?atinla- X apca XXX + XXX owla X :atinla), X
X atinla= X X X X etcharga()) X
X ; orfa( X atinla=iocccwa?(( X (atinla- X
X owla)*(owla+ X umna-atinla)>=0 X )?atinla- X
X owla+apca: X atinla): X atinla; ((( X
X atinla-apca)* X (apca+umna- X atinla)>=0)+( X
X (atinla-owla)* X (owla+ X umna-atinla)>= X
X 0)); utcharpa( XX XX atinla),atinla X
X =etcharga()); XXXXXXX orfa(*igpa=0, X
X igpa=oink; * igpa; utcharpa( X
X *(igpa++))); orfa(; (atinla+1)&&(!((( X
X atinla-apca )*(apca+ X
X umna- XXXXX XXXXX atinla)>=0 X
X )+(( XXXXX atinla- X
XX owla)*( owla+umna- XX
XX atinla)>=0))); utcharpa XX
XX (atinla),atinla= XX
XX etcharga()); } XX
XXXX } XXXX
XXXXXXXXX
char sudoku[9*9]
arraystatic const uint8_t row_starts[] = {
0, 9, 18, 27, 36, 45, 54, 63, 72,
};
static const uint8_t row_offsets[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
};
static const uint8_t column_starts[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
};
static const uint8_t column_offsets[] = {
0, 9, 18, 27, 36, 45, 54, 63, 72,
};
static const uint8_t block_starts[] = {
0, 3, 6, 27, 30, 33, 54, 57, 60,
};
static const uint8_t block_offsets[] = {
0, 1, 2, 9, 10, 11, 18, 19, 20,
};
bool verify_pattern(char (*sudoku)[81], uint8_t *starts, size_t num_starts, uint8_t *offsets, size_t num_ffsets) {
for(char digit = 0; digit < 9; digit++) {
for(size_t i = 0; i < num_starts; i++) {
bool found = false;
for(size_t o = 0; o < num_offsets; o++) {
if((*sudoku)[i][o] == digit) {
found = true;
break;
}
}
if(!found) {
return false;
}
}
}
return true;
}
#define NELEM(arr) (sizeof(arr) / sizeof((arr)[0]))
bool verify(char (*sudoku)[81]) {
return true
&& verify_pattern(sudoku, row_starts, NELEM(row_starts), row_offsets, NELEM(row_offsets))
&& verify_pattern(sudoku, column_starts, NELEM(column_starts), column_offsets, NELEM(column_offsets))
&& verify_pattern(sudoku, block_starts, NELEM(block_starts), block_offsets, NELEM(block_offsets))
}
static const uint8_t row_starts[] = {
0, 9, 18, 27, 36, 45, 54, 63, 72,
};
static const uint8_t row_offsets[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
};
static const uint8_t column_starts[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
};
static const uint8_t column_offsets[] = {
0, 9, 18, 27, 36, 45, 54, 63, 72,
};
static const uint8_t block_starts[] = {
0, 3, 6, 27, 30, 33, 54, 57, 60,
};
static const uint8_t block_offsets[] = {
0, 1, 2, 9, 10, 11, 18, 19, 20,
};
bool verify_pattern(char (*sudoku)[81], uint8_t *starts, size_t num_starts, uint8_t *offsets, size_t num_ffsets) {
for(char digit = 0; digit < 9; digit++) {
for(size_t i = 0; i < num_starts; i++) {
bool found = false;
for(size_t o = 0; o < num_offsets; o++) {
if((*sudoku)[i][o] == digit) {
found = true;
break;
}
}
if(!found) {
return false;
}
}
}
return true;
}
#define NELEM(arr) (sizeof(arr) / sizeof((arr)[0]))
bool verify(char (*sudoku)[81]) {
return true
&& verify_pattern(sudoku, row_starts, NELEM(row_starts), row_offsets, NELEM(row_offsets))
&& verify_pattern(sudoku, column_starts, NELEM(column_starts), column_offsets, NELEM(column_offsets))
&& verify_pattern(sudoku, block_starts, NELEM(block_starts), block_offsets, NELEM(block_offsets))
}
bool Sudoku_verify(Sudoku sudoku) {
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[i*9 + j];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[i + 9*j];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[(i%3)*3 + (i/3*27) + (j%3) + (j/3*9)];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
return true;
}
my attempt lol(i%3)*3 + (i/3*27) + (j%3) + (j/3*9)
this is just some magicbool Sudoku_verify(Sudoku sudoku) {
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[i*9 + j];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[i + 9*j];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
for (int i=0;i<9;i++) {
bool seen[9] = {false};
for (int j=0;j<9;j++) {
char value = sudoku[(i%3)*3 + (i/3*27) + (j%3) + (j/3*9)];
if (value == 0) continue;
if (seen[value - 1]) return false;
seen[value - 1] = true;
}
}
return true;
}
my attempt lol (fn()->void)[69]
or [69]fn()->void
(fn()->void)[69]
or [69]fn()->void
(fn()->void)[69]
or [69]fn()->void