OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!!

8

88888 Dihedral

PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

PROBLEM 2: COMPUTE PI AS IN THE ABOVE!

PROBLEM 3: LIST ALL PERMUTATIONS OF A STRING WITHOUT ANY REPEATED STRING IN THE LIST!

PROBLEM 4: IMPLEMENT A HASH THAT COULD BE AS FAST AS POSSIBLE AND VERY STABLE AND ROBUST TO BE USED EVERYWHERE TO BEAT OTHER LANGUAGES WITH A HASH BUILT IN.
 
I

Ian Collins

PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

PROBLEM 2: COMPUTE PI AS IN THE ABOVE!

PROBLEM 3: LIST ALL PERMUTATIONS OF A STRING WITHOUT ANY REPEATED STRING IN THE LIST!

PROBLEM 4: IMPLEMENT A HASH THAT COULD BE AS FAST AS POSSIBLE AND VERY STABLE AND ROBUST TO BE USED EVERYWHERE TO BEAT OTHER LANGUAGES WITH A HASH BUILT IN.

Problem 5: Locate and turn off caps-lock.
 
E

Eric Sosman

I solved those long time ago in C.

Glad to hear it. Just to verify, please post the output of
your Problem 3 solution for the string

I solved those long time ago in C

.... and state whether you are considering or ignoring letter case,
so we can check your answer.
 
K

Kaz Kylheku

Glad to hear it. Just to verify, please post the output of
your Problem 3 solution for the string

I like problem 4, because of its well-quantified and concretely targettable
requirement: "as fast as possible".
 
8

88888 Dihedral

1. Define an order in the symbol set of the string by a sort.
2. Start from the smallest mapped by the ordered defined which will yield the maximum if reversed.
3. From the smallest string by the order defined, just generate the next until the maximum is reached.

I hate to answer trivial questions!
 
I

Ian Collins

1. Define an order in the symbol set of the string by a sort.
2. Start from the smallest mapped by the ordered defined which will yield the maximum if reversed.
3. From the smallest string by the order defined, just generate the next until the maximum is reached.

I hate to answer trivial questions!

Like you hate quoting context?
 
E

Eric Sosman

1. Define an order in the symbol set of the string by a sort.
2. Start from the smallest mapped by the ordered defined which will yield the maximum if reversed.
3. From the smallest string by the order defined, just generate the next until the maximum is reached.

I hate to answer trivial questions!

I'm sure you'll be happy to learn that you're tied for third
place in my fastest-to-PLONK list.
 
J

Joe Pfeiffer

88888 Dihedral said:
PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

PROBLEM 2: COMPUTE PI AS IN THE ABOVE!

PROBLEM 3: LIST ALL PERMUTATIONS OF A STRING WITHOUT ANY REPEATED STRING IN THE LIST!

PROBLEM 4: IMPLEMENT A HASH THAT COULD BE AS FAST AS POSSIBLE AND VERY STABLE AND ROBUST TO BE USED EVERYWHERE TO BEAT OTHER LANGUAGES WITH A HASH BUILT IN.

Please provide the email address of your instructor, so we can submit
our homework directly.

Also, please do something about your broken caps-lock key.
 
L

Lew Pitcher

PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

"Euler's Number"? Do you mean "the mathematical constant e"? Or
perhaps "a sequence En of integers defined by a specific Taylor series
expansion"?

If you mean /e/, then
a) the number starts with a /2/, not a /1/ (as in 2.718281828...),
b) Steve Wozniak published a solution to 116000 places, in 1981, and
c) /I/ wrote and published a C-language solution to 5000 places in the
1990s
What's so difficult about a /30 place/ solution?
PROBLEM 2: COMPUTE PI AS IN THE ABOVE!

It's been done. Many times over.
PROBLEM 3: LIST ALL PERMUTATIONS OF A STRING WITHOUT ANY REPEATED STRING IN THE
LIST!

A little more difficult, but again, it's been done many times over.
PROBLEM 4: IMPLEMENT A HASH THAT COULD BE AS FAST AS POSSIBLE AND VERY STABLE AND
ROBUST TO BE USED EVERYWHERE  TO BEAT OTHER LANGUAGES WITH A HASH BUILTIN.

Again, it's been done, many times. And it's simpler than e or pi.

So, what's your point? Or is this a sad attempt to get others to do
your homework for you?
 
M

Martin Ambuhl

PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

PROBLEM 2: COMPUTE PI AS IN THE ABOVE!

PROBLEM 3: LIST ALL PERMUTATIONS OF A STRING WITHOUT ANY REPEATED STRING IN THE LIST!

PROBLEM 4: IMPLEMENT A HASH THAT COULD BE AS FAST AS POSSIBLE AND VERY STABLE AND ROBUST TO BE USED EVERYWHERE TO BEAT OTHER LANGUAGES WITH A HASH BUILT IN.

The subject line "OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!!"
is a lie. It should read: "a cretin who can't turn off his shift lock
and engages in childish multiple exclamation marks wants someone else to
do his homework." Or just "Dihedral is a troll, please ignore."
 
K

Keith Thompson

Martin Ambuhl said:
The subject line "OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!!"
is a lie. It should read: "a cretin who can't turn off his shift lock
and engages in childish multiple exclamation marks wants someone else to
do his homework." Or just "Dihedral is a troll, please ignore."

Quite possibly, but it's also possible that the OP has seen the
recent spate of off-topic flaming and is making a clumsy attempt
to encourage actual discussion of C programming.

Perhaps we should consider following his example, if not his
typography.

Some advice to 88888 Dihedral:

1. Don't post in all-caps. It's considered equivalent to shouting, and
is generally seen as rude. Same for exclamation points.

2. Questions about actual problems you've encountered are more likely to
generate good answers than contrived puzzles (unless the puzzles are
particularly interesting, but frankly these aren't).
 
8

88888 Dihedral

There was some library for big numbers written C. Of course, printing the big numbers won't be the same as printing native types. With other languages supporting big numbers C with some libraries seems not attractive to novices.
 
K

Keith Thompson

88888 Dihedral said:
There was some library for big numbers written C. Of course, printing
the big numbers won't be the same as printing native types. With other
languages supporting big numbers C with some libraries seems not
attractive to novices.

If you're actually interested in particating here, then please
(a) format your text in lines shorter than 80 columns, preferably
around 72 and (b) quote some context from the article to which you're
replying (see 99% of the followups here for examples; Google Groups
can make this difficult, but the "old" interface isn't as bad as
the new one).
 
M

Malcolm McLean

"Euler's Number"? Do you mean "the mathematical constant e"?
That is Euler's number.

The confusion arises because e doesn't stand for "Euler". He chose it
because other mathematicians had already bagged a, b, c, and d for
other uses. The C programming language was named on the same system.
 
8

88888 Dihedral

"Euler's Number"? Do you mean "the mathematical constant e"? Or
perhaps "a sequence En of integers defined by a specific Taylor series
expansion"?

If you mean /e/, then
a) the number starts with a /2/, not a /1/ (as in 2.718281828...),
b) Steve Wozniak published a solution to 116000 places, in 1981, and
c) /I/ wrote and published a C-language solution to 5000 places in the
1990s
What's so difficult about a /30 place/ solution?


It's been done. Many times over.


A little more difficult, but again, it's been done many times over.


Again, it's been done, many times. And it's simpler than e or pi.

So, what's your point? Or is this a sad attempt to get others to do
your homework for you?

I am talking about language features to be checked to be used as a tool to solve problems.
 
P

Phil Carmody

Malcolm McLean said:
That is Euler's number.

Except when one of them's ~2.781828 and the other one's ~0.577215665.
Better to include either the e or the gamma in the name to reduce
ambiguity.

Phil
 
J

jacob navia

Le 20/11/11 20:12, 88888 Dihedral a écrit :
PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!

Euler's constant is the limit of the sum when N goes to infinity of:

1 + 1/2 + 1/3 + 1/4 + ... 1/N - ln(n)

This is related to the PSI function (digamma) by

Euler constant = -psi(1)

This can be calculated in C with this program:
(Using lcc-win. Other compilers will be able to do this too
but in a different way)

d:\lcc\mc79\test>type teuler.c
#include <qfloat.h>
#include <specialfns.h>
#include <stdio.h>
int main(void)
{
qfloat e=psiq(1.0q);
printf("Euler constant is:\n%.95qf\n",-e);
}

OUTPUT:
Euler constant is:
+0.577215664901532860606512090082402431042159335939923598805767234884867726777664670936947063291747

Thanks to this poster I have uncovered a bug in that function, that I
could correct.

lcc-win uses the Cephes Mathematical library of Stephen L Moshier. He uses:

*
* d +-
* psi(x) = -- ln | (x)
* dx
*
* is the logarithmic derivative of the gamma function.
* For general positive x, the argument is made greater than 16
* using the recurrence psi(x+1) = psi(x) + 1/x.
* Then the following asymptotic expansion is applied:
*
* inf. B
* - 2k
* psi(x) = log(x) - 1/2x - > -------
* - 2k
* k=1 2k x
*
* where the B2k are Bernoulli numbers.
*
* psi(-x) = psi(x+1) + pi/tan(pi(x+1))
 
8

88888 Dihedral

I suggest 2 or 3 new built in types added to C that will certainly beat other computer languages. I don't think after 10 years C is still not evolved.
 
K

Kleuskes & Moos

I suggest 2 or 3 new built in types added to C that will certainly beat
other computer languages.

Such as?
I don't think after 10 years C is still not evolved.

Me neither. In fact i think it's evolved quite a bit.

-------------------------------------------------------------------------------
___________________________________
/ I'm DESPONDENT ... I hope there's \
| something DEEP-FRIED under this |
\ miniature DOMED STADIUM ... /
-----------------------------------
\
\
___
{~._.~}
( Y )
()~*~()
(_)-(_)
-------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top