Guest User

AoC 9 Part 1 nomalloc.

a guest
Dec 9th, 2016
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char** argv)
  4. {
  5.     unsigned long int count = 0;
  6.     char c;
  7.     while((c=getchar())!= EOF){
  8.         if(c=='('){
  9.             int len;
  10.             scanf("%d", &len);
  11.             getchar();//discard x
  12.             int i;
  13.             scanf("%d", &i);
  14.             getchar();//discard )
  15.             for(;len>0;len--){
  16.                 getchar();
  17.                 count += i;
  18.             }
  19.         }else{count++;}
  20.     }
  21.     printf("%lu", count-1);//eof still isn't a character
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment