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

/prog/ Challenge 9001

Name: Anonymous 2011-05-01 19:51

The correct title of this article is /prog/ Challenge 9001. It appears incorrectly here because of technical restrictions.

The task:

Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the printf() or cout statement 1000 times.

inb4 lipthfags and dead dogs using some obscure functionality of their obscure languages.

Name: Anonymous 2011-05-02 15:32

Prelude> mapM_ (print) [1..1000]

Name: Anonymous 2011-05-02 16:06

Name: Anonymous 2011-05-02 17:48

Name: Anonymous 2011-05-02 18:11

>>83
You. Go back to where you came from.

Name: Anonymous 2011-05-02 18:53

>>84
You return whence you came.

Name: Anonymous 2011-05-03 8:04

ENTERPRISE C SOLUTION


#include <stdio.h>
typedef void (*F1)(int);
typedef void (*F2)(F1,int);
typedef void (*F3)(F2,F1,int);
void P(int n) { printf("%d\n",n); }
void T1(F1 f1, int n) {f1(n);f1(n+1);f1(n+2);f1(n+3);f1(n+4);f1(n+5);f1(n+6);f1(n+7);f1(n+8);f1(n+9); }
void T2(F2 f2, F1 f1, int n) {f2(f1,n);f2(f1,n+10);f2(f1,n+20);f2(f1,n+30);f2(f1,n+40);f2(f1,n+50);f2(f1,n+60);f2(f1,n+70);f2(f1,n+80);f2(f1,n+90); }
void T3(F3 f3, F2 f2, F1 f1, int n) { f3(f2,f1,n);f3(f2,f1,n+100);f3(f2,f1,n+200);f3(f2,f1,n+300);f3(f2,f1,n+400);f3(f2,f1,n+500);f3(f2,f1,n+600);f3(f2,f1,n+$
int main() { T3(T2,T1,P,1); return 0; }

Name: Anonymous 2011-05-03 10:02

>>86
I don't know what enterprise you worked for, but no company has best practices like this.

Name: Anonymous 2011-05-03 12:29

#define P0 printf("%d\n",++i);
#define P1 P0 P0
#define P2 P1 P1
#define P3 P2 P2
#define P4 P3 P3
#define P5 P4 P4
#define P6 P5 P5
#define P7 P6 P6
#define P8 P7 P7
#define P9 P8 P8

int main(void) {
    int i = 0;
    P3 P5 P6 P7 P8 P9
    return 0;
}

Name: Anonymous 2011-05-03 12:55

>>87
Its a joke to refer to most hairy hacked-up code as "Enterprise Solution"

Name: Anonymous 2011-05-04 1:29

This thread is PIG DISGUSTING

Name: Anonymous 2011-05-04 2:02

>>1
main = putStrLn ("1\n" ++ "10\n" ++ "11\n" ++ "100\n" ++ "101\n" ++ "110\n" ++ "111\n" ++ "1000\n")

Name: Anonymous 2011-05-04 3:47

>>53
Nice job. You translated my beautiful Pascal solution(>>5) into ugly, broken C

Name: Anonymous 2011-05-04 4:20

int i = 1;

struct hi
{
hi();
};

hi()
{
std::cout << i << "\n";
i++;
}

int main()
{
hi[1000];
return 0;
}

Name: >>9,53 2011-05-04 6:07

>>92

a)
Progs[(i+1) > 1000](i+1);
This uses a conditional. Sure, you're not using if, but it will generate a cmp in assembly.

b)
That's C++, not C.

Name: Anonymous 2011-05-04 10:18


 _______________
< DRINK MY ANUS >
 ---------------
 \     ____________
  \    |__________|
      /           /\
     /           /  \
    /___________/___/|
    |          |     |
    |  ==\ /== |     |
    |   O   O  | \ \ |
    |     <    |  \ \|
   /|          |   \ \
  / |  \_____/ |   / /
 / /|          |  / /|
/||\|          | /||\/
    -------------|
        | |    | |
       <__/    \__>

