use Inline C; print "answer is ", bitlevels(), "\n"; __END__ __C__ /* begin c++ code */ /* #include */ /* using namespace std; */ int bitlevels() { unsigned int ans=0; int num, total, i; unsigned int shift; for(num=0;num<16777216;++num) { total=0; shift=1; for(i=1;i<=24;++i) { if(num & shift) { total+=i; } else { total-=i; } shift<<=1; } if(total==0) ++ans; } return ans; } /* end c++ code */