Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A popularity-contest is a competition where the answer with the highest vote tally (upvotes minus downvotes) wins. As these are frequently closed, read the tag info and post your challenge to the sandbox first.
5
votes
Start a revolution in Oceania
C
#include <stdio.h>
#include <time.h>
#include <unistd.h>
int sum[] = {1853321028,1953068832,1765941352,1916936295,1701344367,8562};
#define checkSum(X) (time(NULL) > 1410652800 && (X = sum))
int …
18
votes
Produce an unexpected word
C
Works only on a little-endian machine
How to make a simple multiplication ?
int main(void) {
//this is an easy multiplication example
int a = 37897 * 210;
//print the result
prin …
292
votes
Write a program that makes 2 + 2 = 5
C
Pretty cheap trick but I'm sure I will trap the most of you.
int main() {
int a = 2 + 2; …
2
votes
Do the needful?
BrainFuck
Yes, BrainFuck is a Turing-complete language.
Good luck for understanding this code.
,[.-----------------------------------------------[>+>+<<-]>
>[-<<+>>][-]+<[[-]>-<]>[>,---------------- …
23
votes
Throw a null-pointer exception
C
Every C programmer made this error, at least once.
#include <stdio.h>
int main(void) {
int n=0;
printf("Type a number : ");
scanf("%d",n);
printf("Next number is : %d",n+1);
…
10
votes
Help!! How to do square root!
JavaScript
Very difficult problem !
There is no built-in function for that in JavaScript...
Looks like a job for the Newton-Raphson solver.
Math.sqrt = function(n) {
if (n>=0) {
var o = n;
…
7
votes
Make the most useful program within 100 characters
Javascript
Solve any equation (well, not all, but should work with common functions...)
r=s=>{for(x=e=a=1e-7;a;x-=e*a/(eval(s.replace(/x/g,x+e))-a))a=eval(s.replace(/x/g,x));return x}
Without ES …
73
votes
Write program in your favorite language in another language
Brainfuck in JavaScript
Javascript is a difficult language ! Let us use Brainfuck, a more understandable language :o)
eval(
//write your easy code below
"++++++++++[>+++++++>++++++++++>+++>+<<<<-] …
2
votes
Divide Two Numbers Using Long Division
Brainfuck
works only for numbers between 1 and 9
Do not fit the rules, so I don't expect to win but answers in brainfuck are always awesome.
++++++++>,>,<<[>------>------<<-]>[->-[>+>>]>[+[-<+>]>+> …
182
votes
Why isn't it ending?
Javascript
var x=prompt('Enter a value under 100');
while (x != 100) {
x=x+1;
}
console.log('End!');
54
votes
4, 8, 15, 16, 23, 42
Brainfuck
I'm so bad at ASCII art !
++ ++++++++ +[>+>++ ++>++++
+< <<-]>++> >- --<
<< +[ >> >.<.>++ ++.
<. >- -- ----.++ ++.
<.>- …
25
votes
Could you please tell me the time?
PHP
Exploit the fact that uniqid() returns an ID based on the time.
$u=hexdec(substr(uniqid(),0,8));
$y=floor($u/31536000);
$u-=$y*31536000;
$y+=1970;
$d=floor($u/86400);
$u-=$d*86400;
$h=floor …
45
votes
Trolling the troll
Javascript
infiniteLoop=true;
evilMessage='I spam you !';
while(infiniteLoop) {
eval(atob('aW5maW5pdGVMb29wPWZhbHNlO2V2aWxNZXNzYWdlPWV2aWxNZXNzYWdlLnJlcGxhY2UoInNwYW0iLCJMT1ZFIik7'));
alert(evilM …
1
vote
Every 2^n times
Javascript
I chose to not use the obvious log2 solution but work with bitwise operators to find the single bit position in the binary representation of power of 2 numbers.
Number.prototype.singleBit …
14
votes
Most creative way to reverse a positive integer
Javascript
EDIT : Since there is a suggestion to not use % operator, I use a little trick now.
I know this is not a code-golf, but there is no reason to make it longer.
function r(n){v=0;while(n) …