olivecoder
  • Member for 9 years, 4 months
  • Last seen more than a month ago
Is string X a subsequence of string Y?
4 votes

C, 23: while(*y)*x-*y++?0:x++; result in *x http://ideone.com/BpITZ

View answer
Interpret brainf***
3 votes

[EDIT] C++11, 318, reads from file: #include <bits/stdc++.h> char b[99999]={0},g[99999]={0},*f=g,*p=b;std::function<void()>m[128]={[43]=[]{++*p;},[]{*p=getchar();},[]{--*p;},[]{putchar(*p);...

View answer
When does (x == x+2)?
3 votes

C If you evaluate x == x+2 directly you will get a false, but I think it is interesting because it makes usage of a different language feature. #include <stdio.h> typedef struct { int bit:1;...

View answer
calculate days of a month
3 votes

I've already answered it before in stackoverflow: (62648012>>m*2&3)+28+(m==2&&y%4==0) https://stackoverflow.com/questions/2675720/calculate-days-of-month/11675530#11675530 [EDIT] ...

View answer
Visualise long multiplication with ASCII art
1 votes

Python, 145, another answer with a little bit different output. Code a,b=input();h=6*'-';print'\n'.join(["%6i\nx%5i\n%s"%(a,b,h)]+["%%%ii"%(6-i)%(int(d)%10*a)for i,d in enumerate(str(b)[::-1])]+["%s\...

View answer
Visualise long multiplication with ASCII art
1 votes

Python, 174 170: a,b=input();r,s=str(a),str(b);h=len(r+s)*'-';print'\n'.join(["%9s\n%9s\n%9s"%(r,'x'+s,h)]+["%%%ii"%(9-i)%(int(d)%10*a)for i,d in enumerate(s[::-1])]+["%9s\n%9i"%(h,a*b)]) Usage: ...

View answer
Generate a valid sequence of numbers with specific rules
0 votes

Python,30: ' 3579'[:(1+x)/2]+'1468'[:x/2]+'2' http://ideone.com/3csRh

View answer
Generate a valid sequence of numbers with specific rules
0 votes

Python, 37 range(3,x+1,2)+[1]+range(4,x+1,2)+[2]) http://ideone.com/xK40m

View answer