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 |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
2
votes
iHateOddNumbers
Racket, 29 bytes
(λ(x)(/ x(modulo(add1 x)2)))
Try it online!
4
votes
Are All the Items the Same?
Racket, 37 18 bytes
(λ(x)(apply = x))
Try it online!
-19 thanks to Wezl
This takes advantages of the fact that = in Racket can take any number of arguments. Note that the tio seems to run an old ver …
2
votes
Implement an Over function
Racket, 30 bytes
(λ(f g x)(apply g (map f x)))
Try it online!
Takes a and b as a list i.e. '(a b).
1
vote
Print the last, middle and first character of your code
Racket, 15 bytes
(display "(y)")
Try it online!
1
vote
A "cheating" quine
Racket, 63 bytes
#lang racket
(display(file->string(find-system-path'run-file)))
Try it online!
Pretty straightforward - just finds the current file, reads it, and prints it back out.
2
votes
Guess my password (cops' thread)
Racket, 202 bytes, Safe
#lang racket
(define (h z)
(when (procedure? z) (error "you lose"))
(define a (λ (x) (not x)))
((λ (f) (call/cc (λ (k) (k (or (a z) (set! a ((eval f) k))))))) z)
(and …
1
vote
Don't google "google"
Racket, 46 bytes
(λ(x)(if(eq? x"google")(-)(string-length x)))
Try it online!
Gives an arity mismatch error on the input "google" since - needs at least one argument.
2
votes
"DDoouubbllee ssppeeaakk!!"
Haskell, 18 bytes
f s=s>>= \c->[c,c]
Try it online!
4
votes
Shortest infinite loop producing no output
Racket, 39 bytes
((λ(x)(x x))(λ(x)(x x)))
1
vote
Average of your code
Python 3, 11 bytes
print('K')#
The average value is 75.09, which rounds to 75 - K.
1
vote
Print the Greek alphabet!
Python 3, 88 bytes
import sys
s=945 if sys.argv[1:] else 913
for i in range(s,s+25):
print(chr(i),end='')
2
votes
Add N numbers without using + or -
Haskell, 3 bytes
sum
Function that takes an argument as a list e.g. sum[1,2,3] and returns the sum of the list.
1
vote
Shortest infinite loop producing no output
Haskell, 9 bytes
main=main
Defines the main function (required to run) recurring on itself, resulting in an infinite loop.
1
vote
The Ackermann function
Haskell, 47 bytes
a 0 n=n+1
a m 0=a(m-1)1
a m n=a(m-1)(a m (n-1))
(Run using ghci <filename>)
Almost directly copies from the problem definition (thank you pattern matching!).
1
vote
Find the percentage
Racket, 81 43 bytes
Accepts a list and index. Outputs rationals (default for division in Racket).
Big thanks to Galen Ivanov for finding the apply function. Still learning as I go :) .
(λ(l i)(*(/(l …