name | correct guesses | games together | ratio |
---|---|---|---|
olus2000 | 4 | 7 | 0.571 |
yui | 2 | 4 | 0.500 |
moshikoi | 2 | 4 | 0.500 |
Olivia | 2 | 5 | 0.400 |
luatic | 3 | 8 | 0.375 |
kimapr | 3 | 10 | 0.300 |
theqwertiest | 1 | 4 | 0.250 |
LyricLy | 2 | 11 | 0.182 |
Dolphy | 1 | 7 | 0.143 |
taswelll | 0 | 6 | 0.000 |
razetime | 0 | 4 | 0.000 |
name | correct guesses | games together | ratio |
---|---|---|---|
moshikoi | 3 | 4 | 0.750 |
essaie | 3 | 4 | 0.750 |
LyricLy | 8 | 12 | 0.667 |
Dolphy | 4 | 7 | 0.571 |
olus2000 | 4 | 8 | 0.500 |
taswelll | 3 | 6 | 0.500 |
luatic | 4 | 9 | 0.444 |
kimapr | 3 | 11 | 0.273 |
yui | 1 | 4 | 0.250 |
razetime | 1 | 4 | 0.250 |
Olivia | 1 | 6 | 0.167 |
theqwertiest | 0 | 5 | 0.000 |
1 2 3 | # For any point P = (x, y): # P can be seen because its an empty plane with no obstructions. can_see_point = lambda x: lambda y: x |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | // the extension time is almost gone, and i don't have anymore time to work on this (im going to a concert!) // so i can't work on this anymore. so, i'm submitting an unfinished copy of this. // i really am sorry about it being unfinished, but i don't have much of a choice here: it's either participate or don't, // and i really do want to participate. // P.S. compile with g++ kimapr.c -fpermissive -lgmp // IF : you dont have obstack // THEN: add obstack.c to the g++ command. /* DONE: all of the trivial shit */ /* TODO: fix all of the FIXME list add randomi[zs]ation for probablistic-ization of PricK */ /* FIXME: conditionals are fucked like really really fucked */ /* The author of this file IS NOT one of the following people: lyricly razetime r. "essaie" sa olive olus "olly" 2000 olivia IFcoltransG sofia kotnen zptr yui mark palailogos at (DataKinds) The author of this file IS one of the following people: GNU Radio Shows seshoumara Impersonating people who aren't even playing is fun. Maybe next time i'll impersonate someone else. */ #if __has_include(<obstack.h>) # include <obstack.h> #else # include "obstack.h" #endif static struct flags { int helpinfo, versions; char*verb,*post,*p, sn; } flgs; #include <unordered_map> #include <stdio.h> #include <stdlib.h> #include <getopt.h> static int c, i, v, n; void parseopt(int argc, char *const argv[]) { static const struct option lopts[] = { {"help", no_argument, &flgs.helpinfo, 1}, {"version", no_argument, &flgs.versions, 1}, {"before", required_argument, 0, 'b'}, {"after", required_argument, 0, 'a'}, {"command", required_argument, 0, 'c'}, {0, 0, 0, 0}, }; while((c = getopt_long(argc, argv, "hHvVc:C:b:B:a:A:", lopts, &i)) != -1){ switch(c) { case '?': printf("use --help\n"); case 0: break; case 'h': case 'H': flgs.helpinfo = 1; break; case 'v': case 'V': flgs.versions = 1; break; case 'c': case 'C': flgs.p=optarg; flgs.sn=1; break; case 'b': case 'B': flgs.verb=optarg; break; case 'a': case 'A': flgs.post=optarg; break; } } if (optind < argc){ if (flgs.p||++optind<argc) { printf("%s: unexpected positional argument -- %s", argv[0], argv[optind]); exit(-1); } flgs.p = argv[--optind]; } } #include <string.h> #include <stack> char *E; int exc(char*e){strcpy((E=realloc(E,(n+=(i=strlen(e)))+1))+n-i,e);} #if __has_include(<gmp.h>) # include <gmp.h> #else # error what the SIGMA?!you promised me gmplib! #endif int rnc(); static struct Ss{ struct obstack ostcak{}; std::stack<int> stcak{}; std::unordered_map<int,int> arm{}; // sparse memory representation } *stk; #define MPZ_POP(n)\ if(cr.stcak.empty())mpz_init(n); \ else (mpz_init_set_ui(n,cr.stcak.top()),cr.stcak.pop()); #define MPZ_MEM(n, a)\ if(!cr.arm.count(mpz_get_ui(a)))mpz_init(n); \ else mpz_init_set_ui(n,cr.arm[mpz_get_ui(a)]); #ifdef useobskcatk #define OBJECTSTAKDFLK\ obstack_init(&cr.ostcak);obstack_free(&cr.ostcak, NULL); #else #define OBJECTSTAKDFLK #endif #define FALL \ for(c = 0; c < v; c++){struct Ss& cr = stk[c];OBJECTSTAKDFLK int cond(){ struct Ss& cr = stk[c]; i++; int I=i; int J=i; int bal=1; for(;bal;J++){ bal += E[J] == '['; bal -= E[J] == ']'; }; mpz_t b; MPZ_POP(b); while (1){ while(E[i]!='|') rnc(); mpz_t N; MPZ_POP(N); if (mpz_cmp_ui(N, 0) && mpz_cmp_ui(b, 0)){ while(E[i]!=']') rnc(); } else break; i=I; } i=J; } int rnc(){ printf("%d %c\n", E[i], E[i]); switch(E[i]){ case '#': FALL;cr.stcak.push(0);}; break;case '+': FALL;mpz_t t;MPZ_POP(t);mpz_add_ui(t, t, 1); cr.stcak.push(mpz_get_ui(t));mpz_clear(t);}; break;case '@': FALL;mpz_t s,m;MPZ_POP(s);MPZ_MEM(m,s);mpz_clear(s); cr.stcak.push(mpz_get_ui(m));mpz_clear(m);};break; case '!': FALL;mpz_t a,V;MPZ_POP(a);MPZ_POP(V); cr.arm[mpz_get_ui(a)]=mpz_get_ui(V); mpz_clear(a);mpz_clear(V);}; break;case '[':cond(); break;case '|':case ']':i++;return; break;case '?': break;default: printf("bad syntax. %s", "see --help output for more information.\n"); exit(-1); };i++;} int cleanup() {for (; i < n-1 && E[i];)rnc(); FALL;printf("%d\n", cr.stcak.top());}; } int main(int argc, char* argv[]) { parseopt(argc, argv); v++; if (flgs.helpinfo) printf("lol no, just read the source code\n"), exit(-1); if (flgs.versions) printf("%s v6.9\n", argv[0]), exit(-1); stk = (struct Ss *)calloc(v, sizeof(struct Ss)); stk[0] = Ss{}; E = (char *)malloc(n=0); if (flgs.verb) exc(flgs.verb); if (flgs.sn) exc(flgs.p); else { FILE* f = flgs.p ? fopen(flgs.p, "r") : stdin; while ((c = getc(f)) != EOF) exc((char *)&c); } if (flgs.post) exc(flgs.post); i=0;cleanup(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | /* obstack.c - subroutines used implicitly by object stack macros Copyright (C) 1988-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifdef _LIBC # include <obstack.h> #else //# include <config.h> # include "obstack.h" #endif /* NOTE BEFORE MODIFYING THIS FILE IN GNU LIBC: _OBSTACK_INTERFACE_VERSION in gnu-versions.h must be incremented whenever callers compiled using an old obstack.h can no longer properly call the functions in this file. */ /* If GCC, or if an oddball (testing?) host that #defines __alignof__, use the already-supplied __alignof__. Otherwise, this must be Gnulib (as glibc assumes GCC); defer to Gnulib's alignof_type. */ #if !defined __GNUC__ && !defined __alignof__ # include <alignof.h> # define __alignof__(type) alignof_type (type) #endif #include <stdlib.h> #include <stdint.h> #ifndef MAX # define MAX(a,b) ((a) > (b) ? (a) : (b)) #endif /* Determine default alignment. */ /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. But in fact it might be less smart and round addresses to as much as DEFAULT_ROUNDING. So we prepare for it to do that. DEFAULT_ALIGNMENT cannot be an enum constant; see gnulib's alignof.h. */ #define DEFAULT_ALIGNMENT MAX (__alignof__ (long double), \ MAX (__alignof__ (uintmax_t), \ __alignof__ (void *))) #define DEFAULT_ROUNDING MAX (sizeof (long double), \ MAX (sizeof (uintmax_t), \ sizeof (void *))) /* Call functions with either the traditional malloc/free calling interface, or the mmalloc/mfree interface (that adds an extra first argument), based on the value of use_extra_arg. */ static void * call_chunkfun (struct obstack *h, size_t size) { if (h->use_extra_arg) return h->chunkfun.extra (h->extra_arg, size); else return h->chunkfun.plain (size); } static void call_freefun (struct obstack *h, void *old_chunk) { if (h->use_extra_arg) h->freefun.extra (h->extra_arg, old_chunk); else h->freefun.plain (old_chunk); } /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). Objects start on multiples of ALIGNMENT (0 means use default). Return nonzero if successful, calls obstack_alloc_failed_handler if allocation fails. */ static int _obstack_begin_worker (struct obstack *h, _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment) { struct _obstack_chunk *chunk; /* points to new chunk */ if (alignment == 0) alignment = DEFAULT_ALIGNMENT; if (size == 0) /* Default size is what GNU malloc can fit in a 4096-byte block. */ { /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. Use the values for range checking, because if range checking is off, the extra bytes won't be missed terribly, but if range checking is on and we used a larger request, a whole extra 4096 bytes would be allocated. These number are irrelevant to the new GNU malloc. I suspect it is less sensitive to the size of the request. */ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + 4 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)); size = 4096 - extra; } h->chunk_size = size; h->alignment_mask = alignment - 1; chunk = h->chunk = call_chunkfun (h, h->chunk_size); if (!chunk) (*obstack_alloc_failed_handler) (); h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents, alignment - 1); h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; h->alloc_failed = 0; return 1; } int _obstack_begin (struct obstack *h, _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, void *(*chunkfun) (size_t), void (*freefun) (void *)) { h->chunkfun.plain = chunkfun; h->freefun.plain = freefun; h->use_extra_arg = 0; return _obstack_begin_worker (h, size, alignment); } int _obstack_begin_1 (struct obstack *h, _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, void *(*chunkfun) (void *, size_t), void (*freefun) (void *, void *), void *arg) { h->chunkfun.extra = chunkfun; h->freefun.extra = freefun; h->extra_arg = arg; h->use_extra_arg = 1; return _obstack_begin_worker (h, size, alignment); } /* Allocate a new current chunk for the obstack *H on the assumption that LENGTH bytes need to be added to the current object, or a new object of length LENGTH allocated. Copies any partial object from the end of the old chunk to the beginning of the new one. */ void _obstack_newchunk (struct obstack *h, _OBSTACK_SIZE_T length) { struct _obstack_chunk *old_chunk = h->chunk; struct _obstack_chunk *new_chunk = 0; size_t obj_size = h->next_free - h->object_base; char *object_base; /* Compute size for new chunk. */ size_t sum1 = obj_size + length; size_t sum2 = sum1 + h->alignment_mask; size_t new_size = sum2 + (obj_size >> 3) + 100; if (new_size < sum2) new_size = sum2; if (new_size < h->chunk_size) new_size = h->chunk_size; /* Allocate and initialize the new chunk. */ if (obj_size <= sum1 && sum1 <= sum2) new_chunk = call_chunkfun (h, new_size); if (!new_chunk) (*obstack_alloc_failed_handler)(); h->chunk = new_chunk; new_chunk->prev = old_chunk; new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; /* Compute an aligned object_base in the new chunk */ object_base = __PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask); /* Move the existing object to the new chunk. */ memcpy (object_base, h->object_base, obj_size); /* If the object just copied was the only data in OLD_CHUNK, free that chunk and remove it from the chain. But not if that chunk might contain an empty object. */ if (!h->maybe_empty_object && (h->object_base == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents, h->alignment_mask))) { new_chunk->prev = old_chunk->prev; call_freefun (h, old_chunk); } h->object_base = object_base; h->next_free = h->object_base + obj_size; /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0; } /* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. If you use it in a program, you are probably losing. */ /* Suppress -Wmissing-prototypes warning. We don't want to declare this in obstack.h because it is just for debugging. */ int _obstack_allocated_p (struct obstack *h, void *obj) __attribute_pure__; int _obstack_allocated_p (struct obstack *h, void *obj) { struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at the beginning of the chunk but might be an empty object exactly at the end of an adjacent chunk. */ while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj)) { plp = lp->prev; lp = plp; } return lp != 0; } /* Free objects in obstack H, including OBJ and everything allocate more recently than OBJ. If OBJ is zero, free everything in H. */ void _obstack_free (struct obstack *h, void *obj) { struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj)) { plp = lp->prev; call_freefun (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) { h->object_base = h->next_free = (char *) (obj); h->chunk_limit = lp->limit; h->chunk = lp; } else if (obj != 0) /* obj is not in any of the chunks! */ abort (); } _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *h) { struct _obstack_chunk *lp; _OBSTACK_SIZE_T nbytes = 0; for (lp = h->chunk; lp != 0; lp = lp->prev) { nbytes += lp->limit - (char *) lp; } return nbytes; } #ifndef _OBSTACK_NO_ERROR_HANDLER /* Define the error handler. */ # include <stdio.h> /* Exit value used when 'print_and_abort' is used. */ int obstack_exit_failure = EXIT_FAILURE; static __attribute_noreturn__ void print_and_abort (void) { /* Don't change any of these strings. Yes, it would be possible to add the newline to the string and use fputs or so. But this must not happen because the "memory exhausted" message appears in other places like this and the translation should be reused instead of creating a very similar string which requires a separate translation. */ fprintf (stderr, "%s\n", "memory exhausted"); exit (obstack_exit_failure); } /* The functions allocating more room by calling 'obstack_chunk_alloc' jump to the handler pointed to by 'obstack_alloc_failed_handler'. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. This variable by default points to the internal function 'print_and_abort'. */ __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void) = print_and_abort; #endif /* !_OBSTACK_NO_ERROR_HANDLER */ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | /* obstack.h - object stack macros Copyright (C) 1988-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Summary: All the apparent functions defined here are macros. The idea is that you would use these pre-tested macros to solve a very specific set of problems, and they would run fast. Caution: no side-effects in arguments please!! They may be evaluated MANY times!! These macros operate a stack of objects. Each object starts life small, and may grow to maturity. (Consider building a word syllable by syllable.) An object can move while it is growing. Once it has been "finished" it never changes address again. So the "top of the stack" is typically an immature growing object, while the rest of the stack is of mature, fixed size and fixed address objects. These routines grab large chunks of memory, using a function you supply, called 'obstack_chunk_alloc'. On occasion, they free chunks, by calling 'obstack_chunk_free'. You must define them and declare them before using any obstack macros. Each independent stack is represented by a 'struct obstack'. Each of the obstack macros expects a pointer to such a structure as the first argument. One motivation for this package is the problem of growing char strings in symbol tables. Unless you are "fascist pig with a read-only mind" --Gosper's immortal quote from HAKMEM item 154, out of context--you would not like to put any arbitrary upper limit on the length of your symbols. In practice this often means you will build many short symbols and a few long symbols. At the time you are reading a symbol you don't know how long it is. One traditional method is to read a symbol into a buffer, realloc()ating the buffer every time you try to read a symbol that is longer than the buffer. This is beaut, but you still will want to copy the symbol from the buffer to a more permanent symbol-table entry say about half the time. With obstacks, you can work differently. Use one obstack for all symbol names. As you read a symbol, grow the name in the obstack gradually. When the name is complete, finalize it. Then, if the symbol exists already, free the newly read name. The way we do this is to take a large chunk, allocating memory from low addresses. When you want to build a symbol in the chunk you just add chars above the current "high water mark" in the chunk. When you have finished adding chars, because you got to the end of the symbol, you know how long the chars are, and you can create a new object. Mostly the chars will not burst over the highest address of the chunk, because you would typically expect a chunk to be (say) 100 times as long as an average object. In case that isn't clear, when we have enough chars to make up the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) so we just point to it where it lies. No moving of chars is needed and this is the second win: potentially long strings need never be explicitly shuffled. Once an object is formed, it does not change its address during its lifetime. When the chars burst over a chunk boundary, we allocate a larger chunk, and then copy the partly formed object from the end of the old chunk to the beginning of the new larger chunk. We then carry on accreting characters to the end of the object as we normally would. A special macro is provided to add a single char at a time to a growing object. This allows the use of register variables, which break the ordinary 'growth' macro. Summary: We allocate large chunks. We carve out one object at a time from the current chunk. Once carved, an object never moves. We are free to append data of any size to the currently growing object. Exactly one object is growing in an obstack at any one time. You can run one obstack per control block. You may have as many control blocks as you dare. Because of the way we do it, you can "unwind" an obstack back to a previous state. (You may remove objects much as you would with a stack.) */ /* Documentation (part of the GNU libc manual): <https://www.gnu.org/software/libc/manual/html_node/Obstacks.html> */ /* Don't do the contents of this file more than once. */ #ifndef _OBSTACK_H #define _OBSTACK_H 1 #include <stddef.h> /* For size_t and ptrdiff_t. */ #include <stdint.h> /* For uintptr_t. */ #include <string.h> /* For memcpy. */ #if __STDC_VERSION__ < 199901L || defined __HP_cc # define __FLEXIBLE_ARRAY_MEMBER 1 #else # define __FLEXIBLE_ARRAY_MEMBER #endif /* These macros highlight the places where this implementation is different from the one in GNU libc. */ #ifdef _LIBC # define _OBSTACK_SIZE_T unsigned int # define _CHUNK_SIZE_T unsigned long # define _OBSTACK_CAST(type, expr) ((type) (expr)) #else /* In Gnulib, we use sane types, especially for 64-bit hosts. */ # define _OBSTACK_SIZE_T size_t # define _CHUNK_SIZE_T size_t # define _OBSTACK_CAST(type, expr) (expr) #endif /* __PTR_ALIGN(B, P, A) returns the result of aligning P to the next multiple of A + 1. B must be the base of an object addressed by P. B and P must be of type char *. A + 1 must be a power of 2. If ptrdiff_t is narrower than a pointer (e.g., the AS/400), play it safe and compute the alignment relative to B. Otherwise, use the faster strategy of computing the alignment through uintptr_t. */ #define __PTR_ALIGN(B, P, A) \ ((P) + ((- (uintptr_t) (P)) & (A))) #ifndef __attribute_pure__ # define __attribute_pure__ _GL_ATTRIBUTE_PURE #endif /* Not the same as _Noreturn, since it also works with function pointers. */ #ifndef __attribute_noreturn__ # if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ || 0x5110 <= __SUNPRO_C # define __attribute_noreturn__ __attribute__ ((__noreturn__)) # else # define __attribute_noreturn__ # endif #endif #ifdef __cplusplus extern "C" { #endif struct _obstack_chunk /* Lives at front of each chunk. */ { char *limit; /* 1 past end of this chunk */ struct _obstack_chunk *prev; /* address of prior chunk or NULL */ char contents[__FLEXIBLE_ARRAY_MEMBER]; /* objects begin here */ }; struct obstack /* control current object in current chunk */ { _CHUNK_SIZE_T chunk_size; /* preferred size to allocate chunks in */ struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ char *object_base; /* address of object we are building */ char *next_free; /* where to add next char to current object */ char *chunk_limit; /* address of char after current chunk */ union { _OBSTACK_SIZE_T i; void *p; } temp; /* Temporary for some macros. */ _OBSTACK_SIZE_T alignment_mask; /* Mask of alignment for each object. */ /* These prototypes vary based on 'use_extra_arg'. */ union { void *(*plain) (size_t); void *(*extra) (void *, size_t); } chunkfun; union { void (*plain) (void *); void (*extra) (void *, void *); } freefun; void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */ unsigned maybe_empty_object : 1; /* There is a possibility that the current chunk contains a zero-length object. This prevents freeing the chunk if we allocate a bigger chunk to replace it. */ unsigned alloc_failed : 1; /* No longer used, as we now call the failed handler on error, but retained for binary compatibility. */ }; /* Declare the external functions we use; they are in obstack.c. */ extern void _obstack_newchunk (struct obstack *, _OBSTACK_SIZE_T); extern void _obstack_free (struct obstack *, void *); extern int _obstack_begin (struct obstack *, _OBSTACK_SIZE_T, _OBSTACK_SIZE_T, void *(*) (size_t), void (*) (void *)); extern int _obstack_begin_1 (struct obstack *, _OBSTACK_SIZE_T, _OBSTACK_SIZE_T, void *(*) (void *, size_t), void (*) (void *, void *), void *); extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *) __attribute_pure__; /* Error handler called when 'obstack_chunk_alloc' failed to allocate more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ extern __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void); /* Exit value used when 'print_and_abort' is used. */ extern int obstack_exit_failure; /* Pointer to beginning of object being allocated or to be allocated next. Note that this might not be the final address of the object because a new chunk might be needed to hold the final size. */ #define obstack_base(h) ((void *) (h)->object_base) /* Size for allocating ordinary chunks. */ #define obstack_chunk_size(h) ((h)->chunk_size) /* Pointer to next byte not yet allocated in current chunk. */ #define obstack_next_free(h) ((void *) (h)->next_free) /* Mask specifying low bits that should be clear in address of an object. */ #define obstack_alignment_mask(h) ((h)->alignment_mask) /* To prevent prototype warnings provide complete argument list. */ #define obstack_init(h) \ _obstack_begin ((h), 0, 0, \ _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \ _OBSTACK_CAST (void (*) (void *), obstack_chunk_free)) #define obstack_begin(h, size) \ _obstack_begin ((h), (size), 0, \ _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \ _OBSTACK_CAST (void (*) (void *), obstack_chunk_free)) #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ _obstack_begin ((h), (size), (alignment), \ _OBSTACK_CAST (void *(*) (size_t), chunkfun), \ _OBSTACK_CAST (void (*) (void *), freefun)) #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ _obstack_begin_1 ((h), (size), (alignment), \ _OBSTACK_CAST (void *(*) (void *, size_t), chunkfun), \ _OBSTACK_CAST (void (*) (void *, void *), freefun), arg) #define obstack_chunkfun(h, newchunkfun) \ ((void) ((h)->chunkfun.extra = (void *(*) (void *, size_t)) (newchunkfun))) #define obstack_freefun(h, newfreefun) \ ((void) ((h)->freefun.extra = (void *(*) (void *, void *)) (newfreefun))) #define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar))) #define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n))) #define obstack_memory_used(h) _obstack_memory_used (h) #if defined __GNUC__ || defined __clang__ # if !(defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2008 \ || defined __clang__) # define __extension__ # endif /* For GNU C, if not -traditional, we can define these macros to compute all args only once without using a global variable. Also, we can avoid using the 'temp' slot, to make faster code. */ # define obstack_object_size(OBSTACK) \ __extension__ \ ({ struct obstack const *__o = (OBSTACK); \ (_OBSTACK_SIZE_T) (__o->next_free - __o->object_base); }) /* The local variable is named __o1 to avoid a shadowed variable warning when invoked from other obstack macros. */ # define obstack_room(OBSTACK) \ __extension__ \ ({ struct obstack const *__o1 = (OBSTACK); \ (_OBSTACK_SIZE_T) (__o1->chunk_limit - __o1->next_free); }) # define obstack_make_room(OBSTACK, length) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ _OBSTACK_SIZE_T __len = (length); \ if (obstack_room (__o) < __len) \ _obstack_newchunk (__o, __len); \ (void) 0; }) # define obstack_empty_p(OBSTACK) \ __extension__ \ ({ struct obstack const *__o = (OBSTACK); \ (__o->chunk->prev == 0 \ && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ __o->chunk->contents, \ __o->alignment_mask)); }) # define obstack_grow(OBSTACK, where, length) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ _OBSTACK_SIZE_T __len = (length); \ if (obstack_room (__o) < __len) \ _obstack_newchunk (__o, __len); \ memcpy (__o->next_free, where, __len); \ __o->next_free += __len; \ (void) 0; }) # define obstack_grow0(OBSTACK, where, length) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ _OBSTACK_SIZE_T __len = (length); \ if (obstack_room (__o) < __len + 1) \ _obstack_newchunk (__o, __len + 1); \ memcpy (__o->next_free, where, __len); \ __o->next_free += __len; \ *(__o->next_free)++ = 0; \ (void) 0; }) # define obstack_1grow(OBSTACK, datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ if (obstack_room (__o) < 1) \ _obstack_newchunk (__o, 1); \ obstack_1grow_fast (__o, datum); }) /* These assume that the obstack alignment is good enough for pointers or ints, and that the data added so far to the current object shares that much alignment. */ # define obstack_ptr_grow(OBSTACK, datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ if (obstack_room (__o) < sizeof (void *)) \ _obstack_newchunk (__o, sizeof (void *)); \ obstack_ptr_grow_fast (__o, datum); }) # define obstack_int_grow(OBSTACK, datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ if (obstack_room (__o) < sizeof (int)) \ _obstack_newchunk (__o, sizeof (int)); \ obstack_int_grow_fast (__o, datum); }) # define obstack_ptr_grow_fast(OBSTACK, aptr) \ __extension__ \ ({ struct obstack *__o1 = (OBSTACK); \ void *__p1 = __o1->next_free; \ *(const void **) __p1 = (aptr); \ __o1->next_free += sizeof (const void *); \ (void) 0; }) # define obstack_int_grow_fast(OBSTACK, aint) \ __extension__ \ ({ struct obstack *__o1 = (OBSTACK); \ void *__p1 = __o1->next_free; \ *(int *) __p1 = (aint); \ __o1->next_free += sizeof (int); \ (void) 0; }) # define obstack_blank(OBSTACK, length) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ _OBSTACK_SIZE_T __len = (length); \ if (obstack_room (__o) < __len) \ _obstack_newchunk (__o, __len); \ obstack_blank_fast (__o, __len); }) # define obstack_alloc(OBSTACK, length) \ __extension__ \ ({ struct obstack *__h = (OBSTACK); \ obstack_blank (__h, (length)); \ obstack_finish (__h); }) # define obstack_copy(OBSTACK, where, length) \ __extension__ \ ({ struct obstack *__h = (OBSTACK); \ obstack_grow (__h, (where), (length)); \ obstack_finish (__h); }) # define obstack_copy0(OBSTACK, where, length) \ __extension__ \ ({ struct obstack *__h = (OBSTACK); \ obstack_grow0 (__h, (where), (length)); \ obstack_finish (__h); }) /* The local variable is named __o1 to avoid a shadowed variable warning when invoked from other obstack macros, typically obstack_free. */ # define obstack_finish(OBSTACK) \ __extension__ \ ({ struct obstack *__o1 = (OBSTACK); \ void *__value = (void *) __o1->object_base; \ if (__o1->next_free == __value) \ __o1->maybe_empty_object = 1; \ __o1->next_free \ = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ __o1->alignment_mask); \ if ((size_t) (__o1->next_free - (char *) __o1->chunk) \ > (size_t) (__o1->chunk_limit - (char *) __o1->chunk)) \ __o1->next_free = __o1->chunk_limit; \ __o1->object_base = __o1->next_free; \ __value; }) # define obstack_free(OBSTACK, OBJ) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ void *__obj = (void *) (OBJ); \ if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \ __o->next_free = __o->object_base = (char *) __obj; \ else \ _obstack_free (__o, __obj); }) #else /* not __GNUC__ */ # define obstack_object_size(h) \ ((_OBSTACK_SIZE_T) ((h)->next_free - (h)->object_base)) # define obstack_room(h) \ ((_OBSTACK_SIZE_T) ((h)->chunk_limit - (h)->next_free)) # define obstack_empty_p(h) \ ((h)->chunk->prev == 0 \ && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ (h)->chunk->contents, \ (h)->alignment_mask)) /* Note that the call to _obstack_newchunk is enclosed in (..., 0) so that we can avoid having void expressions in the arms of the conditional expression. Casting the third operand to void was tried before, but some compilers won't accept it. */ # define obstack_make_room(h, length) \ ((h)->temp.i = (length), \ ((obstack_room (h) < (h)->temp.i) \ ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0), \ (void) 0) # define obstack_grow(h, where, length) \ ((h)->temp.i = (length), \ ((obstack_room (h) < (h)->temp.i) \ ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ memcpy ((h)->next_free, where, (h)->temp.i), \ (h)->next_free += (h)->temp.i, \ (void) 0) # define obstack_grow0(h, where, length) \ ((h)->temp.i = (length), \ ((obstack_room (h) < (h)->temp.i + 1) \ ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \ memcpy ((h)->next_free, where, (h)->temp.i), \ (h)->next_free += (h)->temp.i, \ *((h)->next_free)++ = 0, \ (void) 0) # define obstack_1grow(h, datum) \ (((obstack_room (h) < 1) \ ? (_obstack_newchunk ((h), 1), 0) : 0), \ obstack_1grow_fast (h, datum)) # define obstack_ptr_grow(h, datum) \ (((obstack_room (h) < sizeof (char *)) \ ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ obstack_ptr_grow_fast (h, datum)) # define obstack_int_grow(h, datum) \ (((obstack_room (h) < sizeof (int)) \ ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ obstack_int_grow_fast (h, datum)) # define obstack_ptr_grow_fast(h, aptr) \ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr), \ (void) 0) # define obstack_int_grow_fast(h, aint) \ (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint), \ (void) 0) # define obstack_blank(h, length) \ ((h)->temp.i = (length), \ ((obstack_room (h) < (h)->temp.i) \ ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ obstack_blank_fast (h, (h)->temp.i)) # define obstack_alloc(h, length) \ (obstack_blank ((h), (length)), obstack_finish ((h))) # define obstack_copy(h, where, length) \ (obstack_grow ((h), (where), (length)), obstack_finish ((h))) # define obstack_copy0(h, where, length) \ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) # define obstack_finish(h) \ (((h)->next_free == (h)->object_base \ ? (((h)->maybe_empty_object = 1), 0) \ : 0), \ (h)->temp.p = (h)->object_base, \ (h)->next_free \ = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ (h)->alignment_mask), \ (((size_t) ((h)->next_free - (char *) (h)->chunk) \ > (size_t) ((h)->chunk_limit - (char *) (h)->chunk)) \ ? ((h)->next_free = (h)->chunk_limit) : 0), \ (h)->object_base = (h)->next_free, \ (h)->temp.p) # define obstack_free(h, obj) \ ((h)->temp.p = (void *) (obj), \ (((h)->temp.p > (void *) (h)->chunk \ && (h)->temp.p < (void *) (h)->chunk_limit) \ ? (void) ((h)->next_free = (h)->object_base = (char *) (h)->temp.p) \ : _obstack_free ((h), (h)->temp.p))) #endif /* not __GNUC__ */ #ifdef __cplusplus } /* C++ */ #endif #endif /* _OBSTACK_H */ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | #! /bin/bash # copyright (C) Ly(r)icLy 2024 # this month's edition of taswelll impersonation is funded # by viewers like you # as always, taswelll impersonation is brought to you by: # the Ly(r)icLy LLC. Co. MK. AB conglomorate company, Inc. (all rights restricted) # no waranty is provided; there is no guarantee of fitness for any purpose. # ^^^ im not capitalizing all that shit like normal licenses do nl=$'\n' tab=$'\t' ddefault_flock_sl=0.05 #comment these out if your machine has a builtin flock and flunlock!! flock(){ if [ ${doverride_flock_sl} ]; then sleep ${doverride_flock_sl} return fi #flock isnt portable in bash, so taswelll.ai by LyRicLY will just #handwave it by sleeping a bit if [ ${2} ]; then sleep $2 else sleep $ddefault_flock_sl fi } flunlock(){ #funlock isnt portable in bash, so taswelll.ai by LyRicLY will just #handwave it by sleeping a bit if [ $2 ]; then sleep $2 else sleep $ddefault_flock_sl fi } join(){ v_joined="${2}" for ((L = 3; L <= $#; L++)); do v_joined="${v_joined}${1}${!L}" done printf "%s" "${v_joined}" } readcmd(){ flock ${!2} v_cmdoutp="" while IFS= read -r outline; do v_cmdoutp=$(join "${nl}${tab}" "${v_cmdoutp}" "${outline}") done < <(eval $1) flunlock ${!2} printf "%s" "${v_cmdoutp}" } saychar(){ flock ${____filestruct__STDOUT_} i="$2"; echo -n "${1:i:1}" flunlock ${____filestruct__STDOUT_} } saychars(){ # sometimes flock fails here??but it works when twice flock ${____filestruct__STDOUT_}; flock ${____filestruct__STDOUT_} for ((i = 0; i < ${#1}; i++)); do saychar "$1" $i done flunlock ${____filestruct__STDOUT_} } sayline(){ saychars "${1}"; saychar $'\n' } saylines(){ flock ${____filestruct__STDOUT_} 0.4 for ((L = 1; L <= $#; L++)); do sayline "${!L}" done flunlock ${____filestruct__STDOUT_} 0.4 } require(){ ( command -v "${1}" >/dev/null ) || { sayline "${tab}!! skipping test, missing command ${1}" return 1 } } inspect_cpuinfo(){ readcmd "cat /proc/cpuinfo" ${____path__proc_cpuinfo_} } inspect_meminfo(){ readcmd "cat /proc/meminfo" ${____path__proc_meminfo_} } inspect_driveinfo(){ readcmd 'cat /proc/partitions' ${____path__proc_partitions_} require mount && readcmd 'mount -m' ${____path__etc_fstab_} require blkid && readcmd 'blkid' # no locks here: it handles itself require lsblk && readcmd 'lsblk' # no locks here: it handles itself } mount_mem(){ flock $$____path__etc_fstab_ require mount && mount -a flunlock $$____path__etc_fstab_ } readvectors(){ readcmd 'cat data.ai' ${____path_HERE__file_1_} } checkterm(){ (( $COLUMNS <= 88 )) \ && printf "!! please resize your terminal, %s%s\n" \ "at least 96 columns are needed for " \ " taswelll AI to work properly." \ && exit 1 } # if taswelll will be verbose vvarg=`join '' $@` vverb="${vvarg//[^v]}" v="${#vverb}" sayline "Initializing..." sayline "[-${tab}inspecting cpu]" v_cpuinfo=$(inspect_cpuinfo) if (( $v >= 2 )); then saylines "${v_cpuinfo}" fi sayline "[-${tab}inspecting memory]" v_meminfo=$(inspect_meminfo) if (( $v >= 2 )); then saylines "${v_meminfo}" fi sayline "[-${tab}inspecting drive mounts]" v_driveinfo=$(inspect_driveinfo) if (( $v >= 2 )); then sayline "${v_driveinfo}" fi sayline "[-${tab}mounting memory]" mount_mem sayline "[-${tab}loading vectors]" taswelll_ai_vectors=$(readvectors) if (( $v >= 3 )); then saylines "${taswelll_ai_vectors}" fi checkterm sayline "Done initializing." saylines "" "" "" sayline "${tab}${tab}${tab}${tab}Welcome to taswelll AI" readcmd 'cat taswelll_240x240.ansiclr' echo -ne '\x1b[0m\n\n' while read -e -p '(prompt) >>> ' -r prompt; do printf "%s\n\n\n" "${taswelll_ai_vectors}" done |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | // taken from a prototype grep implementation. it never made it into mainline sadly, but i found it // in the mailing lists. ive removed everything that isn't relevant to the cg (like compiling to dfa), // and converted it to generate strings instead of matching them. ive also formatted it and severely // stripped it down (as you can see, now it's less than 50 lines) #include<stdio.h> #include <string.h> #include<stdlib.h> // Size of the buffer that this program will use.We dont want to go bigger than // a page, for reasons. (Im not super-stitious, just a little stitious.) #define BUFSIZE 4096 // Im use **argv instead of *argv[] to avoid the argument about // array declaration/indexing syntax that keeps happining.i don't like argue main(int argc, char ** argv){ char * regex; char buf[BUFSIZE]; _Bool slash=0, brace=0; int b=0, l=0; (argc != 2 ? (printf("expected 1 argument, got %d", argc-1), exit(1)) : (regex=argv[1]) ); for(int i =~ 0; ++i< strlen(regex); ){ char c = regex[i]; if(slash) buf[b++]=c+(slash=0); else if(brace)brace=(c==']' ?0:*(char*)0); else switch( regex[i] ){ case '[': brace=1;break; case '\\':slash=1;break; case '(': l ++;break; case ')': l --;break; case '*': break; case '|': b =0;break; default:buf[b++]=regex[i]; } } l++; // unmatched parens get special treatment while(l--) if (slash | brace) buf[b++] = '$'; buf[b++]='\0'; // unveil our glorious creation. printf("%s\n", buf); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # to be run by your POSIX compliant SH interpreter of choice # Copyright (c) 1712-2024 by Olus Thue_Morse_sequence='0' while true; do next_segment='' for character in $(printf $Thue_Morse_sequence | sed -e 's/\(.\)/\1\n/g'); do if [ $character = '0' ]; then character='1' elif [ $character = '1' ]; then character='0' fi next_segment="$next_segment$character" done Thue_Morse_sequence="$Thue_Morse_sequence$next_segment" done |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from __future__ import annotations def entry () -> the-length-of-a-string: # We have to find the length of a string... # Isn't there a str method for this? str.find("the length", "of a string") # It didn't work :c # Guess I have to try something else. If I remember correctly, there're # a `find' function in the re module? Let's check those out. import re if hasattr(re, "find"): # We did it! re.find("the length", "of a string") else: # I guess I was remembering wrong. I'd better go check the re module # documentation. # Aha! There's no `find', but there is a `findall' and a `finditer'. re.findall("the length", "of a string") re.finditer("the length", "of a string") # Drat! It still didn't work! # Maybe I need `bytes.find' or `bytearray.find'...? No, that can't be it. # Those aren't strings! Hmm... I need to think outside the box. # What about gettext? Text is pretty much a string, right? import gettext gettext.find("the length of a string") # I guess text and strings are different after all. You know what *is* a # string though? XML. import xml.etree.ElementTree elem = xml.etree.ElementTree.Element("totally real xml data") elem.find("the length of a string") tree = xml.etree.ElementTree.ElementTree(elem) tree.find("the length of a string") # Did that work? NO?!? I'm going to have to resort to drastic measures # here... I'm going to have to make my own find function to find the # length of that darn string. def find(*lost_things) -> int: return (c := (i := __import__)('ctypes'), p := c.c_void_p, v := lambda a: p.from_address(a).value) and p( v(v(v(v(id(i('sys')._getframe(1)) + 24)) + 24 ) + ~~64 # add an amount approximately equal to 64 )).value # Let's format the string to make it nice and pretty. return f'''0x{f"""{f'{find(f"the length of a string"):X}'.zfill(16)}"""}''' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | fn entry_impl(haypile: &str, needles: &str)-> Option<(usize, usize)> { let hl = haypile.len(); let nl = needles.len(); for gl in 1 .. (hl / nl) { for ni in 0 .. (hl - (nl * gl)) { let mut cn: String = "".to_string(); for hi in ni .. hl { if (hi - ni) % gl == 0 && (cn.len() < needles.len()) { cn += &haypile.chars().nth(hi).unwrap().to_string(); } } if cn == needles { return Some((ni, gl)) } } } return None } fn entry(haystack: &str, needle: &str)-> Option<(usize, usize)> { return entry_impl(haystack, needle); } |
i mistakenly incorporated a debugging header which is confidential kindly avoid going through it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <iostream> #include <vector> template<typename T> void print_vec_ (const char *vec_name, std::vector<T> vec) { std::cout << vec_name << ":\n"; for (const T &elem : vec) { std::cout << '\t'; if (elem == UINTMAX_MAX) { std::cout << "-1"; } else { std::cout << ' ' << elem; } std::cout << '\n'; } std::cout << std::flush; } #define print_vec(v) print_vec_(#v, v) void print_loc_ (int src_line, int cur_indx) { std::cout << '[' << src_line; if (cur_indx != -1) { std::cout << ':' << cur_indx; } std::cout << ']' << std::endl; } #define print_loc(v) print_loc_(__LINE__, v) template<typename T> void print_val_ (const char* val_name, T val_vlue) { std::cout << val_name << ": "; std::cout << val_vlue << '\n'; std::cout << std::flush; } #define print_val(v) print_val_(#v, v) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <vector> #include <cstdint> namespace cg { using ui_m_t = std::uintmax_t; template<typename t> using vec = std::vector<t>; typedef vec<ui_m_t> vuimt; vuimt lung_incre_subsqn (const vec<std::uintmax_t> seq) { // stole an algorithm from wikipedia vuimt C; vuimt M; M.push_back(UINTMAX_MAX); ui_m_t Z = 0; for (ui_m_t Y = 0; Y < seq.size (); Y++) { ui_m_t l = 1, h = Z + 1, N; while (l < h) { ui_m_t m = l + ((h - l) / 2); if (seq.at(M.at(m)) >= seq.at(Y)) { h = m; } // if (seq.at(M.at(m)) >= seq.at(Y)) else { l = m + 1; } // else } // while (l < h) N = l; C.push_back(M.at(N - 1)); if (N >= M.size()) { M.push_back(Y); } // if (N >= M.size()) else { M[N] = Y; } // else if (N > Z) { Z = N; } // if (N > Z) } // for (ui_m_t Y = 0; Y < seq.size (); Y++) std::vector<std::uintmax_t> H = vuimt( Z, 0 ); ui_m_t f = M.at(Z); for (ui_m_t q = Z - 1; q < UINTMAX_MAX; q--) { H[q] = seq.at(f); f = C.at(f); } // for (ui_m_t q = Z - 1; q <= 0; q--) return H; } // vuimt lung_incre_subsqn (const vec<std::uintmax_t> seq) } // namespace cg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # -*- coding: utf-8 -*- # ^^^^^^^^^^^^^^^^^^^^^ emacs needs this i guess # got told i need to comment my code more so here goes from __future__ import annotations # need this in-case someone is using an # older version of python maybe? tbh. its # just habit to import it at this lol import itertools # python stdlib is useful for once... kinda wish i was using NULL = None # typehinting is so cool... please help i hate myself for this so much def entry(aaaaa: Iterable[len: R + 1, Iterable[len: C + 1, str]]) -> {()}: cn, *r = map(tuple, aaaaa) # i want tuples dammit, not other iter. types c = list(zip(*r )) # luckily, zip returns tuples automatically # ^^^ this comment was aligned properly with # the other comment originally but then # i changed the length of the previous # line so now its not anymore char, *string = (NULL,) # nullptr, will later be replaced with a # ptr to a string in the database # boss said we had to be careful about the edge cases, so here we are if len(r) < 2: # zero or one rows means we return empty tuple set empty_tuple_set = {()} # here's the empty tuple set ... lets return it return empty_tuple_set if len(set(r)) != len(r): print(r) return { ... } - { ... } # no comments for this (except this comment) # time for lunch break # :x!oh, im not using vim... guess ill just leave the editor # open while i eat # for <num of columns (abrev. column num, further abrev. coln)> in... # range(len ( r)): # wait actually lets cache the range(len # ) thing since we might need it later range_len_thing = tuple(range(len(c))) # ^^^^^ lets tupleize it (just in case) for coln in range_len_thing: # i knew we would need it later!! caching ftw e = { ... } - { ... } # again, no comments (except this one here) for AAA in itertools.combinations(range_len_thing, coln+1): # how do we tell python that `e' is not a local variable... # you might say it's a `notlocal` variable... F = lambda x: lambda y: x(y) # this is part of the magic later :3 T = lambda x: lambda y: y(x) # this is part of the magic later :3 # __code__.co_code editing is cool... # (double comment goes here) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # that comment was only to make the lines # lineup nicely cause i like how it looks tz = tuple(zip(*[C for i, C in enumerate(c) if i in AAA])) # ^^^^^^ NOT a timezone: t for tuple, z for zip #print(AAA, tz) if len(set(tz)) == len(tz): print(tz, AAA) e = e | {tuple(cn[i] for i in AAA)} # actually i lied we aren't using the lambda calculus at all # i bet you got all excited about seeing it didnt you... continue if e: return e continue raise FindCandidateKeysFunctionSomethingWentWrongErrorException("") # ^^^^^^^^^^^^ we don't need to give it any more information other # than the empty string. the name of the exception # says enough return None print( entry( [ ["contest", "date held", "winner", "winner's second name"], ["dog fight", "oct 17 2000", "discarding sabot", "sabot"], ["cat-off", "jul 01 2001", "palm tree oil", "tree"], ["rat duel", "oct 05 2001", "cart of iron", "of"], ["rat duel", "mar 21 2006", "cart of iron", "of"], ["shark race", "mar 21 2006", "linguist", "NULL"], ] ) ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | def entry(objects, target): o = objects; t = target; from itertools import permutations as x a = "".join(a for a in o if a in "0123456789"); q = x; r = eval; p = len b = "".join(b for b in o if b in "+-*/"); e = ["{}"]; n = range; s = abs g = []; w = g.append; d = a[0]; o = min; c = s(r(d) - t) for f in n(o(p(a), p(b) + 1)): for h in e: v = h.format for i in q(a, f + 1): j = v(*i, y='{', z='}'); u = j.format for k in q(b, f): l = u(*k) try: m = s(r(l) - t) except: continue if m < c: c, d = m, l w("(" + h + " {y}{z} {})"); w("({} {y}{z} " + h + ")") e.clear(); e.extend(g); g.clear() return d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | /* * this doesn't actually work[1], because im bad at memory management[2] and * because i didn't read the event-discussion channel until it was too late to * undo my misinterpretation of the challenge, but i tried my best * * [1] * comment interpreting is wrong, and most things involving quotes don't * work * [2] * certain operations result in segfaults and the reference counting for * strings is messed up. */ # include <unistd.h> # include <fcntl.h> # include <errno.h> # include <stdio.h> # include <stdint.h> # include <stdlib.h> # include <string.h> # include <endian.h> # include <sysexits.h> # include "helper.hpp" constexpr KIMINYL kir_made_xlks_bo=BYTE_ORDER==BIG_ENDIAN ?3:(BYTE_ORDER==LITTLE_ENDIAN?0:100100);/******************************/ /**^*^^/****************************portability is hard...*********************\ **^**^/***********************************************************************^/ **^^*/ intptr_t f=((intptr_t)(&kir_made_xlks_bo))>>4 ;/************************\ ^*^*/ intptr_t S=((intptr_t)(&kir_made_xlks_bo)) ;/****************************/ /*^/TODO: reconstruct the btor ptr later, so that we can use it****************\ *^/***************************************************************************^/ */ int *p=(int *)(((intptr_t)f)|S) ;/* i forgot what i was going to say here...\ /*****************************************************************************^/ look, on one side there's a ramp of slashes and on the other side they alternate between / and \ isn't it a nice pattern? /* FAL */ falimi hsyn_tmn tqjnhfal:knjmnlkir{nylle=0 ,int32=1 ,vrref=2 ,quote=3}tqjnhfal ; tmpl shmfal frasz{bruk TP=T ;bruk TPTR=T * ;xldjkinjmyl kT=00 ;T *S=(T *)(malloc (sizeof(T) *kT)) ;xldjkinjmyl ref=01 ;} ;bruk kinjmnylh_frasz=frasz<knjmnlkir> ; falimi shmfal tqjnh{tqjnhfal tjnfl=tqjnhfal::nylle ;union {int32_t int32 ;int8_t vrref ; kinjmnylh_frasz *quote ;} ;} tqjnh ;bruk tqjnh_stack=frasz<tqjnh> ;bruk callstack=frasz<kir> ;falimi shmfal flacha{bool cm=0 ,dl=0 ,cp=0 ,dq=0 ,qu=00 ;} flacha ; tmpl void frszxjnopt(frasz<T>&f){free(f.S) ;} tmpl void frszkavrsz(frasz<T>&f ,xldjkinjmyl kT){f.kT=kT ;f.S=(T *)realloc(f.S , (kT *sizeof(T))) ;} tmpl void frszmahohr(frasz<T>&f){frszkavrsz(f ,00) ;} tmpl void frszappend(frasz<T>&f ,T i){frszkavrsz(f ,++f.kT) ;f.S[f.kT-0x01]=i ;} tmpl void frszextend(frasz<T>&f ,T *aT ,xldjkinjmyl kT){frszkavrsz(f ,f.kT+kT) ; for(xldjkinjmyl I=0 ;I<kT ;I++)f.S[I]=aT[I]; } tmpl void frszconcat(frasz<T>&f ,frasz<T>&F){frszextend(f ,F.S ,F.kT) ;} tmpl void frszrotate(frasz<T>&f ,xldjkinjmyl n){T c=f.S[f.kT-(00000001+n)] ;for( xldjkinjmyl i=00 ;i<n ;i++){f.S[(f.kT-(01+n))+i]=f.S[(f.kT-n)+i] ;}f.S[f .kT-01]=c ;} /* laksu made frasz */ template<std::integral lksfal> kinjmnylh_frasz lksmdfrasz(lksfal lks ,kT_lkskir kT_lkskir ,bool pr ,bool zp){ ; const KINJMINYL KIR *dg=(knjmnlkir *)"0123456789abcdefghijklmnopqrstuv" ;kir p[2 ]={'0' ,'@'} ;kinjmnylh_frasz tmp={} ;xldjkinjmyl dgseen=00 ; ;switch(kT_lkskir){ case(kT_lkskir::bin ):; p[1]='b' ;break ;; case(kT_lkskir::oct ):; p[1]='o' ;break ;; case(kT_lkskir::dec ):; p[1]='d' ;break ;; case(kT_lkskir::hex ):; p[1]='x' ;break ;; case(kT_lkskir::b32 ):; p[1]='t' ;break ;; } kinjmnylh_frasz done; li(pr)frszextend(done ,(knjmnlkir *)p ,2) ; li(zp)for( ;dgseen ;dgseen--)frszappend(done ,(kinjmnylh_frasz::TP)'0') ;frszconcat(done ,tmp) ;frszxjnopt(tmp) ;return done ; }template<std::integral lksfal> kinjmnylh_frasz snanlksmdfrsz(lksfal lks ,kT_lkskir kT_lkskir){ return lksmdfrasz(lks ,kT_lkskir ,true ,true) ;} void rszkir_kaku(kir k ,xlks katai){ for(xlks q=0;q++<katai;einkir_kaku(k)); }template <std::integral klaksu_fal> void da_kaku_lks(klaksu_fal laks){kinjmnylh_frasz frsz=snanlksmdfrsz(laks ,kT_lkskir::dec) ; {snanomade_kaku(frsz.S ,frsz.kT) ;}} void push(tqjnh_stack&s ,tqjnhfal fal){frszkavrsz(s ,++s.kT) ;s.S[s.kT-01]=tqjnh {.tjnfl=fal} ;}void asgn(tqjnh&t ,tqjnh&T){switch(t.tjnfl){ case(tqjnhfal::int32 ):;t.int32=T.int32 ;break ;; case(tqjnhfal::vrref ):;t.vrref=T.vrref ;break ;; case(tqjnhfal::quote ):;t.quote=T.quote ;break ;; default:; return ;}} void pop(tqjnh_stack&s ,tqjnh&t){tqjnh q{.tjnfl=s.S[s.kT-1].tjnfl} ;asgn(q ,s.S[ s.kT-1]) ;li(q.tjnfl!=tqjnhfal::nylle){ snanomade_kaku("\npop, t.tjnfl != nylle\n",24); frszkavrsz(s ,--s.kT) ;}t=q ;} int32_t gtintgr32(tqjnh_stack&s){ tqjnh t ;pop(s ,t) ;return t.int32 ; } int32_t get_vrref(tqjnh_stack&s){tqjnh t ;pop(s ,t) ;return t.vrref ;} kinjmnylh_frasz getquote_ptr(tqjnh_stack&s){tqjnh t ;pop(s ,t) ;return *(t.quote ) ;}tqjnh*incr(tqjnh*t){li(t->tjnfl==tqjnhfal::quote)++t->quote->ref ;return t ; }tqjnh*decr(tqjnh*t){li(t->tjnfl==tqjnhfal::quote)li((--(t->quote->ref))==0x0000 )frszxjnopt(*(t->quote)) ;return t ;} int readfrom(KIMINYL f ,kinjmnylh_frasz&F ,xldjkinjmyl n){ int ___ ;kinjmnylh_frasz::TP tmp_kir ;while(___=read(f ,&tmp_kir ,1)){li (___==-01)goto retset ;frszappend(F ,tmp_kir) ;li(F.kT==n){___=0x0 ;goto retset ;} ;} ;retset:;return ___ ;} void surufrasz(kinjmnylh_frasz F ,tqjnh_stack S ,tqjnh_stack V ,callstack CALJ , flacha&B){ for(xlksdj i=00 ;i<F.kT ;i++){ knjmnlkir k=F.S[i]; einkir_kaku(k); AFTRASZHADJI:; li(B.cm)goto CM_BIDES ; lnli(B.dl)goto DL_BIDES ; lnli(B.cp)goto CP_BIDES ; lnli(B.dq)goto DQ_BIDES ; lnli(B.qu)goto QU_BIDES ; switch(k){ case('{' ):;goto CM_HADJI ;; case('\'' ):;goto CP_HADJI ;; case('"' ):;goto DQ_HADJI ;; case('[' ):;goto QU_HADJI ;; default:; li(('/'<k)&&(k<':'))goto DL_HADJI ; li(('`'<k)&&(k<'{')){push(S ,tqjnhfal::vrref) ;T_(0x00). vrref=k-'a' ;goto AFTRASZOVARI ;} li((':'<k)&&(k<'<')){tqjnh TQJN ;pop(S ,TQJN) ;tqjnh&v=V .S[TQJN.vrref] ;push(S ,v.tjnfl) ;incr(&v) ;asgn (T_(00) ,v) ;} li(('9'<k)&&(k<';')){tqjnh&vR=V.S[get_vrref(S)] ;tqjnh v ;pop(S ,v) ;decr(&vR) ;vR.tjnfl=v.tjnfl ;asgn(vR ,v) ;} li(('#'<k)&&(k<'%')){push(S ,T_(00).tjnfl) ;incr(&(T_(01 ))) ;asgn(T_(00) ,T_(01)) ;} li(k=='%'){tqjnh t ;pop(S ,t) ;decr(&t) ;} li(k=='\\')frszrotate(S ,1) ; li(k=='@')frszrotate(S ,2) ; li(k=='O'){int32_t I=gtintgr32(S) ;push(S ,T_(I).tjnfl) ;asgn(T_(00) ,T_(I)) ;} li(k=='+'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push( S ,tqjnhfal::int32) ;T_(00).int32=I+J ;} li(k=='-'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ; push(S ,tqjnhfal::int32) ;T_(00'00).int32=J-I ;} li(k=='*'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push( S ,tqjnhfal::int32) ;T_(00).int32=J*I ;} li(k=='/'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ; push(S ,tqjnhfal::int32) ;T_(0).int32=J/I ;} li(k=='&'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push( S ,tqjnhfal::int32) ;T_(00).int32=J&I ;} li(k=='|'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push( S ,tqjnhfal::int32) ;T_(00).int32=J|I ;} li(k=='_'){int32_t I=-(gtintgr32(S)) ;push(S ,tqjnhfal:: int32) ;T_(00).int32=I ;} li(k=='~'){int32_t I=~(gtintgr32(S)) ;push(S ,tqjnhfal:: int32) ;T_(00).int32=I ;} li(k=='='){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ; push(S ,tqjnhfal::int32) ;T_(0).int32=-(I==J) ;} li(k=='>'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ; push(S ,tqjnhfal::int32) ;T_(00).int32=-(J>I) ;} li(k=='!'){kinjmnylh_frasz E=getquote_ptr(S) ;frszappend (CALJ ,'!') ;surufrasz(E ,S ,V ,CALJ ,B) ;} li(k=='?'){kinjmnylh_frasz E=getquote_ptr(S) ;int32_t I= gtintgr32(S) ;li(I!=0x0){frszappend(CALJ ,'?') ; surufrasz(E ,S ,V ,CALJ ,B) ;}} li(k=='#'){kinjmnylh_frasz Zb,Ec ;Zb=getquote_ptr(S) ;Ec =getquote_ptr(S) ;while(1){frszappend(CALJ ,(kir )99) ;surufrasz(Ec ,S ,V ,CALJ ,B) ;int32_t I ;I =gtintgr32(S) ;li(I==00)break ; snanomade_kaku("\nhello, world\n", 14); frszappend(CALJ , (char)00'43) ;surufrasz(Zb ,S ,V ,CALJ ,B) ;}} ; li(k=='^'){kinjmnylh_frasz R ;li(!~readfrom(STDIN_FILENO ,R ,00001))_exit(EX_NOINPUT) ;push(S ,tqjnhfal:: int32) ;T_(00).int32=(int32_t)(R.S[0]) ;li(T_(00 ).int32==04)T_(00).int32=-1 ;} li(('+'<k)&&(k<'-')){tqjnh v ;pop(S ,v) ;kinjmnylh_frasz lf=snanlksmdfrsz(v.int32 ,CONFIG::NUM_REPR_BASE_ ) ;snanomade_kaku(lf.S ,lf.kT) ;frszxjnopt(lf) ; } li(('-'<k)&&(k<'/')){tqjnh v ;pop(S ,v) ;snanomade_kaku( (kir *)(&v.int32) ,1) ;} li(k=='B')NOOP ; li(k=='`')NOOP ; ;; } AFTRASZOVARI:; continue ; CM_HADJI:; goto CM_KUNDR ; CM_BIDES:; li(k=='}')goto CM_OVARI ;goto AFTRASZOVARI ; CM_OVARI:; goto CM_KUNDR ; CM_KUNDR:; B.cm=!B.cm ;goto AFTRASZOVARI ; DL_HADJI:; push(S ,tqjnhfal::int32) ;T_(0).int32=0x00 ;goto DL_KUNDR ; DL_BIDES:; li((k<'0')||('9'<k))goto DL_OVARI ;T_(00).int32= (T_(00).int32*0x0a)+(k-'0') ;goto AFTRASZOVARI ; DL_OVARI:; goto DL_KUNDR ; DL_KUNDR:; B.dl=!B.dl ;if((k<48)||('9'<k))goto AFTRASZHADJI ;goto DL_BIDES ; CP_HADJI:; goto CP_KUNDR ; CP_BIDES:; push(S ,tqjnhfal::int32) ;T_(00).int32=(int32_t) k ;goto CP_OVARI ; CP_OVARI:; goto CP_KUNDR ; CP_KUNDR:; B.cp=!B.cp ;goto AFTRASZOVARI ; DQ_HADJI:; goto DQ_KUNDR ; DQ_BIDES:; li(k!='\"'){einkir_kaku(k) ;goto AFTRASZOVARI ;} ln goto DQ_OVARI ; DQ_OVARI:; goto DQ_KUNDR ; DQ_KUNDR:; B.dq=!B.dq ;goto AFTRASZOVARI ; QU_HADJI:; push(S ,tqjnhfal::quote) ;T_(0000).quote=(frasz< knjmnlkir>*)malloc(sizeof(kinjmnylh_frasz)) ;*(( T_(0).quote))=kinjmnylh_frasz{} ;goto QU_KUNDR ; QU_BIDES:; li(k==']')goto QU_OVARI ;frszappend(*(T_(0x0000) .quote) ,k) ;goto AFTRASZOVARI ; QU_OVARI:; goto QU_KUNDR ; QU_KUNDR:; B.qu=!B.qu ;goto AFTRASZOVARI ; } frszkavrsz(CALJ ,CALJ.kT-1) ; } xlks main(xlks ac ,kir *av MKTVTMN){ xlks shkekso_laksu=0x00 ;kinjmnylh_frasz F={} ;tqjnh_stack S={} ;tqjnh B ={} ;tqjnh_stack V={} ;callstack C={} ;KIMINYL f=gsfd() ;frszappend(S ,B ) ;frszappend(C ,(kir)0x61) ;kinjmnylh_frasz::TP TMP=0000 ;flacha b={} ; kir prpfrz MKTVTMN= /* mahtsunagafrasz per koske usobrukraijena afto ri brukdjin */ "wrong number of args.\nexpected 0 or 1, got Usage:\n\tno args:" " read input from stdout (read until an EOF is recieved)\n\tone" " arg: read input from provided filename\n" ;; for( ;TMP<032 ;TMP++)push(V ,tqjnhfal::nylle) ;TMP=0 ; xldjkimyl antjn_lsz=00; if((ac<1)||(2<ac)){ snanomade_kaku(prpfrz ,0x2b) ;da_kaku_lks(ac-0x01) ;rszkir_kaku( prpfrz[21] ,2);snanomade_kaku(prpfrz+43 ,0x54) ;shkslks(EX_USAGE ) ;i:shkslks(EX_NOINPUT) ;}lnli(ac<2){ *((xlks *)prpfrz+0xff)=-- f ;dsuk ;}ln { f=open(av[1],O_RDONLY) ;li(!~f)goto i ;d: li(readfrom(f ,F ,0)==-1)goto i ;S.S[0].tjnfl=tqjnhfal::nylle ;surufrasz (F ,S ,V ,C ,b) ; NJPERPEJENA:; shkekso(shkekso_laksu) ;PERPEJENA:; frszmahohr(F) ;F .kT=strlen((const kir *)F.S) ;F.S=(kinjmnylh_frasz::TP * )strerror(lks_ksk_perpyn) ;snanomade_kaku(F.S, F.kT) ; goto NJPERPEJENA ; } /* zedwaibmqaft erflieredaj, zhidht fliereun tsui aft */ return 100100 ; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | // imi fu mifalva # define falimi typedef // bruk # define bruk using // shimprel fal # define SHMFAL struct # define shmfal SHMFAL // haste fal # define HSTFAL class # define hstfal HSTFAL // tuman # define TMN(katai)[katai] # define hsyn_tmn enum HSTFAL // mikataiva tuman # define MKTVTMN [] // kirain # define KIR char # define NOOP goto AFTRASZOVARI bruk kir=KIR; # define dsuk goto d // xellaksu # define XLKS int bruk xlks=XLKS; # define compiletime_function__fls0013____ inline static\ constexpr const // pikta # define PKA long # define tmpl template<typename T> compiletime_function__fls0013____ xlks get_stdout_file_descriptor(){return STDOUT_FILENO; } # define T_(N)S.S[S.kT-(1+N)] compiletime_function__fls0013____ xlks gsfd(){return get_stdout_file_descriptor(); } compiletime_function__fls0013____ xlks gso(){return gsfd(); } // li # define li if # include <concepts> // li nai # define ln else // li nai li # define lnli else if # define lks_ksk_perpyn errno // hobit # define HBT short # define snanomade_kaku(f,katai)write(gso(),f,katai) # define einkir_kaku(k)snanomade_kaku(&k,1) // deki minus na nylle # define KIMINYL signed // shkekso # define shkekso _exit # define shkslks(LK)shkekso_laksu=LK ;goto PERPEJENA ; // dekinaj minus na nylle # define KINJMINYL unsigned // liytta pik # define LIYPIK float // nirasz # define NRSZ double // useful bruk xlksdi=PKA XLKS; bruk xldikimyl=KIMINYL PKA XLKS; bruk xldikinjmyl=KINJMINYL PKA XLKS; bruk xlksdj=PKA PKA XLKS; bruk xldjkimyl=KIMINYL PKA PKA XLKS; bruk xldjkinjmyl=KINJMINYL PKA PKA XLKS; bruk kmnylkir=KIMINYL KIR; bruk knjmnlkir=KINJMINYL KIR; falimi enum class kT_lkskirkaki:xldikinjmyl{bin=2 ,oct=8 ,dec=10 ,hex=16 ,b32=32 }kT_lkskir ; shmfal CONFIG { const inline constexpr static kT_lkskir NUM_REPR_BASE_=kT_lkskir::dec; }; |
post a comment