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

Pages: 1-

enterprise dubs checker

Name: Anonymous 2012-04-10 21:46

#!/bin/bash
# fuck you faggot
echo "enter 0-9, faggot"
echo "this shit will check for dubs"
echo -n "digit 1:"
read digit1
echo -n "digit 2:"
read digit2
if test "$digit1" = "$digit2"
then
   echo "nice dubs bro"
else
   echo "sorry bro, not dubs"
fi
echo "back to /b/, please"

Name: Anonymous 2012-04-10 21:50

> #!/bin/bash

IHBT

Name: Anonymous 2012-04-10 21:51

>>2
YHNBT
NIJMUA

Name: Anonymous 2012-04-10 22:03

>>3

YTMND

Name: Anonymous 2012-04-10 22:04

>>4
BTBP

Name: Anonymous 2012-04-10 22:12

>>1'
>his code can't check for dubs in other bases

Name: Anonymous 2012-04-10 22:13

>>5

/PCK/

BTIBP, ``F''

Name: Anonymous 2012-04-10 22:25

>>6
technically it can, if you think about it
for example, 11 is dubs both in binary and decimal

Name: Rob Pike 2012-04-10 23:13


int isdubs(int a, int b)
{
        return a == b ? 1 : 0;
}

Name: Anonymous 2012-04-11 0:15

>>9
AHURRR HURHRURHUR HAV U RED U SCIP 2DAY *DANCES AROUND LIKE A JACKASS*


int isdubs(int a, int b)
{
        return a == b;
}

Name: Anonymous 2012-04-11 0:17

>>10
Now do it in Scheme.

Name: Anonymous 2012-04-11 0:29

>>11
DO MY ANUS

Name: Anonymous 2012-04-11 1:02

(define (dubs? number base)
  (zero? (modulo (modulo number (expt base 2)) (+ base 1))))

Name: Anonymous 2012-04-11 1:35



boolean isDoubles(int checkem){

  if(String(checkem).length < 2){
    return false;
  }

  for(int i=0; i<10; ++i){
    if(String(checkem).indexOf(String(i)+String(i)) = String(checkem).length - 2){
      return true;
    }
  }
  return false;
}


ENTERPRIES

Name: Anonymous 2012-04-11 1:42

iscodroolpels:

HOOKIE KA DOOKIE U WINNER

Name: Anonymous 2012-04-11 2:19

PROC check em = (INT n, base) BOOL : n %* base = (n % base) %* base;
PROC (INT) BOOL binary dubs = check em(, 2);
print((check em(144, 10), binary dubs(14), binary dubs(3)))

Name: Anonymous 2012-04-11 5:49

#include <stdio.h>
#include <stdlib.h>
#define MAX_BASE 36
#include <math.h>
const char *alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWYZ";
const char *names[] = {
  NULL, NULL, "dubs", "trips",
  "quads", "quints", "sexts",
  "septs", "octs", "nons",
};

/* Actual dubs checking: four lines of code. */
int check(int num, int base) {
  int count = 0, digit = num % base;
  while (num % base == digit) {
    count++; num /= base;
  }
  return count;
}
void print_(int num, int b) {
  int n = 0;
  do {
    n++;
  }while(num/=b);
  int i = n;
  for(; i > 0; i--) {
    putchar(alphabet[num/(int)pow(b,i) % b]);
  }
}
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <postnum>\n", argv[0]);
    return 1;
  }

  int postnum = atoi(argv[1]), base, result;

  if (postnum <= 0) {
    fprintf(stderr, "Invalid post number: %s\n", argv[1]);
    return 1;
  }

  for (base = 2; base < postnum && base < MAX_BASE; base++) {
    result = check(postnum, base);
    if (result < 2) continue;

    if (result >= 10) {
      printf("* %ds in base %d: ", result, base);
    } else {
      printf("* %s in base %d: ", names[result], base);
    }

    while (result--) {
      putchar(alphabet[postnum % base]);
    }
    print_(postnum, base);
    putchar('\n');
  }

  return 0;
}

Name: Anonymous 2012-04-11 7:40

dubs = lambda x: (int(x) / 100) % 11 == 0)

Name: >>18 2012-04-11 7:41

Obviously the final ) is a bug.

Also non-FIOC FIOC code

Name: Anonymous 2012-04-11 12:42

>>18

U MENA int(x) % 11

Name: Anonymous 2012-04-11 14:20

>>20

NO 211 % 11 == 2

Name: Anonymous 2012-04-11 15:28

int digits, x=1; bool repeat=FALSE;cin << digits;
while( ((digits/10)%10==digits%10) ){repeat=TRUE; x++; digits=(digits - (digits%10))/10;}
if(repeat) return x;
else segfault();

Name: Anonymous 2012-04-11 16:08

def dubs_checker(number):
    number = number - number / 100
    if len(str(number)) == 2:
        digit1, digit2 = str(number)[0], str(number)[1]
        digit1 = int(digit1)
        digit2 = int(digit2)
        if digit1 == digit2:
            return True
        else:
            return False
    else:
        raise Exception("Number is the wrong size!")


[b][i]LEAH QUALITY[i][/b]

Name: Anonymous 2012-04-11 17:01

x % 100 % 11

Name: Anonymous 2012-04-11 17:32

If you check it, mine isn't explicitly for dubs, but returns however many times the (singular) digits repeat from left to right, as a symbolic function (it isn't named or declared etc but it can be ENTERPRISE SCALED to resolve run-time requirements). A function with a wider scope (patterns such as '1212' ie not comparing just singular digits) would require something more sophisticated with more lines but that would mean I would actually have to program.

Name: bampu pantsu 2012-05-29 4:19

bampu pantsu

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