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

Fun Programming Contest - Win $10

Name: Anonymous 2007-09-24 4:44 ID:qljv4pIe

I have a fun little programming contest for y'all! You are writing a function named foo() that takes in five arguments and outputs a 32-bit integer. The user who writes the most efficient solution meeting all of the specifications outlined below will receive a $10 cash prize. (We have thousands of test cases to spread out the results.)

function foo(a, b, c, d, e) {
// your code goes here
return out;
}

Inputs:
u8 a; // range: 0-24
bool b;
u8 c; // range: 0-255
bool d;
u32 e; // range 0-2^32-1

Output:
u32 out; // range 0-2^32-1

Here are the four restrictions for the output:
1. (out mod 25) must be equal to a
2. if b = FALSE, then out mod 255 must be between 0 and c-1, inclusive
3. if b = TRUE, then out mod 255 must be between c and 255, inclusive
4. if d = TRUE, then ((out XOR e) / 65536) XOR (out XOR e) % 65536)) must be < 8

Example:
foo(1, 0, 31, 1, 0) returns 1, which satisfies all of the conditions above.
foo(3, 1, 31, 1, 3162282670) returns 4063024378
There may be several possible values for out, but a value that satisfies all four conditions above must be returned.

You may use Java, C, or C++.

All solutions should be sent to markus.yeh (at) gmail.com . Only your most recent submission will be entered into the contest. The entry deadline is Wednesday, September 26 at 12:00 a.m. Pacific Time, and winners will be announced before Saturday, September 29 at 12:00 a.m. Pacific Time.

Good luck!

Name: Anonymous 2007-09-24 4:54 ID:Heaven

SHITCOCK

Name: Anonymous 2007-09-24 4:56 ID:qljv4pIe

Go screw yourself kthx

Name: Anonymous 2007-09-24 5:01 ID:VpNgRPyq

Do your own homework.

Name: Anonymous 2007-09-24 5:12 ID:qljv4pIe

Except it's not homework, or else I'd have done it myself.

Name: Anonymous 2007-09-24 5:17 ID:UGWYNjCI

how will these our solutions be compiled?

Name: Anonymous 2007-09-24 5:20 ID:Heaven

>>5
Except it clearly is, and you are too retarded/lazy to do it yourself.

Name: Anonymous 2007-09-24 5:21 ID:qljv4pIe

Java Compiler, gcc, etc. you can use Java, C, or C++, but you must mail the source code to the email above to submit your entry.

Name: Anonymous 2007-09-24 5:21 ID:qljv4pIe

Heaven, fuck off along with your sage-bombing.

Name: Anonymous 2007-09-24 5:56 ID:Heaven

>>9
no

Name: sage !ccqXAQxUxI!t0MJimflCHPycJH 2007-09-24 6:31 ID:Heaven

sage goes in every field

Name: Anonymous 2007-09-24 7:14 ID:47VAqc2E

int foo(int a, int b, int c, int d, int e) {
    if (a == 1 && b == 0 && c == 31 && d == 1 && e == 0) {
        return 1;
    } else if (a == 3 && b == 1 && c == 31 && d == 1 && e == 3162282670) {
        return 4063024378;
    } else {
        return a / 0;
    }
}

Name: pedo !BEAR0SWNFs 2007-09-24 7:16 ID:Heaven

Name: Anonymous 2007-09-24 7:51 ID:Heaven

>>13
Another tripfag script kiddy who just discovered a tripcode manufacturing utility. This is why we don't post /prog to Reddit.

Name: Anonymous 2007-09-24 7:54 ID:Heaven

>>14
Disregard that, I sucks cocks.

Name: pedo!BEAR0SWNFs 2007-09-24 8:01 ID:Heaven

Testing

Name: pedo !p2bmc06e0Q 2007-09-24 8:02 ID:Heaven

test

Name: !DrrU2BEaRQ 2007-09-24 11:44 ID:Heaven

>>17
>>16
trip is jzSzAirR. I also like

Name: Anonymous 2007-09-24 22:03 ID:qljv4pIe

>>12
urafag

Name: Anonymous 2007-09-24 22:08 ID:T9hry1wD

