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 |
For challenges that involve the physical layout or physical manipulation of source-code.
4
votes
Code 3k to Codee k
Haskell, 8 bytes
gcd 3 21
Outputs 3, and gcd 3 211 outputs 1.
6
votes
Self-Mutilating Program
MSM, 8 bytes
'.qp.;.;
Transforms the source code to pqpqpqpq
MSM operates on a list of strings. Commands are taken from the left and they treat the right side as a stack. MSM always works on it's …
1
vote
Sequential Multiplication
Haskell, 14 11 bytes
(*)=<<pred$
Usage example
Prelude> (*)=<<pred$5
20
Prelude> (*)=<<pred$(*)=<<pred$5
380
Prelude> (*)=<<pred$(*)=<<pred$(*)=<<pred$5
144020
Maybe this isn't a proper function …
6
votes
Normal and visual string reversion
Haskell, 124 bytes
Forward:
f=id
--esrever.q pam=2>1|esrever=2<1|f;x=x q;')'='(' q;'('=')' q;']'='[' q;'['=']' q;'>'='<' q;'<'='>' q;'}'='{' q;'{'='}' q
Normal reverse:
q '}'='{';q '{'='}';q '>'= …
3
votes
Figure and Ground
Haskell, 88 65 bytes
main=putStr
...........--
.."figure"..........
--"ground"........
and
...........
main=putStr..
--........"figure"--
.........."ground"
. indicates a space. Just some line c …
4
votes
Square and square
Haskell, 7x7 6x6
f=b>>y
y=b++n
n="\n"
b=c++d
c=d++d
d="--"
Outputs
------
------
------
------
------
------
Try it online!
How it works:
f= -- main function which returns the stri …
5
votes
Find the Needle in the Haystack (Robbers)
Haskell
Cracks @Laikoni's answer.
s=map;hay=zipWith;a=head;h=s a.(hay(scanr id).s a<*>s(succ<$))$words"Haysta ayst ackH ays k ayst"
Try it online!
Original code:
hays=map;hay=zipWith;stack=head; …
5
votes
I transpose the source code, you transpose the input!
Haskell, 185 161 bytes
t i
=
i
af
n m
u a e i
l p s d
lu h=u
(
h
e
a
d
a
)
t
h
e
n
[
]
e
l
s
e
m
a
p
h
e
a
d
a
:
t
(
m
a
p
t
a
i
l
a
)
Try it onlin …
75
votes
Inverse function
Haskell, 11 bytes
f=log
pxe=f
and in reverse order:
f=exp
gol=f
This works without the "comment" trick. Instead each version defines an additional, but unused function (pxe/ gol).
2
votes
The confused twister
Haskell, 235 bytes
main=interact$unlines.g.lines;g l@("":_)=l; g l|t<-tail<$>l,n<-length t=zipWith(:)(head<$>l)$ g$take n$drop(n-1)$t++t
maim=interact$unlines.h.lines;h l@("":_)=l; h l|t<-tail<$>l,n< …
1
vote
Palindrome Hello, World
MSM, 73 bytes
GGreetings, Planet!.................,.................!tenalP ,sgniteerGG
The first half just before the middle , builds a reverse greeting string including the additional G on the ve …
11
votes
The repetitive byte counter
Haskell, 8 bytes
(-8+).id
Try it online!
Like many other answers it returns 0 for truthy and non-0 for falsy by repeatedly subtracting the length of the code from the input number.
4
votes
I reverse the source code, you negate the input!
Haskell, 12 bytes
f=id;x-0=x f
Try it online! Reverse:
f x=0-x;di=f
Try it online!
Not as short as Ørjan Johansen's answer, but without comments.
10
votes
From Programming Puzzles to Code Golf
Haskell, 48 bytes
a _="Programming Puzzles";a4="Code\32Golf";f=a 4
a_="ProgrammingPuzzles";a4="Code\32Golf";f=a4
Defines function f which returns the corresponding string.
For reference, the old v …
12
votes
Write A Program That Outputs Its Mirror Level
Haskell, 42 bytes
(8-8)-(-(8-8)^(8-8))--((8-8)^(8-8)-)-(8-8)
Luckily a line comment in Haskell (-> --) is mirrorable and half of it (-> -) is a valid function. The rest is some math to get the numb …