d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Yo, Canadians
Prev11011121314Next
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 7 2011 12:31am
http://codepad.org/yQWWJ33A

the efficiency of 9 using that algo is 0.473684


edit:: betta step back kids before i #define you as mine... or ill just make a gay ass struct and name it after you like

Code
typedef struct{
    char *im;
    int  gay;
} beakpoint;


Code
#include <stdio.h>
#include <stdlib.h>

int odd(int a);
float algo(float a);


int main()
{
   float result = algo(9);
   printf("\n\nEffeciency: %f\n\n", result);
   return 0;
}

float algo(float a)
{
   float temp = a;
   float rounds = 0;

   printf("%.0f> ", temp);

   while(temp != 1)
   {

   rounds += 1;

       if(odd(temp) == 1)
       {
           temp = temp * 3 + 1;
           printf("%.0f> ", temp);
       }
       else if(odd(temp) == 0)
       {
           temp = temp / 2;
           printf("%.0f> ", temp);
       }
   }
return a / rounds;
}

int odd(int a)
{
   if((a % 2) == 1)
       return 1;
   else
       return 0;
}


This post was edited by AbDuCt on Jun 7 2011 12:40am
Member
Posts: 6,522
Joined: Jun 5 2008
Gold: 0.00
Jun 7 2011 12:36am
Quote (AbDuCt @ Jun 7 2011 01:31am)
http://codepad.org/yQWWJ33A

the efficiency of 9 using that algo is 0.473684

where 1 is 100% efficient and 0.0 is 0% efficient

edit:: betta step back kids before i #define you as mine... or ill just make a gay ass struct and name it after you like

Code
typedef struct{
    char *im;
    [B]int     gay[/B];
} beakpoint;




waitwut

you can't define that as an integer.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 7 2011 12:39am
Quote (DeadShell @ Jun 6 2011 11:36pm)
waitwut

you can't define that as an integer.


why not D:
Member
Posts: 6,522
Joined: Jun 5 2008
Gold: 0.00
Jun 7 2011 12:51am
Quote (AbDuCt @ Jun 7 2011 01:39am)
why not D:


CAUSE IT"S GAY

now duct, tell me why there are errors in this. Python breaks my balls, it's too format whore for me.

Code
from Tkinter import *
from tkMessageBox import showerror
import shelve

shelvename = 'class-shelve'
fieldnames = ('name', 'age', 'job', 'pay')

def makeWidgets():
   global entries
   window = Tk()
   window.title('Records Entry')
   form = Frame(window)
   labels = Frame(form)
   values = Frame(form)
   labels.pack(side=LEFT)
   values.pack(side=RIGHT)
   form.pack()
   entries = {}
   for label in ('key',) + fieldnames:
       Label(labels, text=label).pack()
       ent = Entry(values)
       ent.pack()
       entries[label] = ent
   Button(window, text="Fetch", command=fetchRecord).pack(side=LEFT)
   Button(window, text="Update", command=updateRecord).pack(side=LEFT)
   Button(window, text="Quit", command=window.quit).pack(side=RIGHT)
   return window

def fetchRecord():
   key = entries['key'].get()
   try:
       record = db[key]
   except:
       showerror(title='Error', message='No such key')
   else:
       for field in fieldnames:
           entries[field].delete(0, END)
           entries[field].insert(0, repr(getattr(record, field)))

def updateRecord():
   key = entries['key'].get()
   if key in db.keys():
       record = db[key]
   else:
       from person import Person
       record = Person(name='?', age='?')
   for field in fieldnames:
       setattr(record, field, eval(entries[field].get()))
   db[key] = record

   db = shelve.open(shelvename)
window = makeWidgets()
window.mainloop()
db.close()
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Jun 7 2011 05:20am
Quote (Anthraxinsoup @ Jun 6 2011 07:18pm)
Iain'tevenmadtho.

I'm happy cause I just got an interview at bestbuy and can do Intel Retail edge.


You'll fit right in with the rest of the douchebags that work at Best Buy.
Member
Posts: 13,630
Joined: Dec 4 2009
Gold: 0.00
Jun 7 2011 10:03am
Quote (DeadShell @ Jun 6 2011 11:51pm)
CAUSE IT"S GAY

now duct, tell me why there are errors in this. Python breaks my balls, it's too format whore for me.

Codefrom Tkinter import *
from tkMessageBox import showerror
import shelve

shelvename = 'class-shelve'
fieldnames = ('name', 'age', 'job', 'pay')

def makeWidgets():
    global entries
    window = Tk()
    window.title('Records Entry')
    form = Frame(window)
    labels = Frame(form)
    values = Frame(form)
    labels.pack(side=LEFT)
    values.pack(side=RIGHT)
    form.pack()
    entries = {}
    for label in ('key',) + fieldnames:
        Label(labels, text=label).pack()
        ent = Entry(values)
        ent.pack()
        entries[label] = ent
    Button(window, text="Fetch", command=fetchRecord).pack(side=LEFT)
    Button(window, text="Update", command=updateRecord).pack(side=LEFT)
    Button(window, text="Quit", command=window.quit).pack(side=RIGHT)
    return window

def fetchRecord():
    key = entries['key'].get()
    try:
        record = db[key]
    except:
        showerror(title='Error', message='No such key')
    else:
        for field in fieldnames:
            entries[field].delete(0, END)
            entries[field].insert(0, repr(getattr(record, field)))

def updateRecord():
    key = entries['key'].get()
    if key in db.keys():
        record = db[key]
    else:
        from person import Person
        record = Person(name='?', age='?')
    for field in fieldnames:
        setattr(record, field, eval(entries[field].get()))
    db[key] = record

    db = shelve.open(shelvename)
window = makeWidgets()
window.mainloop()
db.close()


Your first for loop seems a bit weird. Change it to
Code
for label in ('key') and fieldnames:
       Label(labels, text=label).pack()
       ent = Entry(values)
       ent.pack()
       entries[label] = ent


Just guessing here, so I could be wrong.

Quote (rockonkenshin @ Jun 7 2011 04:20am)
You'll fit right in with the rest of the douchebags that work at Best Buy.


I'm trying to get a job there. :(

This post was edited by BreakPoint on Jun 7 2011 10:04am
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Jun 7 2011 10:28am
Quote (BreakPoint @ Jun 7 2011 12:03pm)

I'm trying to get a job there. :(


My condolences.
Member
Posts: 27,059
Joined: Nov 29 2006
Gold: 67.00
Jun 7 2011 10:30am
Quote (rockonkenshin @ Jun 7 2011 06:20am)
You'll fit right in with the rest of the douchebags that work at Best Buy.


:lol: duck works there
Member
Posts: 13,630
Joined: Dec 4 2009
Gold: 0.00
Jun 7 2011 10:32am
Quote (rockonkenshin @ Jun 7 2011 09:28am)
My condolences.


Hey mang, the way I see it, it's leap and bounds better than being some grunt for a local wood shop. <_<
Member
Posts: 27,059
Joined: Nov 29 2006
Gold: 67.00
Jun 7 2011 10:35am
Quote (BreakPoint @ Jun 7 2011 11:32am)
Hey mang, the way I see it, it's leap and bounds better than being some grunt for a local wood shop. <_<


You'll be forced to sell some 40 year old guy $100 ram that he could buy for $40 on newegg. And you'll have to tell him it's a good deal and ask if he wants the $30 warranty on it too

:( I couldn't do it
Go Back To Computers & IT Topic List
Prev11011121314Next
Add Reply New Topic New Poll