Skip to main content
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
Results tagged with
Search options not deleted user 3970

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.

0 votes

Print 123454321 without if statements and using only 2 variables

Powershell ((1..9)|%{ $_ = ($_%18-5) 5 - @($_,-$_)[$_ -lt -$_] })-join ' ' 1 variable, no if, no functions (unless you were to count -join which is just for displaying the data... Explanation: Lo …
DarkAjax's user avatar
  • 669
0 votes

Loop without 'looping'

PowerShell date sleep 1 $this = $MyInvocation.MyCommand.Definition &"$this" This will print the current date, wait 1 second and then the program will call itself endlessly...
DarkAjax's user avatar
  • 669
3 votes

Print 123454321 without if statements and using only 2 variables

Perl Version 1: for(1..9){ $x = ($_%18 - 5); print 5 - ($x, -$x)[$x < -$x] . " "; } Version 2: for(1..9){ $x = ($_%18 - 5); $x =~ s/-//; print 5 - $x . " "; } For both versi …
DarkAjax's user avatar
  • 669
3 votes

Write a piece of code to output the line number of the print / output statement itself (in t...

Powershell $l=(Get-PSCallStack | ForEach{$_.Location})[0].split(' ')[-1]; "Hello World, from line $l!" And: try{ I AM ERROR. } catch { $l=$error[0].InvocationInfo.ScriptLineNumber; "Hello World, from …
DarkAjax's user avatar
  • 669
3 votes

Write a piece of code to output the line number of the print / output statement itself (in t...

Perl Another Perl one: use warnings; $SIG{__WARN__} = sub { ($line = shift) =~ s/\D//g; }; $x=$x+1; print "Hello World, form line $line!\n";
DarkAjax's user avatar
  • 669
3 votes

Make an error quine!

ksh $ ksh: ksh:: not found. ksh: ksh:: not found.
DarkAjax's user avatar
  • 669