Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Something for the weekend 5

Status
Not open for further replies.

vgulielmus

Programmer
Jan 27, 2014
522
RO
Encode the followings formulas. The solutions must not include (explicit) mathematical formulas.
Code:
a) The factorial of 6
6! = 1*2*3*4*5*6
b) 6 to the power 4
6**4 = 6^4 = 6*6*6*6
c) The fifth root of 3125
3125^0.2 = 5
d) This math expression
6^3/2 = 108

* This is only for fun, not recommended as a substitute for math formulas.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
lcTime = CHR(42)
lcPower = CHR(94)

?EVALUATE('6' + lctime + '9')
?EVALUATE('6' + lcPower + '2')
?EVALUATE('3125'+lcPower + '.2')




Ez Logic
Michigan
 
Numerous variations can be made :
- using _vfp.eval() instead of evaluate()
- using macrosubtitution instead of evaluate()
- automating other applications
- using advanced math to compose equivalent expressions

My first intention was to get solutions without revealing the math expressions.
I loved the first solution, the one using IE automation. Only words, no math formula!
The must direct approach was the one using the preprocessor directive, and the last solution.

Instead of Evaluate("6^3"), I preferred Evaluate(Transform(63,"9^9")), or better SET SEPARATOR TO "^" and Evaluate(Transform(63,"9,3")). In the last version, the math expression is completely hidden.
And when I saw the second solution, I was sure someone would use Transform() in a similar way.

When I composed the problem, I was very amused by SET SEPARATOR TO "^" and Evaluate(Transform(31250.2,"9999,9.9"))
I hope I was not the only one amused by this "game" :)

Thanks you for playing :)

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Indeed, that was very amusing, especially using the separator for something else than dot or comma. Actually I don't know any locale/culture with anything else than dot or comma, making use of that in TRANSFORM is (obviously) something, that didn't come to my mind.

I think this got the most variety of solutions so far for thie little series. So a very good fun puzzle.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top