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

JavaBat

Name: Jesus 2009-02-11 20:37

Hey /programing/ i need some help w/ javabat.(array 1)

it would really help if i could have the user/pass of someones. i will not screw it up.




We'll say that a 1 immediately followed by a 3 in an array is an "unlucky" 1. Return true if the given array contains an unlucky 1 in the first 2 or last 2 positions in the array.

unlucky1({1, 3, 4, 5}) → true
unlucky1({2, 1, 3, 4, 5}) → true
unlucky1({1, 1, 1}) → false
public boolean unlucky1(int[] nums) {

Name: Anonymous 2009-02-13 2:35

>>39
(nums[0] == 1 && nums[1] == 3) ...
Incoming ArrayIndexOutOfBoundsException!

Name: Anonymous 2009-02-13 2:41

>>41
>>38 has the same problem.
public boolean fuckyourshittyproblems(int[] nums) {
    int l = nums.length
    return l > 1 && (nums[0] == 1 && nums[1] == 3) ||
           l > 2 && (nums[1] == 1 && nums[2] == 3) ||
           (nums[nums.length - 2] == 1 && nums[nums.length - 1] == 3]);
}

Name: Anonymous 2009-02-13 2:42

>>42
Nice job destroying the readability for no gain, faggot.

Name: Anonymous 2009-02-13 5:32

>>41
Incoming AnusOutOfBoundsException!

Name: Anonymous 2009-02-13 7:29

>>41
public boolean fuckyourshittyproblems(int[] nums) {
    try {
        return fuckyourshittyproblem(nums);
    } catch (ArrayIndexOutOfBoundsException e) {
        return false;
    }
}


Your move.

Name: Anonymous 2009-02-13 7:56

>>45
Exceptions are meant to catch random runtime failures, not for you niggers too lazy to code proper array bound checking.

Name: Anonymous 2009-02-13 8:05

>>46
Runtime exceptions aren't meant to be caught at all, but since they exist, you might as well use them.

Name: Anonymous 2009-02-13 9:12

>>47
So you never catch IOException when you try to open a file that could potentially be locked?

Name: Anonymous 2009-02-13 10:42

>>46
It's EAFP than to LBYL.

Name: Anonymous 2009-02-13 11:13

>>49
What?

Name: Anonymous 2009-02-13 12:09

>>50
It's easier to ask for permission than forgiveness than to look before you leap.

Anticudders prefer to ignore errors and slap a try/catch on as an afterthought.

Name: Anonymous 2009-02-13 16:18

>>48
Runtime exception has a specific meaning in Java. IOException isn't a runtime exception.

Name: Anonymous 2009-02-13 23:08

>>39

(nums[nums.length - 2] == 1 && nums[nums.length - 1] == 3]);
Syntax error on token "]", delete this token

Name: Anonymous 2009-02-13 23:11

>>42
>>38 posted the testing results and they are all right.  Plus I plugged it into Javabat to double check and it's correct.  PS I hope you die of AIDS.

Name: Anonymous 2009-02-25 6:54

The former case your   program will include   the bits of   the library you   need and will   work in the   post ID ranges   Secondly by pure   chance someone had   posted before you   just as you   think are needed.

Name: Anonymous 2010-11-13 22:28

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