Turn on thread page Beta
    Offline

    1
    ReputationRep:
    (Original post by Alaric)
    LoC/day is generally a really useless measure, but since the code is _working_ I thought it jusified to quote it. It's distinctly above average but not insane, it wasn't really that simple code today, yesterday I did also did 500 but spent today debugging it and it was simpler code.

    I can probably beat 500/day in PHP, probably 350/day tops in C++ though.

    A.
    I have some 100 lines of java and I still haven't got a clue what's wrong with it... argh...
    Offline

    14
    ReputationRep:
    we should rename this the compsci thread

    sorry, i'm bored, need to go to bed but can't be bothered moving, and i'm enjoying spamming
    Offline

    1
    ReputationRep:
    Argh. It's useless trying to explain how Cambridge works to my old school friends! They can't understand the college system and can't understand why I wasn't in the boat race!! I give up!
    Offline

    1
    ReputationRep:
    (Original post by priya)
    we should rename this the compsci thread

    sorry, i'm bored, need to go to bed but can't be bothered moving, and i'm enjoying spamming
    That's unfair, it's just as much a boatie/medic/natsci thread too!

    I'm spamming too, and also should be going to bed but I think I still have too much caffeine and haven't adjusted to the change of clocks yet!

    A.
    Offline

    1
    ReputationRep:
    (Original post by Camford)
    I have some 100 lines of java and I still haven't got a clue what's wrong with it... argh...
    Post it, I'll read it.

    A.
    Offline

    20
    ReputationRep:
    (Original post by Katie J)
    Argh. It's useless trying to explain how Cambridge works to my old school friends! They can't understand the college system and can't understand why I wasn't in the boat race!! I give up!
    Tell them it's like the houses at Hogwarts. Mostly inaccurate, but they'll get some idea. And you weren't in the boat race because you're a girl, surely?
    Offline

    1
    ReputationRep:
    (Original post by Helenia)
    Tell them it's like the houses at Hogwarts. Mostly inaccurate, but they'll get some idea. And you weren't in the boat race because you're a girl, surely?
    That was actually the first thing I said! I then said I just row for my college in a fairly low boat...which got us all back to the college system, I've tried so many times, with so many explanations! Like form groups is the nearest I've ever got I think (never read/seen HP), maybe if the degree names were a little more conventional (& my subject more understood) I might stand a better chance! Tried explaining NatSci this evening...half of them still think I'm at an FE college and not really a student which really confuses them! It's a nightmare normally, when they're all a little drunk it's insane!
    Offline

    1
    ReputationRep:
    (Original post by Alaric)
    Post it, I'll read it.

    A.
    I'll give it one final debugging run tomorrow, if I can't solve it, I'll post.
    Offline

    0
    ReputationRep:
    (Original post by Katie J)
    Argh. It's useless trying to explain how Cambridge works to my old school friends! They can't understand the college system and can't understand why I wasn't in the boat race!! I give up!
    yea tell me about it. Whenever i said "I row" to my friends who knew I was at cambridge they were all like "cool, so you'll get to be on the telly in that race then".....FFS DO I LIKE 6 FOOT 6!??
    Offline

    14
    ReputationRep:
    my friends seem to have a slightly better grasp......but not my family

    *cue odd indian accents* ahh so you arre rowving forr cammbridge! vee vill see you rowving against oxfarrd yar?"
    Offline

    17
    ReputationRep:
    (Original post by priya)
    my friends seem to have a slightly better grasp......but not my family

    *cue odd indian accents* ahh so you arre rowving forr cammbridge! vee vill see you rowving against oxfarrd yar?"
    At least that's a bit more understandable than random unknown relatives presuming getting an offer gurantees a Nobel Prize in the future or something:rolleyes:
    Offline

    0
    ReputationRep:
    any of you compsci's out there.....how would you show that the following preorder ml function is O(n^2) in the worst case?

    Code:
    fun preorder Lf = []
    | preorder(Br(v,t1,t2)) = [v] @ preorder t1 @ preorder t2;
    
    where Lf and Br are part of a tree datatype:
    datatype 'a tree = Lf | Br of 'a * 'a tree * 'a tree;
    I'm having difficulty just stepping through it to find out how much time it will take to execute on a test tree
    Offline

    1
    ReputationRep:
    (Original post by Willa)
    any of you compsci's out there.....how would you show that the following preorder ml function is O(n^2) in the worst case?

    Code:
    fun preorder Lf = []
    | preorder(Br(v,t1,t2)) = [v] @ preorder t1 @ preorder t2;
    
    where Lf and Br are part of a tree datatype:
    datatype 'a tree = Lf | Br of 'a * 'a tree * 'a tree;
    I'm having difficulty just stepping through it to find out how much time it will take to execute on a test tree
    I think you should take a look at Slide 407 (the inefficient reversing of a list) from your notes, the problem is with append so a completely unbalanced tree down the left branch will have a O(n^2) worst case.

    A.
    Offline

    20
    ReputationRep:
    (Original post by Willa)
    yea tell me about it. Whenever i said "I row" to my friends who knew I was at cambridge they were all like "cool, so you'll get to be on the telly in that race then".....FFS DO I LIKE 6 FOOT 6!??
    My friends had at least managed to notice that there are no women in the boat race, however, when I pointed out that the only way I could get in the Blue Boat was to cox, they were all "Well, why don't you do that?" Hmmm...because I'm 5'9 and too heavy to be a lightweight man, let alone a 55kg cox. :rolleyes: Feel sorry for those guys - both of the Blues coxes are at least my height and have to starve themselves to make weight. I saw last year's Blues cox at Henley, and comparing him now with the scrawny thing he was then, the difference is horrendous.

    My family just about understand it, as 4 of them have been through Cambridge already, though I'm the first to row.
    Offline

    1
    ReputationRep:
    (Original post by Lozza)
    :eek:

    and i just realised...natscis have it easy, dont we? :s:
    I thought we had it easy...

    ML is easy. Rather nice in fact. Just about anything that is accepted by the interpreter will run properly... but java... I need a cup of coffee.
    Offline

    1
    ReputationRep:
    (Original post by Lozza)
    half of my more elderly relatives don't know what cambridge is.

    a favourite question of mine was "cambridge? is that good?" :confused:
    I have the double difficulty of explaining about Ox/Cam and about classics. "So you're going to be an interpreter?"
    Offline

    1
    ReputationRep:
    (Original post by Camford)
    I thought we had it easy...

    ML is easy. Rather nice in fact. Just about anything that is accepted by the interpreter will run properly... but java... I need a cup of coffee.
    Like I said, if you want a hand post it, I'm in a Java frame of mind at the moment I might be able to help.

    A.

    PS: Java is easy
    Offline

    14
    ReputationRep:
    (Original post by d750)
    I have the double difficulty of explaining about Ox/Cam and about classics. "So you're going to be an interpreter?"
    everyone wonders what on earth i'm going to do with my degree. they don't understand the point of degrees that a) don't involve science, and b)don't immediately lead to a specific career
    Offline

    0
    ReputationRep:
    (Original post by Alaric)
    I think you should take a look at Slide 407 (the inefficient reversing of a list) from your notes, the problem is with append so a completely unbalanced tree down the left branch will have a O(n^2) worst case.

    A.

    no i still dont follow it.

    Suppose I have a tree that just goes off to the left branch starting from the top reads: A->B->C->D

    then the algorithm would result in:

    A @ (B @ (C @ (D @ [] @ []) @ []) @ []) @ []

    which to actually do would take only 1 unit of time per append, since the list being appended to is only ever of length 1. The above is equivilent to:

    A :: (B :: (C :: (D :: [] :: []) :: []) :: []) :: []

    So this would be O(n)???
    Offline

    1
    ReputationRep:
    PHP Code:
    import java.util.*;

    public class 
    Unic
    {
        public static 
    void main(String[] args)
        {
            final 
    char[] digList = {'1','2','3','4','5','6','7','8','9','0'};
            
    //final char[] digList = {'9','7','5','3','1','0','2','4','6','8'};

            
    String add1add2sumtotal;
            
    add1 "SEND";
            
    add2 "MORE";
            
    sum "MONEY";
            
    total add1 add2 sum;
            
    char[] ch1 = new char[add1.length()];
            
    char[] ch2 = new char[add2.length()];
            
    char[] chsum = new char[sum.length()];
            
    ch1 add1.toCharArray();
            
    ch2 add2.toCharArray();
            
    chsum sum.toCharArray();
            
    //keep track which letter has got a value
            
    HashSet<Integerloci = new HashSet<Integer>();
            
    //keep track which digit has been used
            
    HashSet<Integerlocj = new HashSet<Integer>();
            
    //which letter is assigned what
            
    HashMap<CharacterCharacter= new HashMap<CharacterCharacter>();
            
            
            
    char[] chaMap = new char[total.length()];
            
    chaMap total.toCharArray();
            
    char[] chars = new char[total.length()];
            
    int idx 0;
            
    int count 0;
            
            for (
    int i 0total.length(); i++) // produce an array countains all used
            
    {                                         // letters just once.
                
    try
                {
                    for (
    int j 0j<= total.length(); j++)
                    {
                        if (
    chaMap[i] == chars[j]) break;
                    }
                }
                catch(
    IndexOutOfBoundsException e)
                {
                    
    chars[idx] = chaMap[i];
                    
    idx++;
                }
            }
            
            
    //shrink the array a little
            
    char[] chUniq = new char[idx];
            
            for (
    int i 0iidxi++)
            {
                
    chUniq[i] = chars[i];
            }
            
            if (
    chUniq.length <=10)
            {
                
    System.out.println("Start");
                
    solve(ch1,ch2,chsum,chUniq,digList,loci,locj,m);
                
    System.out.println("boo");
                
            }
            
        }
        
        
    // recursively solve for solution
        
    static void solve(char[] s1char[] s2char[] sumchar[] chUniqchar[] digListHashSet<Integer>
             
    lociHashSet<IntegerlocjHashMap<CharacterCharacterm)
        {
            for(
    int i 0i<chUniq.length i++)
            {
                if (!
    loci.contains(i))//if letter has not been assigned a value
                
    {
                    
    loci.add(i);//chUniq[i] is now used
                    //System.out.println("i2 "+i);
                    
    for(int j 0j<10;j++)
                    {
                        if(!
    locj.contains(j))//if the digit is not used
                        
    {
                        
    //System.out.println("j2 "+ j);
                        
    m.put(chUniq[i],digList[j]);//assign value to letter
                        
                        
    locj.add(j);//digList[j] is now used
                        
    solve(s1,s2,sum,chUniq,digListlocilocj,m);
                        
                        
    locj.remove(j);//unsuccessful, remove digList[j]
                        
    m.remove(chUniq[i]);//remove the assignment
                        
    }
                        
                        
                    }
                    
    loci.remove(i);//unsuccessful, remove chUniq[i]
                
    }
            }
            
            
    boolean assignments true;//true if every letter has been
                                       //assigned a value
            
    for(int i 0i<8i++)
            {
                
    assignments assignments loci.contains(i);
                if (!
    assignments) break;
            }
            
            if (
    assignments)//precede with calculation
            
    {
                
    String a1="";
                for (
    int x 0s1.lengthx++)
                {
                    
    a1 a1 m.get(s1[x]);
                }
                
                
    //if (m.get(s1[0]) = '0') return;
                
                
                
    String a2="";
                for (
    int x 0s2.lengthx++)
                {
                    
    a2 a2 m.get(s2[x]);
                }
                
                
    //if (m.get(s2[0]) = '0') return;
                
                
    String s="";
                for (
    int x 0sum.lengthx++)
                {
                    
    m.get(sum[x]);
                }
                
    //if (m.get(sum[0]) = '0') return;
                
                
    for (int i=0i<chUniq.length;i++)
                {
                    
    System.out.printf("%s",m.get(chUniq[i]));
                }
                
    System.out.printf("%n");
                
                if ((
    Integer.parseInt(a1) + Integer.parseInt(a2))==Integer.parseInt(s))
                {
                    
    System.out.println(a1 "+" a2 "=" s);
                    
    System.exit(0);//terminates when solution is found
                
    }
            }
        }

    The recursion part is not working properly. It goes back on itself and repeat what is has already searched. Basically, this thing is taking up 5 to 10 time longer than it should. If I leave this program running for... god knows 2 days maybe, it'll find the solution.
 
 
 
Poll
Black Friday: Yay or Nay?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.