bored, give me a program to write.

Discussion in 'Programming & Software Development' started by Foliage, Jan 22, 2012.

  1. OP
    OP
    Foliage

    Foliage Member

    Joined:
    Jan 22, 2002
    Messages:
    31,967
    Location:
    Sleepwithyourdadelaide
  2. ShadowBurger

    ShadowBurger Member

    Joined:
    Feb 19, 2008
    Messages:
    1,394
    Location:
    Melbourne
    that's bloody awesome, nicely done! It's just a shame one has to own a Ford to have a use for it ;) :D

    EDIT: quick question - how do the professional and workshop licenses work? just curious. ie. can vehicles be removed from the list of 6x vehicle licenses? I would imagine a workshop would see a large volume of vehicles which would only ever see a handful of flashes each... perhaps a premises based license / subscription model would be better suited to that environment? $0.02

    PS. are you cluey about flashing Toyotas? I've always wondered what my CVT gearbox would be like without the bullshit 'gear simulator' programming that it has
     
    Last edited: May 15, 2018
  3. OP
    OP
    Foliage

    Foliage Member

    Joined:
    Jan 22, 2002
    Messages:
    31,967
    Location:
    Sleepwithyourdadelaide
    What do you mean removed? Most of our workshop customers just buy licenses in bulk at the moment. Eg they might spend $500-1000 on credits in 1 go. Eg they pay $150 per vehicle they tune.

    Most tuners charge $800-1500 a tune so we are taking 10-20% for using our software. If the customer comes back 50x they only pay once as the license lasts for ever for that vehicle.

    The license/credit system is well accepted in the tuning industry. All serious products use a similar system, eg pay per vehicle. Subscription wouldn't be fair as some customers tune 1 vehicle a week some tune 10, so I'm not sure how you'd fairly charge. By charging per vehicle everyone gets billed identically.

    Service based products (eg not tuning rather fault investigation) tend to use a subscription model like you said.

    I haven't looked at toyotas at all. Changing the gearbox control strategy from pseudo gears to a constant slip would be a huge change though, you'd most likey need to find another vehicle that implements what you suggested and see if the controllers are compatible.
     
    Last edited: May 15, 2018
  4. ShadowBurger

    ShadowBurger Member

    Joined:
    Feb 19, 2008
    Messages:
    1,394
    Location:
    Melbourne
    Ohhh, makes sense. Damn that software is a license to print money... I'm in the wrong industry! Definitely looks like nice software... in my time tinkering with old mechanical diesels I'm a bit sad that I never got to explore tuning and computers
     
  5. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,510
    Location:
    Perth NOR
    Is it possible/practical to use the ford equipment in a cheap diy efi conversion on something like an old carby v8? I know the early 90's delco featured on pcmhacking can do it, but it doesn't seem the easiest. AFAIK, you need the computer, then some modified hardware to custom tune it, and then it only takes certain timing signals, some of which require external modules. I also believe I read that you need a speed sensor to correctly handle certain scenarios (gearing down predominately). So lots of little traps/pitfalls.
     
  6. OP
    OP
    Foliage

    Foliage Member

    Joined:
    Jan 22, 2002
    Messages:
    31,967
    Location:
    Sleepwithyourdadelaide
    The only way to become a millionaire is work while you sleep.

    Not really. The new PCMs are insanely complex beasts, tuning the airflow model would take you months with all the overlap etc which they do not expect.

    You'd be better off just putting a 5.0 from a late model ford into whatever vehicle you want to play with along with a complete loom and sensor setup. As soon as you start mixing and matching things get really difficult. A few of our customers put the 5.4s and 4Ls into old F150s, Speed boats and all sorts. They do run into issues without the speed sensors, though you can transplant the ABS module wheel sensor if you wanted to, or in the case of a speed boat most people use a 555 Timer with a square wave output to trick it into thinking it is always doing 60kph.

    If you want a cheap DIY EFI solution look into the mega squirt, you can have a very basic fuel injection + dizzy setup if you wanted.
     
    neRok likes this.
  7. GumbyNoTalent

    GumbyNoTalent Member

    Joined:
    Jan 8, 2003
    Messages:
    5,165
    Location:
    Briz Vegas
    Only way to become a millionaire is to make money of other people working for you.
     
  8. Hater

    Hater Member

    Joined:
    Nov 19, 2012
    Messages:
    2,033
    Location:
    Canberra
    There is lots of way to become a millionaire that doesn't involve working at all, win the lottery, move to Zimbabwe, invest in housing when young and sell that house when you are old, starting with multi-millions and spending unwisely, etc.
     
  9. BurningFeetMan

    BurningFeetMan Member

    Joined:
    Apr 22, 2003
    Messages:
    7,834
    Location:
    Veg City
    Program an OCAU member themed version of Pokemon - where the player chooses an Admin for their main character. Admins then travel around an OCAU themed land in search of the "Original Post", catching & training wild "Members" who they fight against with other NPC Admins and their captured members.

    ... I really need to get out more.
     
  10. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,510
    Location:
    Perth NOR
    I took the challenge. The following is my best function (python 3). I tried a few other types of loop, but I think the overhead of doing checks every loop iteration is worse than just doing a fixed number of loops. This is about 10% faster than the alternatives.

    Code:
    def get_factors_by_range_twice(num_a, num_b):
       
        factors = set([1])
       
        # determine smaller number.
        if num_a < num_b:
            num1 = num_a
            num2 = num_b
        else:
            num1 = num_b
            num2 = num_a
       
        # determine if numbers are odd.
        num1_odd = num1 & 1
        num2_odd = num2 & 1
       
        max_factor = False
       
        # if either number odd, factors cannot be even.
        if num1_odd:
            start = 3
            interval = 2
            # determine if small number is a factor of big number.
            if not num2 % num1:
                factors.add(num1)
                max_factor = num1
        elif num2_odd:
            start = 3
            interval = 2
            # small number must be even, so cannot be factor of big odd number.
        else:
            start = 2
            interval = 1
            # determine if small number is a factor of big number.
            if not num2 % num1:
                factors.add(num1)
                max_factor = num1
       
        # loop until find the first common factor.
        if not max_factor:
            for test_factor in range(start, num1, interval):
    
                # test factor against small number.
                if num1 % test_factor:
                    continue # not a factor
               
                # test 'good' factor against the big number.
                if num2 % test_factor:
                    continue # not a factor
               
                # save the tested factor.
                factors.add(test_factor)
                max_factor = num2 // test_factor
                start = test_factor + interval
                break
       
        # loop between the current and the max factor.
        if max_factor:
            for test_factor in range(start, max_factor+interval, interval):
    
                # test factor against small number.
                if num1 % test_factor:
                    continue # not a factor
               
                # test 'good' factor against the big number.
                if num2 % test_factor:
                    continue # not a factor
               
                # save the tested factor.
                factors.add(test_factor)
               
        return sorted(factors)
     
  11. Sindarin Ultra

    Sindarin Ultra Member

    Joined:
    Sep 7, 2005
    Messages:
    249
    Location:
    Brisbane
    It's certainly at least 10% more code than the alternatives ;).

    Code:
    # Naive version
    def common_factors(a, b):
        factors = []
        for i in range(1, min(a, b) + 1):
            if a % i == b % i == 0:
                factors.append(i)
        return factors
    
     
  12. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,510
    Location:
    Perth NOR
    It's all my shortcuts, and they make my code 1.5x faster than yours when testing 10000 random pairs :D

    Your code can be faster if it alters the range by checking for odd numbers, like my code. It's still slower than mine though!
     
    Last edited: May 16, 2018
  13. Sindarin Ultra

    Sindarin Ultra Member

    Joined:
    Sep 7, 2005
    Messages:
    249
    Location:
    Brisbane
    So that's how you want to play it!

    Code:
    # Slightly less naive approach
    def common_factors2(a, b):
        while b:
            a, b = b, a % b
        gcd = a
        factors = []
        for i in range(1, gcd + 1):
            if gcd % i == 0:
                factors.append(i)
        return factors
    
    Running 10,000 iterations of random integers between 1 and 10,000 gives running time of ~1s for your solution and ~0.03s for the above, 33x faster. The difference becomes more extreme as the size of a and b increases e.g. for a and b random to 100,000 yours is ~10s vs 0.033s (300x faster).

    When testing I noticed your version seems to miss some factors??

    Code:
    a=8300, b=6225
    common_factors2: [1, 5, 25, 83, 415, 2075]
    nerok:           [1, 5, 25, 83, 415]
    
    a=4828, b=8449
    common_factors2: [1, 17, 71, 1207]
    nerok:           [1, 17, 71]
    
    a=4565, b=2739
    common_factors2: [1, 11, 83, 913]
    nerok:           [1, 11, 83]
    
     
    neRok likes this.
  14. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,510
    Location:
    Perth NOR
    Very nice. But the challenge was for 2 digit numbers (1-99, maybe 0 too?), and mine tests 1.5x slower than your new code at that task on my PC.

    I can see why the time for mine blows out on larger numbers compared to yours though (because I test each factor twice).

    I don't know why mine is missing some factors, I will look into it tomorrow. I'll also see if I can pinch some of your ideas :lol:

    Edit: Found and fixed my missing factor problem. It was in the first loop. Fixed it. Doesn't effect my 2 digit speed.
     
    Last edited: May 16, 2018
  15. GumbyNoTalent

    GumbyNoTalent Member

    Joined:
    Jan 8, 2003
    Messages:
    5,165
    Location:
    Briz Vegas
    https://contest.openai.com/
     
  16. Sindarin Ultra

    Sindarin Ultra Member

    Joined:
    Sep 7, 2005
    Messages:
    249
    Location:
    Brisbane
    Oh, I missed that.. well anyway the approach above is certainly fine for 2 digit numbers. The first 3 lines are Euclid's algorithm to find the greatest common factor (gcf) and then knowing that the remaining factors must be factors of the gcf do a naive (linear) search for factors of the gcf and voila. You can get much fancier if you need to find factors of enormous numbers.

    I wouldn't expend too much energy though, @rt probably wanted it in C for a microcontroller or something and probably long since moved on :tongue:
     
  17. GumbyNoTalent

    GumbyNoTalent Member

    Joined:
    Jan 8, 2003
    Messages:
    5,165
    Location:
    Briz Vegas
    Sounds more like a homework assignment.
     

Share This Page