TWISTER 2.1
¿? Your have to take a decision in a program but the creator of the
programming language forgot to supply the programmer with a IF-ELE
Construct? Can you find a work arround?
TWISTER 2.2
¿? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
(* *)
*************** *************** 0oo*********(_) ******oo0****** *************** *****
SMALLEST CODE WILL BE APPRECIATED
:) 24 2295
Nirjhar Oberoi said:
TWISTER 2.1
¿? Your have to take a decision in a program but the creator of the
programming language forgot to supply the programmer with a IF-ELE
Construct? Can you find a work arround?
That depends on what you think IF-ELE should do. Personally, I think it
should subtract the value of ELE from the value of IF, yielding the
difference between the two. The workaround would be as follows:
diff = IF;
diff -= ELE;
TWISTER 2.2
¿? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
I don't think he can. I don't think anyone else can either, since using
loops without using any kind of looping is likely to challenge the
ingenuity of even the most perspicacious programmer. Nevertheless, printing
1 to 100 without using any kind of looping is trivial:
puts("1 to 100");
SMALLEST CODE WILL BE APPRECIATED
No problem. Here ya go:
main(){}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Heathfield wrote:
Nirjhar Oberoi said:
.... snip ...
>
> ¿? You have to use loops and print 1 to 100 without using any kind of looping not even GOTO statement? Can u do it?
I don't think he can. I don't think anyone else can either, since
using loops without using any kind of looping is likely to
challenge the ingenuity of even the most perspicacious programmer.
Nevertheless, printing 1 to 100 without using any kind of looping
is trivial:
puts("1 to 100");
You forgot about recursion:
#include <stdio.h>
void putn(int n) {
if (n - 1) putn(n - 1);
printf("%d\n", n);
}
int main(void) {putn(100); return 0;}
which even the all seeing u can use. Why do people give their
children one character names?
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
On 23 Nov 2006 21:40:06 -0800, "Nirjhar Oberoi" <ni*******@gmai l.com>
wrote:
>TWISTER 2.1
¿? Your have to take a decision in a program but the creator of the programming language forgot to supply the programmer with a IF-ELE Construct? Can you find a work arround?
You may take a peek at local newspapaers, probably ther is some work
around, where you are not asked to make decisions. Street sweeping?
Maybe
>TWISTER 2.2
¿? You have to use loops and print 1 to 100 without using any kind of looping not even GOTO statement? Can u do it?
Ah! that was VHDL, not C! Off Topic here.
library loops;
use loops.all;
print:std_logic _vector(1 to 100)=(others=>' U');
As you can see, not only U, but also OTHERS can do it!
SMALLEST CODE WILL BE APPRECIATED
Try with Huffman coding.
Regards,
Zara
CBFalconer said:
You forgot about recursion:
No, I didn't. I was saving that in case he turned out to be serious, and to
provide some effort of his own.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Heathfield wrote:
CBFalconer said:
>You forgot about recursion:
No, I didn't. I was saving that in case he turned out to be serious,
and to provide some effort of his own.
Well, I kept the example subtly obtuse (the output order and end
points) to give him something to think about. However I think
"challenge the ingenuity of the most perspicacious" implies
impossibility or the need for non-standard code.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
CBFalconer said:
Richard Heathfield wrote:
>CBFalconer said:
>>You forgot about recursion:
No, I didn't. I was saving that in case he turned out to be serious, and to provide some effort of his own.
Well, I kept the example subtly obtuse (the output order and end
points) to give him something to think about. However I think
"challenge the ingenuity of the most perspicacious" implies
impossibility or the need for non-standard code.
Yes, I implied impossibility, and I stand by that. You can't use loops
without using loops, which is what he asked. A recursive call is not a loop
per se. Nevertheless, I agree that it is probably what his tutor had in
mind.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
CBFalconer wrote:
Richard Heathfield wrote:
>>CBFalconer said:
>>>You forgot about recursion:
No, I didn't. I was saving that in case he turned out to be serious, and to provide some effort of his own.
Well, I kept the example subtly obtuse (the output order and end
points) to give him something to think about. However I think
"challenge the ingenuity of the most perspicacious" implies
impossibility or the need for non-standard code.
The original problem statement, in full, was
¿? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
.... and neither CBF's nor RH's code meets the requirement to
"use loops." I offer the following as a possible solution:
#include <stdio.h>
int main(void) {
char buff[293], *p = buff;
int n;
for (n = 1; n <= 100; ++n) {
sprintf(p, "%d\n", n);
while (*p)
++p;
}
fputs (buff, stdout);
return 0;
}
This program
- Uses loops (two of them; it could have been simpler were
"loops" not in the plural)
- "and"
- Prints 1 to 100 without using any kind of looping (the
output is generated by one execution of an fputs() call).
However, even this doesn't answer the question. It doesn't matter
if I or CBF or RH can produce a solution; the question asks whether
the former Secretary General can do it. Anybody know how to get
in touch with him?
--
Eric Sosman es*****@acm-dot-org.invalid
Eric Sosman said:
<snip>
>
The original problem statement, in full, was
¿? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
... and neither CBF's nor RH's code meets the requirement to
"use loops."
....and yours doesn't meet the requirement *not* to use "any kind of
looping".
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Heathfield wrote:
Eric Sosman said:
<snip>
The original problem statement, in full, was
¿? You have to use loops and print 1 to 100 without using any kind of
looping not even GOTO statement? Can u do it?
... and neither CBF's nor RH's code meets the requirement to
"use loops."
...and yours doesn't meet the requirement *not* to use "any kind of
looping".
There is no such requirement. There is a requirement to print 1 to 100
without using any kind of looping. Eric Sosman's code uses a loop, but
not for the actual printing. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Markus Breuer |
last post by:
I have a question about oracle commit and transactions. Following scenario:
Process A performs a single sql-INSERT into a table and commits the
transaction. Then he informs process B (ipc) to read the new date. So
process B starts "select ..." but does not get the previously inserted
row. The timespan between commit and select is very short.
(NOTE: two different sessions are used)
Questions:
1.) Does commit when returning from call...
|
by: Scott Robert Ladd |
last post by:
I've posted my revised C++ implementation of the Mersenne Twister at:
http://www.coyotegulch.com/libcoyote/TwistedRoad/TwistedRoad.html
This is "free-as-in-liberty" and "free-as-in-beer" code.
The Mersenne Twister is a "random number" generator invented by Makoto
Matsumoto and Takuji Nishimura; their website includes numerous
implementations of the algorithm.
|
by: Steven T. Hatton |
last post by:
I know of a least one person who believes std::ifstream::read() and
std::ofstream::write() are "mistakes". They seem to do the job I want
done. What's wrong with them. This is the code I currently have as a test
for using std::ifstream::read(). Is there anything wrong with the way I'm
getting the file?
#include <vector>
#include <iomanip>
#include <fstream>
#include <iostream>
|
by: BBM |
last post by:
I have an object that has a fairly complex construction sequence, so I have
written a dedicated "factory" class that invokes the constructor of my object
class (which does nothing but instantiate the object and set default
blank/null values), and then does all the Db access and number crunching to
populate the new object. The factory returns the fully populated object to
the caller. All the fields in the object are private, but have...
|
by: Martin Ho |
last post by:
Hi Everyone,
I have this code of Mersenne twister, which produces the random
numbers, one of the fastest codes as far as I know to produce random
numbers.
Anyways, it's writen in c# and I need to translate it to vb.net.
I tried some translators and I can't get it to work.
Could someone help me?
This is the code:
| |
by: Jose Reckoner |
last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script
to convert .DT1 and .DEM data to ASCII or some other format? I don't
need a viewer.
Thanks!
|
by: Simon |
last post by:
I have a quick question on the Mersenne Twister (hereinafter MT)
I'm using the standard C code downloaded from the MT website
(http://tinyurl.com/6d8t3). It's being used for a game to generate
random levels, monsters, items and so on, and I want the game to be
different each time I play it.
The standard MT code gives me the same string of random numbers each
time I run it. This is not surprising - computers are deterministic
and it...
|
by: Spiros Bousbouras |
last post by:
Do you have an example of an implementation where
sizeof(short int) does not divide sizeof(int) or
sizeof(int) does not divide sizeof(long int) or
sizeof(long int) does not divide sizeof(long long int) ?
Same question for the corresponding unsigned types.
|
by: bearophileHUGS |
last post by:
This may be interesting for Python developers of the random module,
"SIMD-oriented Fast Mersenne Twister (SFMT): twice faster than
Mersenne Twister":
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
One function may be useful to generate integers (randint, randrange,
choice, shuffle, etc), the other for floating point values (random)
faster than the current Mersenne Twister used in the random module.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |