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 competition to solve a particular problem through the usage and manipulation of numbers.
2
votes
I spy with my little eye a number beginning with n++
sh, 170
tr -cs 0-9/. '\n'|
grep -vxEe"[0-9]+/[0-9]+" -e"[0-9]*\.0*[1-9][0-9]*"|
sed -r 's/^([0-9]*)\.0+$/0\1/'|
tr -s /. '\n'|
awk -vORS="\r" '$1==l{l=$1+1;print l-1}END{print "\n"}'
4
votes
How many peaks in my mountain range?
Julia, 66
x->(y=diff([0;x;0]);y=y[y.!=0];sum((y[1:end-1].>0)&(y[2:end].<0)))
Pad, differentiate: y=diff([0;x;0]).
Ignore the plateaus: y=y[y.!=0].
Count + to - zero crossings: sum((y[1:end-1].>0)&(y[ …
1
vote
How many peaks in my mountain range?
MATL, 23
Since we need to use stack based esolangs to be competitive, I reimplemented my Julia solution in MATL.
0i0hhdtg)t5L)0>w6L)0<*s
Push 0, input, 0, concatenate twice. 0i0hh => x = [0, input('' …
7
votes
Split, flip and recombine integers
= 2 in the factors array
p % multiply that factors
q2/ % product - 1 / 2
2w^ % 2^x
K % load variable K (the logical array)
s % sum (yields the number of 2s)
2*Q % count * …
0
votes
Condense these page numbers!
{o=$1;c=", ";p=""}
# if the sequence is not a single number, its end is denoted by "-o".
# print only the last n digits of o.
o>s
{p="-"substr(o,length(o)-length(o-s-1)+1)}
# end the current sequence …
1
vote
Accepted
Digital Clock Matches Puzzle
sum(map(b->c(a$b),m))
We now have a vector n of length 10 representing the numbers 0-9 that gives us the total number of additions/deletions we have to perform to tranform all input digits to that number … , or inf, if such a transformation is impossible without changing the number of lines. …
1
vote
9 Deaths of the Ninja
MATL, 32
9yi"@+t0>~?x1-y]]g*wxt0>~?x'dead'
Explanation
9 # push 9
y # duplicate 2nd value to top (there is none -> get it from input first)
i # get input and push it
The sta …
5
votes
Swap out some periodic and non-periodic parts
Python 2, 292 bytes
def x(n,d):
L=len;s=cmp(n*d,0);n*=s;b=p=`n/d`;a={};n%=d
while not n in a:
a[n]=p;q=n/d;n=n%d
if q==0:n*=10;p+=' '
p=p[:-1]+`q`
p=p[L(a[n]):];a=a[n][L(b):]
if n==0:p=''
n …
4
votes
Numbers with Rotational Symmetry
sh, 40 33 bytes
[ `rev<<<$1|tr 6923457 96` = $1 ]
Input via command line argument, output via exit code. Generate all testcases:
for i in `seq 0 10000`
do
if [ `rev<<<$i|tr 6923457 96` = $i ]
the …
5
votes
Yahtzee Small Straight Detection
MATL, 11 bytes
udY'w1=)2>a
Try it online
u unique (implicit sort)
d diff
Y' run-length-encode
w1=) exract the length of all runs of ones
2> check whether …
6
votes
Convert English to a number without built-ins or libraries
sh + coreutils, 112 bytes
Can be run on all testcases at once, one per line.
sed -r "`awk '$0="s/"$0"/+"NR"/g"'<<<"on
tw
th
fo
fi
si
se
ei
ni
te|lv
el"`
s/ /y0/
s/y/*10/
s/^\+|[a-z-]//g"|bc
Explan …