Challenge :
given 4 numbers as inputs display one possible solution that results in 100 using operations. +-*/()^ (the ^ is for exponent)
Input :
You will be given 4 non-decimal positive integers as input.
You can alternately take input as an array of numbers.
Output :
Arrange the value...
it'll be a bit annoying because then I need to custom-define it instead of using the Python semi-wrapper, but I need to implement my custom definition of and and or anyway
More than a month ago, we've reached a consensus: We want MathJax back. The reasons why it was turned off in 2015 no longer seem to apply, and details about why MathJax is needed on this site are detailed in the linked post. After a while, I asked a Community Manager about what we shall do next, ...
PPCG has graduated. Some features for graduated sites come immediately after graduating. However, other features are held off for an indefinite amount of time:
The site gets a custom theme, and
Privilege levels, which are initially lowered to help growing beta sites grow, are raised to match th...
Recently I've been posting a lot of challenges on the site. This is because I am in a class where the homework are programming challenges (Algorithm Class).
Is that OK? or should I stop posting them? I ask because I know this is not site for homework (Yes, the answers helps me to create better ...
@user202729 I meant to ask how do we know that it doesn't change from, say, -1 mod 5^n for some of the digits to 1 mod 5^n to the other (sorry if stupid question)
@user202729 why isn't there a root to 1 that ends in those 7 digits (where the numbers follow -1 mod 5^n), but also from the eighth digit it follows 1 mod 5^n instead
Challenge :
Count the number of ones 1 in the binary representation of all number between a range.
Input :
Two non-decimal positive integers
Output :
The sum of all the 1s in the range.
Example :
4 , 7 ---> 8
4 = 100 (adds one) = 1
5 = 101 (adds two) = 3
6 = 110 (add...
(mostly for restricted-complexity. For fastest-algorithm it's the algorithm that matters, not the code. Answers without code are allowed.)
Consider a simple function:
lambda a,b:a+b
What should be the time complexity of this function?
If it's O(log(a)+log(b)), most of the current restrict...
I want to do this, Render an ASCII maze but with ascii pipe characters.
I know this is similar, but I think the extra logic required to figure out which character to put at each position makes this sufficiently different.
here is what I am thinking of asking.
Write code that replaces non wh...
@LeakyNun what if I phrase the question in a different way, x is a number that ends in 249, it is congruent to -1 mod 5^3 and 1 mod 2^3. It is given that x*x is congruent to 1 mod (5^3, 2^3, 10^3). How do you know that x is congruent to -1 mod 5^4? (and likewise, 1 mod 2^4)
@J.Sallé Yes, it is. f⍰A returns a future value which won't actually be computed until needed. E.g. you can do list←⍳{⎕←⍵}⍰4 and 4 won't actually be printed until you ask for list (which itself will be 1 2 3 4).
aaaaaaaaaaaah now it all makes sense, I thought I was missing some obvious way to determine that, but the only way you know is through using p-adic numbers and the number of roots
Richard Dawkins in his book The Blind Watchmaker, describes a Weasel program. The algorithm can be described as follows:
Start with a random string of 28 characters. Valid characters are all upppercase letters, and space.
Make 100 copies of that string, with a 5% chance per character of ...
Challenge :
Count the number of ones 1 in the binary representation of all number between a range.
Input :
Two non-decimal positive integers
Output :
The sum of all the 1s in the range.
Example :
4 , 7 ---> 8
4 = 100 (adds one) = 1
5 = 101 (adds two) = 3
6 = 110 (add...
@Zacharý I store a scope and a global scope and pass them down in the recursive evaluate function, and accessing variables is done by using scope[name] and modifying is with scope[name] = value
I usually make a separate assign function because of multi-assignment
I'm struggling to figure out how to not torture myself, as the only way I see to implement variables is to create a LazyObject class that overrides EVERY SINGLE MAGIC METHOD, as things like A+(A←2+A)+A←3 need to work properly.
Maybe I could rearrange some stuff, moving CodeObject (the thing that turns atoms into values) into CodeObject_ (the backup, giving a dummy object) and add an activate method for getting gthe value. Let's just hope I don't break 1 + 2again >_<
@Zacharý why would that be particularly hard? Just parse name← differently (as a monadic function) that assigns to the variable (that might have bad implications around ops though)
is there some problem just having ← be a regular operator and just make it have special actions for certain structures of the left argument in the AST?
@Adám Yeah, I allow ⍣= (that is, once ⍣ is implemented) anyways. I did it as a way to implement dyadic operators without having to go through NDNNDFFDNFDF
yeah I did not think of that. feels like it should be impossible to do as to correctly parse an expression all variables need their arities used correctly but ← needs the raw variables (though Dyalog obviously got around that somehow)
@Adám I meant from a parsing perspective. How is {(⍺⍺⍣⍵⍵) ⍵} any different from ⍣ (well, except that there's no use of ⍺, but functions should be able to handle both cases)?