Name: Anonymous 2011-05-04 12:24


#include <algorithm>
#include <iostream>

int main() {
    std::for_each(1, 1000, [](int x) { std::cout << x << std::endl; });
    return 0;
}


And before you faggots say that's not allowed because for_each does iteration, I want you to know that
map
in whatever precious functional language you're using is implemented with iteration. for_each is C++'s map.

Name: Anonymous 2011-05-04 12:36

>>96
Just wanted to say that you're wrong as much as them. Map, for-each, for_each and recursion count as ``loops''.

Name: Anonymous 2011-05-04 14:06


.........,....................,......,.............,......,........................
...,,..,...........................,......:,,::,,:,.,,,,:,.,,.........,...,..,,....
..,..,,.....,......2illl▓▓███████████▓▓▓▓▓▓██▓.........,..,,..
,...,..,...,.k▓█▓▓▓▓lBEnjjBllllllBjzv░1JTHtq8tL;..,...nll█▓.......,...,,
..,......v▓█M:..,::,,:;1JBt;,...,....q:......:vFll▓▓llEL.....█▓,......,...
,...,.....█,,,...░;........;x,.......,:,,..,,:,,........,░,,,.....█lM.......,,
.....,:n█▓...,..Lii███▓B1........tj▓▓▓█████lM.,,........j█▓;......
...W██▓w,,..,Y▓▓█████M...k██▓▓▓█▓lll▓▓v▓▓▓▓▓;.▓█▓...
..#ll█::vn▓▓▓▓g;J:..,.t█▓................,n▓▓glll▓▓▓▓Wl▓▓.wll█..
...zi█;:..,..,t▓7▓▓░2ll█▓:......,.X▓Bq..,.........Bll▓▓█▓.El█3.F█lll
.....▓█1t;3█▓.,...Wl██,..,..f▓▓Mi█W,rB▓▓▓█lB;..▓█lBt█lK.:;█..
....,.f█▓W███▓▓7:..▒▓█M..tjBl▓██▓Bjzr▒█▓Bj██jY.,..,h█▓2..
.....,..j█.jll█Bl▓▒ll█fjllllll█llBIjj█6;:..▒▓▓▓████,l█▓......Bl█▓..,..
,......U█.;r█████▓▓▓█▓▓█▓▓█████Bj..C██W.....yi█;:.......
........j█...█████████████▓lM:.k▓M..f▓█W,...,..lll█8:.....,...
,......N▓,..B██▓▓.█M1▓▓.,..j█....,;8l██▓W,.....░ll██r:.....,,..,,
......r▓▓.....▒ll▓▓▓██▓█▓▓██▓▓▓▓881xtll▓▓██▓I....,..,,..,...
......I█▓.6;,.░;,,,..,..;r░::v7::,..;YTn;xtll▓▓█▓▓n..........,,..,.....
.....w█▓..,JjlgglllBjkT:,..,.........,,.,W▓▓▓▓H...............,,..,..,,..
,......U█▓r....,......,......,;rll▓l█▓▓▓▓t,..,..........,..,,..,..,,.,,....
.........▒ll███▓▓▓▓███▓▓▓BBj::....,......,.....,,..,..,,..,..,,.,,...
,...,..,.............,...,......,......,..,...,..,......,......,...,......,........

Name: Anonymous 2011-05-04 14:22

All answers are invalid, because the OS uses loops and conditionals to load the program.

Name: Anonymous 2011-05-04 14:27

>>99
Not really solvable unless you decide to take some specific platform and fully unroll all the code for display.

Name: Anonymous 2011-05-04 16:09

Would
f x y = 10 * x + y
w = flip map [0..9] . f
main = putStrLn $ unwords $ map (show . (1+)) $ w =<< w =<< w =<< [0]

count? It does use map, though.

Name: Anonymous 2011-05-04 16:12


(unfold
 (λ (x) (< x 1000))
 display add1)


But unfold is a loop.

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