Elegant solutions
Name:
Anonymous
2007-06-28 15:16
ID:lcs47ZU6
Im bored, show me some good code (any language whatsoever)
Post a problem, then a great solution.
1) Transpose a matrix
(apply #'mapcar #'list '(( 1 2 3 4)
( 5 6 7 8)
( 9 10 11 12)
(13 14 15 16)))
(( 1 5 9 13)
( 2 6 10 14)
( 3 7 11 15)
( 4 8 12 16))
Name:
Anonymous
2007-06-30 23:11
ID:Uh/Yaan4
AMIDOINITRITE??
(defun primer ()
((lambda (&rest q)
(lambda ()
((lambda (u n) (funcall u u n))
(lambda (u n) (if (some (lambda (x y) (and (/= 1 y) (= (mod x y) 0)))
((lambda (x &aux (y (list x))) (setf (cdr y) y)) n) q)
(funcall u u (1+ n)) (setf q (cons n q) n n))) (1+ (car q))))) 1))
Name:
Anonymous
2007-07-01 5:30
ID:pp6LFGvp
>>26
while(<>){push @lines, $_;}
What's that? 27 keystrokes?
Oh, wait, that's right. Perl isn't elegant, it's hacky and kludgy.
Name:
Anonymous
2007-07-01 5:53
ID:Heaven
Name:
Anonymous
2007-07-01 7:41
ID:TFsb1KjX
zip(*x)
Python wins.
Name:
Anonymous
2007-07-01 9:43
ID:6/IC6p2W
Start>run> type "cmd">type "edit look.bat"
type: "echo off
:look:
echo look around you
goto look"
push alt>save
push alt>exit
type "look"
Name:
Anonymous
2007-07-01 9:50
ID:iYCbzeuc
>>44
and that does what?
also THE FORCED INDENTATION OF CODE
Name:
Anonymous
2007-07-01 9:58
ID:TFsb1KjX
>>46
You wanted to transpose a matrix, right?
Also, zip(*x) is an expression thus it's not subject to forced indentation of code.
Name:
Anonymous
2007-07-01 10:07
ID:iYCbzeuc
>>47
CORRECTION! I WANTED TO LOL @ YOU FOR BEING A FUCKING GAY JEW
Name:
Anonymous
2007-07-01 12:36
ID:TFsb1KjX
>>48
I'd rather be a gay jew than a straight muslim
Name:
Anonymous
2007-07-01 14:52
ID:mfzzduCs
>>49
uncalled for, that is in no way true for anyone that has a fucking brain, even if its the size of you jewish dick
Name:
Anonymous
2007-07-01 15:33
ID:iYCbzeuc
>>50
LOL YHBT YHL HAND!!!
Name:
Anonymous
2007-07-01 15:40
ID:dCFpJOs/
>>42
where do you write the name of the file?
Name:
Anonymous
2007-07-01 15:47
ID:TFsb1KjX
>>50
Muslim
Who will you bomb tomorrow, bub?
Name:
Anonymous
2007-07-01 17:04
ID:wCj+wvsT
I think matlab has the most elegant solutions to these problems
A'
B*A
Name:
Anonymous
2007-07-01 18:06
ID:ip5ObYuR
>>54
k now post code to determine how similar two pieces of audio are. using matlab.
Name:
Anonymous
2007-07-01 18:24
ID:84OFbcT1
Name:
Anonymous
2007-07-01 23:16
ID:ip5ObYuR
Name:
Anonymous
2007-07-02 1:38
ID:Heaven
>>54 and
>>56 are different people,
>>57
Name:
Anonymous
2007-07-02 11:38
ID:Heaven
>>55 and
>>57 are different people,
>>58
Name:
Anonymous
2007-07-02 18:30
ID:Heaven
>>56 and
>>58 are different people,
>>59
Name:
Anonymous
2007-07-02 20:17
ID:Heaven
>>57 and
>>59 are different people,
>>60
Name:
Anonymous
2007-07-02 20:39
ID:Heaven
>>58 and
>>60 are different people,
>>61
Name:
Anonymous
2007-07-03 9:25
ID:w/DqIVCq
bump
Name:
Anonymous
2007-07-03 9:26
ID:w/DqIVCq
/r/ a one lined code that returns the larger of two numbers
Name:
Anonymous
2007-07-03 9:27
ID:fkP3dR0i
>>64
#define bigger(x, z) ((x>z)?(x):(z))
Name:
Anonymous
2007-07-03 9:46
ID:ANmcquwZ
template <class T> T bigger (T t1, T t2){ return t1>t2 ? t1 : t2; }
(defun bigger (x y) (if (> x y) x y) )
Name:
Anonymous
2007-07-03 11:05
ID:Heaven
>>33
'uniq' the unix command assumes the input is sorted and so should all functions named uniq
Name:
Anonymous
2007-07-03 11:12
ID:f8ckGWbD
>>64
tuck - dup abs + 2/ +
or you could just use math::max (
http://factorcode.org/responder/browser/browse?apropos=&word=max&vocab=math), which basically does this:
2dup > [ drop ] [ nip ] if
>>65
#define bigger(x,z) (x>z?x:z)
Name:
Anonymous
2007-07-03 11:23
ID:/LWDyi+e
>>68
#define bigger(x,z) ([b]([/b]x[b])[/b]>[b]([/b]z[b])[/b]?[b]([/b]x[b])[/b]:[b]([/b]z[b])[/b])
Name:
Anonymous
2007-07-03 11:30
ID:Heaven
I AM NOT AN EXPERT BBCODE PROGRAMMER :(
#define bigger(x,z) ((x)>(z)?(x):(z))
Name:
Anonymous
2007-07-03 11:44
ID:ANmcquwZ
>>68 It is still fail.
#define bigger(x,z) (x>z?x:z)
bool condition=true;
std::cout << bigger(condition ? 1 : 3, 37) << std::endl;
Yes ladies and gentlemen, the output is 1.
Name:
Anonymous
2007-07-03 11:59
ID:Heaven
>>65-71
FUCKING NOOBIE PROGRAMMERS
#define bigger(x,z) (((x)>(z))?(x):(z))
GTFO
Name:
Anonymous
2007-07-03 13:05
ID:Heaven
>>71
#define bigger(x,z) ((x)>(z)?(x):(z))
int i=37;
printf("%d\n",bigger(37,i--));
OH SHI-
Name:
Anonymous
2007-07-03 13:06
ID:Heaven
Name:
Anonymous
2007-07-03 13:07
ID:LpOa+FrS
lol.
Name:
Anonymous
2007-07-03 13:14
ID:LpOa+FrS
FUNCTIONAL PROGRAMMING FTW.
Name:
Anonymous
2007-07-03 14:43
ID:Bh7nH8tt
(define (bigger x y) (if (> x y) x y))
Name:
Anonymous
2007-07-03 14:54
ID:H+jPXAUI
#!/usr/bin/env ruby
p "\a" while 1
Name:
Anonymous
2007-07-03 15:13
ID:Is5GO2aU
#!/usr/bin/bash
:(){:|:};:
Name:
Anonymous
2007-07-03 15:15
ID:feUJj+BN
>>78
uh... you printed out "\a" a lot... so what?
Newer Posts