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.
3
votes
Outputting a base-proof expression
The base idea is the same as the previous program: find a square near our target number, and represent its root and the remainder recursively. … But now we allow our square being also some larger than the target number, which then makes the remainder negative. …
2
votes
Count up forever
Ceylon (on JVM), 92 87 78 bytes
(The Big integer type Whole which is used here does only exist on the JVM, not when compiling for JavaScript.)
This is the third improvement (78 bytes):
import ceylo …
0
votes
Find the sum of all possible base representations
((any(s*.letter) then 11 else 2) .. 36)
// map each r of them to ...
.map((r) =>
// try parsing s as a number using base r
parseInteger(s, r)
// if that …
2
votes
Numbers that are actually letters
any(formatInteger(n,16)*.digit);
Straightforward ... we format n as a hexadecimal number (which produces a string), call on each character of that string the .digit number (which returns true if it is …
0
votes
XOR multiplication
Ceylon, 90 bytes
alias I=>Integer;I x(I a,I b)=>[for(i in 0:64)if(b.get(i))a*2^i].fold(0)((y,z)=>y.xor(z));
This is just the algorithm as described: multiply a by 2^i wherever the ith bit is set in …
0
votes
What is the smallest positive base 10 integer that can be printed by a program shorter (in c...
Ceylon, 111111111111111111111111111111111111111111 (42 digits)
This was my second try:
shared void run(){print("1".repeat(42));}
A program with length 41, prints a string of 42 ones.
My first, …
2
votes
Cantor's unspeakable numbers
.
=>
// increment the counter, then check if it
// is an unspeakable number. …
1
vote
Is this number a prime?
(t .. c - t).any((d) => c % d < o));
}
}
The : range operator needs an Integer (the number of elements) as a second argument, so we use the .. operator, which takes the same type as the first argument …
2
votes
Find the XOR Primes
i * 2^k
].fold(0)((y, z) => y.xor(z))) i
}.empty).take(n);
This creates an infinite iterable of integers (starting with 2), filters it by checking if a number …
1
vote
List Prime Numbers
any((d) => c%d < 1) )
// then take the first n elements
.take(n)
// print each element
.each(print);
This uses the same basic prime check as my answer to the "Is this number …
1
vote
Let's decrease the monotony
Ceylon, 86 bytes
Object m(Integer+l)=>let(c=l.paired.map(([x,y])=>x<=>y))[if(!smaller in c)equal in c];
The function takes the input as its parameters, and returns a tuple of zero or one booleans – …
0
votes
Simple Factorial Challenge
Ceylon, 98 bytes
import ceylon.whole{l=one}Integer q(Integer n)=>sum({0,*product({l,*(l:n)}).string*.offset('0')});
Try it online
Explanation:
This is quite long, because we need to convince th …