Which type are the 5 arguments?

Name: Anonymous 2007-09-24 22:08 ID:T9hry1wD

Nevermind.

Name: Anonymous 2007-09-24 22:50 ID:Heaven

Ignore any stupid mistakes

$ cat stupid.c; gcc -Wall -O2 stupid.c -o stupid && time ./stupid
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>


uint32_t foo( uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint32_t e )
{
    uint32_t out = 0;
    uint32_t tmp;
    uint32_t max;

    max = 0xFFFFFFFFuL - a;

    for( out = a; out < max; out += 25 )
    {
        if ( d )
        {
            tmp = out ^ e;

            if ( (((tmp / 65536) ^ tmp) % 65536) >= 8 )
            {
                continue;
            }
        }

        if ( b )
        {
            tmp = out % 255;

            if ( tmp < c )
            {
                continue;
            }
        }
        else
        {
            if ( out % 255 > c-1 )
            {
                continue;
            }
        }

        return out;
    }

    return 0;
}


int main( int argc, char ** argv )
{
    printf( "r=%u\n", foo( 1, 0, 31, 1, 0 ) );
    printf( "r=%u\n", foo( 3, 1, 31, 1, 3162282670uL ) );
    printf( "r=%u\n", foo( 3, 1, 31, 1, 0xFFFFFFFFuL ) );
    return 0;
}


r=1
r=75478
r=1114128

real    0m0.005s
user    0m0.000s
sys     0m0.000s

Name: Pedo !BEAR0SWNFs 2007-09-24 23:40 ID:Heaven

test

Name: Anonymous 2007-09-25 2:37 ID:Heaven

>>22

foo a b c d e = head $
  filter (\x -> let n = x `xor` e
    in (if b == False then x < c else x >= c) &&
       (not d || (n `div` 65536) `xor` (n `mod` 65536) < 8)
  ) [ a, a + 25 .. 0xFFFFFFFF - a ]

Haskell'd.

Name: ​​​​​​​​​​ 2010-09-09 16:24

Name: Anonymous 2012-06-25 23:05

䐸隓靗ᘥ猉造艇႓怵ቈᄱ妉ܘ䔢桗䐣䤷茡莈⚁餖ᄐ㜵祄㡰〥蘀䈧ጲԹ蝳錉嘦࠷奕╕ဇ䐨瀂怹␆嘡䜴印∣䥹ဆ⒐䢉噹䡹桗霷偷璗憂䑐䦃㒑嘘╒ٔႆ⁃倖眈晷ᑤ朖蜔ʙ葱ፄʁ⌓襆銔襐朗ぃ㌧ԗ㊈䄐鐵䤗獂蝓鈸е牔㉄䞗䎑蕨㡇熂⎉遂☡♐ʑ㄀顑瘓̕礖敥䄸ᑠᔉ鍗襥荄瘩∴䢒ޑ匳蚆熀∇脕獠㡑̆卒̐㜆∷嚄䖕⥐悕砤ጠ捑㌀ぃㄉ䄦舒ᜳ敄Թ㌗茸疗瀆砄㠗恨啀⊖ጥ爇u⅐鉇脘撕࢕斕䠘逈Ā䠙⁁ؙ䅘饐Т鈔嘅瑠遘蘅ᆇጆ脕枖ↁ瀧㘩؀ē☱鄔ᡴ阶憁楶⑵酹煄吨ᄇ愳㍡⡇⠶䅷ݵᕁ膅敹暄偗楕鑙ᠴ偕遖吥扶敠犔瞈唅卙夡摢戥ࠨ獆䢀䌘鐧蜶❩ᄵ垔⑑酵㉖扆␷膂膙┕䚘爳顶。ࡹ艄䤣䦔鞓鐶䊃–Չ⍇剧☨葘ʅ䠰䐖⅗扸ឆ舐ɀ腕❐畉牢枙᜸襖͸喓▉挖⌖炔䙩ࠔ鍘扢❦㘇䝥⌵ㆂ靈䝃昴茴䂅砲㠷ॵㅒ⡂䈧ᐴ慤

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