Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Most C programmers are faggots

Name: Anonymous 2012-01-29 19:36

I'm getting really irritated at a lot of self proclaimed C programmers for abusing the fuck out structures and pointers. It's easy to get out of hand and make your code look like shit and it seems people want to do it even when it's not necessary. The problem is even a lot of legitimately experienced C programmers do the same shit. Go look at the source to your favorite software written in C.

A good example is that stupid dubs checker thread that faggot just made. It should be written like this


#include <stdio.h>

#define base 10

int check(int i, int b) {
  return(i%b == (i/b)%b);
}

int main(void) {
  int i = 1;
 
  while(i++ < 100)
    if(check(i, base))
      puts("nice dubs bro");
     
  return(0);
}

Name: Anonymous 2012-01-31 15:11

11^2 get

Name: Anonymous 2012-01-31 15:54

Check em

Name: Anonymous 2012-01-31 17:46

check 'em base 122 dubs

Name: Anonymous 2012-01-31 18:20

Name: Anonymous 2012-01-31 20:52

if (post_number & 0b1 && post_number & ob10){
    //Binary dubs
}

Name: Anonymous 2012-01-31 20:58

>>125
s/ob1/0b1/

Name: Anonymous 2012-01-31 21:35

>>125

Not portable


if ((post_number & 1) && (post_number & 2)){
    //Binary dubs
}

Name: Anonymous 2012-01-31 21:54

>>127
u mena: ( (post_number & 1) == ((post_number >>1) & 1) )

Name: Anonymous 2012-01-31 22:57

>>114


int checkem(int n) {
  return n%11 == n/100;
}

Name: Anonymous 2012-01-31 23:35

if (postnumber & 3 == 3){
   //Binary dubs
}

Name: Anonymous 2012-01-31 23:50


efinition 1.1:

  An integer n, is said to have dubz in base b, if and only if the following is satisfied:

                          n mod b = floor(n/b) mod b

Theorem 1.1:

  Let n be an integer, b be a base, and let r = n mod b. Then n has dubz in base b if and only if:

                          n mod b^2 = r(b + 1)

Proof:
 Part 1:
  First assume that n has dubz in base b, with r = n mod b. We will show that n mod b^2 = r(b + 1)

  Decompose n into its quotient and remainder, q and r:

                          n = qb + r

  We have that floor(n/b) = q. Because n has dubz in b, we have the following:

                          n mod b = floor(n/b) mod b
                          n mod b = q mod b

  So q will have remainder r when divided by b. Let p be the quotient of q and r.

                          q = pb + r
                          n = qb + r    q = pb + r
                          n = (pb + r)b + r
                          n = pb^2 + rb + r
                          n = pb^2 + r(b + 1)
                          n mod b^2 = r(b + 1)

  And we have arrived at the needed conclusion.

 Part 2:
  Now suppose that n satisfies:

                          n mod b^2 = r(b + 1)

  where r = n mod b. We would like to show that n has dubz in base b. The steps are essentially
  the same as Part 1 in reverse:

                          n mod b^2 = r(b + 1)

  Let p be the quotient of n and b^2. We can express n in terms of its quotient and remainder with b^2.

                          n = pb^2 + r(b + 1)
                          n = pb^2 + rb + r
                          n = (pb + r)b + r

  We have now decomposed n into its remainder and quotient of b, and found the quotient to be q = pb + r.
  But q has remainder r when divided by b, the same remainder that n has when divided by b.

                          n = qb + r    q = pb + r
                          n mod b = q mod b
                          n mod b = floor(n/b) mod b

  Thus, we have shown that n mod b yields the same remainder as floor(n/b) mod b. Therefore n has dubz in base b.

Theorem 1.2:

  to be written by >>132 san.

Name: 131 2012-02-01 0:01

>>131

waaitt! that's wrong. sorry. It should be:


                          n mod b^2 = r(b + 1) mod b^2


We can't always assume that 0 <= r(b + 1) < b^2, or can we...update soon...

Name: >>131 2012-02-01 0:03

>>132
 that probably messes up the if and only if part too, woe is me

Name: >>133 2012-02-01 0:13

nevermind, it's alright:


0 <= r < b
0 <= r <= b - 1
0 <= r(b + 1) <= (b - 1)(b + 1) = b^2 - 1 < b^2
0 <= r(b + 1) < b^2

Name: Anonymous 2012-02-01 1:00

>>131

*is reverse engineering that explanation =D

// does it not detect 122 as a dub? / as opposed to 221

Name: Anonymous 2012-02-01 1:16

**more like trying to anyway D=
// or does get 122 & not 221?

212??



r1 = n mod b;
r2 = floor(n/b) mod b;
r3 = floor(n/ (b*b)) mod b;

if((out = r1==r2 + r2==r3 + r1==r3) > 0) puts("nice dubs.?");

Name: Anonymous 2012-02-01 2:52

>>135

yeah, only the least significant dubs are detected.

>>136

so that would do if at least two of the lesser three significant digits are equal

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List