Your challenge, should you choose to accept it, is, given an integer K >= 1, find integers A and B such that at least one of the two conditions following hold:
K = 2^A + 2^B
K = 2^A - 2^B
If there does not exist such A and B, your program may behave in any fashion.
Test cases
K => A, B
15 =>...
Your challenge, should you choose to accept it, is, given an integer K >= 1, find integers A and B such that at least one of the two conditions following hold:
K = 2^A + 2^B
K = 2^A - 2^B
If there does not exist such A and B, your program may behave in any fashion.
Test cases
K => A, B
15 =>...
code-golfstring
Make me a bad fade animation
Your task is to, as the title discreetly suggests, make a bad fade animation of one word turning into a second word for yours truly.
What exactly is this "fade animation" you may ask?
To make a spectacular(ly bad) fade animation, you start with you...
rofl, just transposed something and then transposed it right back just to use the padding function on the first transpose: codegolf.stackexchange.com/a/92855/31343. still shorter than anything else... D:
@quartata I'm not great with functional languages in general, but I'm good at tinkering with boilerplates code. Given a working template to handle the basics, I might if the challenge itself is interesting.
After posting a rather specific, narrow, restrictive, one-language (well... one group of languages: POSIX-ey shells) puzzle, thats been "closed as too broad". Commentators then offered explanations inconsistent with the notion of "too broad":
"challenges that are restricted to one language ar...
if last of input==0, (output input except last of input, and 1, ) else output (this function with input all of input but the last part of input) and zero
that's kind of cinfusing, let me try again
funcname: if input[-1]==0, output input[:-1]+[1], else output funcname(input[:-1])+[0]
Brachylog, 23 bytes
,A:B#+.:2rz:^a{+|-}?,.=
Try it online!
This is much faster than required, e.g. this is still under 10 seconds on TIO.
Explanation
This is basically a direct transcription of the formula with no optimization:
,A:B The list [A, B]
#+ Both A and B are greater tha...
This was mostly implemented by the person who implemented CLPFD for SWI-Prolog
The reason this isn't implemented by default in CLPFD is because you have no guarantees of termination when the domain is infinite which Prolog people don't like
5 ?- [library(clpfd)].
true.
6 ?- [A,B] ins 0..264, (2^A + 2^B #= 264 ; 2^A - 2^B #= 264), label([A,B]).
A = 3,
B = 8 ;
A = 8,
B = 3 ;
false.
If this company honestly thinks that Anonymous is the emblem of ethical hacking, WTF would I expect them to be smart enough to teach me anything worth knowing?
Language-creation has become a popular activity on PPCG. A decent portion of answers, especially code-golf answers, are written in languages invented by the community. These are also languages that might be unfamiliar to this site's wider viewing audience.
What languages (esoteric, golfing, or...
Your task is to make a program that, using +, -, *, /, sqrt, ceil, ! and floor, output 100 equations that equal every number from 1 to 100 using as few 1's as possible in the output. The only numeral you are allowed in the output is 1.
There is only 1
Your task is, given a number n, to generate an equation that equals to the number n.
The catch is: you're only allowed the number 1 in the output.
The operators at your disposal are:
+, -, * and /
sqrt (as s)
ceil and floor (as c and f respectively)
! (factorial)
You must a...
First off, I'm sorry that your first contribution to our site was so poorly received. I hope this doesn't discourage from posting more challenges. Writing good challenges is really hard, especially for users who are unfamiliar with our rules and culture. But, they are extremely important for the ...