|
More of recreational value, something like a mathematical excursion.
|
|
|
|
|
A variant using the four digits, 1 9 7 and 2, in order, was educational to me. Took a few minutes to write a BASIC program to generate and evaluate random Polish notation expressions. The program took days to generate almost all of 1..100 on a time-shared mini-computer. When one of my kids had a similar assignment in school, I wrote the program again in C for modern hardware. Ran instantaneously.
That program taught me that computers can solve problems without human super-skills being needed.
|
|
|
|
|
Amarnath S wrote: any number between 1 and 100
Presumably that means any natural number? If you had to express every real number, or even all the rational numbers, in that range, you'd need a much longer train journey!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes. I meant natural numbers. Not rational numbers, that set may be countable but is infinite, or irrational numbers; that set is not even countable.
|
|
|
|
|
16=4+4+4+4
88 = 44+44
2=4/4+4/4
4=4+4*0+4*0+4*0
...
|
|
|
|
|
Last one - cannot use the number 0 in the expression.
|
|
|
|
|
Ok
32=4*4+4*4
36=4!+4+4+4
56=4!+4!+4+4
76=4!+4!+4!+4
96=4!+4!+4!+4!
|
|
|
|
|
Since this is "codeproject" my train trip was short. Took about 15 minutes to get the 1st order solution in C.
Yes...I know it's simplistic....but a good exercise nonetheless. Obviously could be improved for all the special cases....could obviously compute squares, square roots, factorials, etc and start from the largest of those to reduce the value. I'll leave that exercise for others.
In this code just change the modulus value to whatever you want and you'll get all the 1st order solutions.
#include <stdio.h>
int modulus = 5;
void do4(int n)
{
int mod = n % modulus;
int i, j;
printf("%d=", n);
for (i = modulus; i <= n; i += modulus)
{
if (i > modulus) { printf("+"); }
printf("%d", modulus);
}
for (j = 0; j < mod; ++j)
{
if (i != modulus) { printf("+"); }
printf("(%d/%d)", modulus, modulus);
}
printf("\n");
}
void main(void)
{
int i;
for (i = 1; i <= 100; ++i)
{
do4(i);
}
}
|
|
|
|
|
|
Four fours! (not arbitrarily many)
|
|
|
|
|
It works for four fours. But this is "Code Project" and writing a routine to do just that one example is no fun.
|
|
|
|
|
The output, after repairing a small bug - condition in 2nd loop is i != modulus || j > 0:
1=(5/5)
2=(5/5)+(5/5)
3=(5/5)+(5/5)+(5/5)
4=(5/5)+(5/5)+(5/5)+(5/5)
5=5
6=5+(5/5) etc.
None of these lines has five fives, so this does not solve the problem. Running it with modulus 4, one gets:
1=(4/4)
2=(4/4)+(4/4)
3=(4/4)+(4/4)+(4/4)
4=4
5=4+(4/4) etc
Here, only the solution for 2 has four fours, all others are not solutions (two fours, six fours, one four, three fours, ...). So how does this "work for four fours"?
|
|
|
|
|
I didn't program the entire solution...left that for others to do.
One could make the necessary change to solve the X/Y problem of trying to get 5 5's or 3 5's or such an arbitrary combination.
I was just demonstrating the "let's use 4's" to solve the values.
That's why I said there needed to be more work to do the special cases of "only 4" or "only X" values.
You eight need to increase or decrease the # of terms so is a bit more challenging.
|
|
|
|
|
Ok - fine In other words, what you did does not take any useful step in any sensible direction for solving the problem
For this, one would need to create all possible expression trees fulfilling the stated properties (e.g., exactly four leaves with constant 4, only the given operator node types) and collecting the trees and their expression results. A suitable pruning condition could prevent creation of trees definitely not yielding results in {1...100} (although I don't see what a simple pruning condition would look like; maybe two stacked exponentations can always be excluded* or thereabouts).
* Not true: 4^(4^(4-4)) is a valid solution for value 4, and (4^4)^(4-4) is a valid solution for value 1.
|
|
|
|
|
|
|
Try this one, it looks the same as the original but points to ZDnet not the lounge itself.
Windows 10: Now you can selectively block USB devices from connecting to your PCs | ZDNet
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
|
|
|
|
|
Saw this earlier, the link did work then. I am very interested in getting embedded programming systems working (also being the Dinosaur, I know ISA ports!) it seems there is talk of a method of white listing devices which could make my life easier BUT Admin Rights!
|
|
|
|
|
I suspect that will make the secure computer admins at my last job happy. Rogue USB drives were a major concern; and being able to easily disable them directly should be a major win. I'm not sure if they had some sort of kludged setup to try and stop them, or just made do with putting a "User XXX was very naughty" entry in the logs (reviewed weekly) to deal with it after the fact.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
|
|
|
|
|
They rolled it out where I work. I think they used a group policy to exempt devices that needed USB access for their daily work.
I think they were mostly worried about office workers taking company data.
|
|
|
|
|
Yes. Where I work, you can't write to USB devices by default - you need to get special dispensation.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Aim to sabotage mini boat (8)
|
|
|
|
|
Aim
to sabotage (anag)
mini boat MINIBOAT
AMBITION
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Sometimes the easy ones take forever ... and the hard ones get done straight away!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|