A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Programming Challenge #2 - Level: ReallyEasy!

1.7k views · started by 323 ·
#1
Programming Challenge #2 - Level: ReallyEasy!
Programming Challenge #2
Level: Really Easy!

Challenge: Create a program that asks the user for their name, and once they enter it, says "Hello, [personsname]" with the name that the person entered being where [personsname] is.

Every person who submits a program will win, the reward is 30LGG. If you make your program do any special other little things, you'll get some bonus LGG!

This contest has an unlimited amount of winners, and is open to anyone! If you're just learning programming, you can start with Challenge #1, and progress through them from there, as you'll learn programming as you go! :)

Enjoy!

Some helpful links:

How To Take User Input in C++
How To Take User Input in Java
How To Take User Input in Python
How To Take User Input in VB.NET
How To Take User Input in PHP

Current Winners List:

1.) The Unintelligible
2.) C0FFINCASE
3.) einstein95
4.) Isonyx
5.) Smithno13
6.)
7.)
8.)
9.)
10.)
11.)
12.)
13.)
14.)
15.)

Past Challenges:

http://forum.logicalgamers.com/programming/49237-programming-contest-1-level-supereasy.html
[/personsname][/personsname]
#2
$lolz = InputBox("", "Enter your name, gewd sir.")
$lolz &= '.' ; Concatenate period to complete sentence
ConsoleWrite("Hello, " & $lolz & @CRLF)


autoit this time.
#3
$lolz = InputBox("", "Enter your name, gewd sir.")
$lolz &= '.' ; Concatenate period to complete sentence
ConsoleWrite("Hello, " & $lolz & @CRLF)


autoit this time.


Nice, good job. I was about to go "Where the hell do I remember "@CRLF" from?" and then I saw your little thing at the bottom saying it was from AutoIt. It's a great scripting language, really useful.
#4
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {

string input = "";

cout << "Please enter your name:\n";
getline(cin, input);
cout << "Hello, " << input << endl << endl;

return 0;
}
#5
CRLF is control feed. It's common in any major programming language. Just in AutoIt it's "@CRLF" rather than \n.

Typically known as the newline sequence. But yeah. AutoIt is alright.
#6
C0FFINCASE wrote:
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {

string input = "";

cout << "Please enter your name:\n";
getline(cin, input);
cout << "Hello, " << input << endl << endl;

return 0;
}


Once again, sir, ur cool.
#7
Once again, sir, ur cool.


Not sure if sarcasm or genuine compliment.
I only know C++ and use logic to navigate other languages when I have to. I also haven't done shit with code in years now so I imagine a few contests in I won't be able to continue on.
#8
C0FFINCASE wrote:
Not sure if sarcasm or genuine compliment.
I only know C++ and use logic to navigate other languages when I have to. I also haven't done shit with code in years now so I imagine a few contests in I won't be able to continue on.


Eh. I've noticed that you've been using C++ so I decided to sarcastically say you were cool. Though not really in a negative way.
#9
name = raw_input("What's your name, you foolish fool wearing the foolishly foolish clothes?\n")
print("Hello, "+name)
if name == "Franziska von Karma":
print("Pheonix Wright, FTW!")


Phoenix Wright + Python
#10
Eh. I've noticed that you've been using C++ so I decided to sarcastically say you were cool. Though not really in a negative way.


I didn't pick up on it as negative. I was only unsure because you said it a second time.
#11

import java.util.Scanner;

public class Input {
public static void main(String[] args) {
String name;
Scanner receive = new Scanner(System.in);

System.out.println("What is your name? ");
name = receive.next();

System.out.println("Hello, " + name);

//Added Functionality
System.out.println("Also, Flareboy is a fag.");
}
}


Since no Java yet.
#12
	
<script type="text/javascript">
while((name = prompt('What is your name?')).length == 0){}
alert('Hello, ' + name);
</script>
#13
So, in the process of completing the first challenge, I got inspiration and started doing random crazy shit... I submitted it to the other thread, but this seems to be more applied here...

Just modified it to include the location question.

Python 3.1
import random
output = open('out.txt', 'w')
id = str(random.randint(100000, 999999))
unit = str(random.randint(1, 13))
name = input('What is your name? ')
print('Why hello there ' + name + '.')
loc = input('What is your location? ')
print('Deploying Unit#' + unit + ' to ' + loc + '. Please wait where you are for retrieval.')
print('You are no longer ' + name + '. You will now be known as Prisoner#' + id + '.')
answer = input('Do you accept? Type Yes or No ')
if 'yes' in answer.lower():
print('Enjoy your stay!')
x = 'compliant'
else:
print('Prisoner#' + id + ' is noncompliant. Beginning execution sequence.')
x = 'non-compliant. Prisoner #' + id + ' executed'
output.write('Subject is ' + name + ' of ' + loc + '\n' + 'Subject will now be known as Prisoner#' + id + '\n' + 'Subject is ' + x)
output.close()
#14
Smithno13 wrote:
So, in the process of completing the first challenge, I got inspiration and started doing random crazy shit... I submitted it to the other thread, but this seems to be more applied here...

Python 3.1
import random
output = open('out.txt', 'w')
name = input('What is your name? ')
print('Why hello there ' + name + '.')
id = str(random.randint(100000, 999999))
print('You are no longer ' + name + '. You will now be known as Prisoner#' + id + '.')
answer = input('Do you accept? Type Yes or No ')
if 'yes' in answer.lower():
print('Enjoy your stay!')
x = 'compliant'
else:
print('Prisoner#' + id + ' is noncompliant. Beginning execution sequence.')
x = 'non-compliant. Prisoner #' + id + ' executed'
output.write('Subject is ' + name + '\n' + 'Subject will now be known as Prisoner#' + id + '\n' + 'Subject is ' + x)
output.close()


Flareboy wrote:
and once they enter it, says "Hello, [personsname]" [/personsname]


Cool code though. Interesting dialogue.
#15
Isonyx wrote:
Cool code though. Interesting dialogue.


print('Why hello there ' + name + '.')

Be gone with you
#16
Sweet, updated the winners list, and sent out the LGG!

Get ready for Challenge #3, coming your way soon!

Still open for anyone wanting to complete it :)
#17
print('Why hello there ' + name + '.')

Be gone with you


wat
#18
#Python 3.3 
response = input("What is your name?")
print("hello ", response)
#19
Isonyx wrote:
wat


His code completely fits the criteria of the challenge. Standard solution or not.
#20
His code completely fits the criteria of the challenge. Standard solution or not.


I may stand corrected.
How so?
#21
Isonyx wrote:
I may stand corrected.
How so?


Challenge: Create a program that asks the user for their name, and once they enter it, says "Hello, [personsname]" with the name that the person entered being where [personsname] is.[/personsname][/personsname]


Smithno13 wrote:

import random
output = open('out.txt', 'w')
id = str(random.randint(100000, 999999))
unit = str(random.randint(1, 13))
name = input('What is your name? ')
print('Why hello there ' + name + '.')

loc = input('What is your location? ')
print('Deploying Unit#' + unit + ' to ' + loc + '. Please wait where you are for retrieval.')
print('You are no longer ' + name + '. You will now be known as Prisoner#' + id + '.')
answer = input('Do you accept? Type Yes or No ')
if 'yes' in answer.lower():
print('Enjoy your stay!')
x = 'compliant'
else:
print('Prisoner#' + id + ' is noncompliant. Beginning execution sequence.')
x = 'non-compliant. Prisoner #' + id + ' executed'
output.write('Subject is ' + name + ' of ' + loc + '\n' + 'Subject will now be known as Prisoner#' + id + '\n' + 'Subject is ' + x)
output.close()


Lrn2read
#22
Lrn2read


I mean yeah, but technically it says the output should be "Hello, [personsname]" not "Why hello there ' + name + '.'"
It's pretty irrelevant and really I wasn't bringing it up as a serious concern or anything but for the sake of argument I don't think by technicality it fits the criteria of the challenge.

Again, not that it matters. Like I said, was interesting the twist he put on it.[/personsname]
#23
Isonyx wrote:
I mean yeah, but technically it says the output should be "Hello, [personsname]" not "Why hello there ' + name + '.'"
It's pretty irrelevant and really I wasn't bringing it up as a serious concern or anything but for the sake of argument I don't think by technicality it fits the criteria of the challenge.

Again, not that it matters. Like I said, was interesting the twist he put on it.[/personsname]


Except his program has the same denotation as the challenge criteria. It doesn't matter how you say hello, as long as you're greeting the user based on their input. Like saying "hi" in Spanish or English.

I think it's a serious concern for you when you feel the need to bring up needless technicalities that are tangent to the actual challenge. Things can be done in a multitude of ways. His was done a little differently. Uniquely.
#24
Except his program has the same denotation as the challenge criteria. It doesn't matter how you say hello, as long as you're greeting the user based on their input. Like saying "hi" in Spanish or English.

I think it's a serious concern for you when you feel the need to bring up needless technicalities that are tangent to the actual challenge. Things can be done in a multitude of ways. His was done a little differently. Uniquely.

I has the same denotation, yes, which is why I didn't give an explanation or any really specific criticism.
It was done uniquely, which is why I complemented it.

Calm yourself.
#25
Isonyx wrote:

Calm yourself.


I'm poised. You should take your own advice, Jack.
#26
I'm poised. You should take your own advice, Jack.


you sound so ridiculous lol
#27
Isonyx wrote:
you sound so ridiculous lol


>sound
>"ridiculous"
>your signature
>you in this thread

demystify where you messed up in saying that
#28
>sound
>"ridiculous"
>your signature
>you in this thread

demystify where you messed up in saying that


I'm not going to start debating semantics with you.
It'd be one thing if I had started criticizing him for it.
I didn't. I complemented his code. The fact that you're taking this so far is ridiculous.
#29
Isonyx wrote:
I'm not going to start debating semantics with you.
It'd be one thing if I had started criticizing him for it.
I didn't. I complemented his code. The fact that you're taking this so far is ridiculous.


lol not even semantics. it's actually just cryptic insults.

All I was doing was amending your original statement because like I said the code is technically correct. Not even taking it far. It was basically over after you had further clarified yourself. Saw "calm yourself" and decided to poke fun at that considering I was never worked up at all in this thread.

I assume you got defensive and decided to draw this out by saying "you sound ridiculous."

But if you really look at the situation, you're the one taking it far. Not me.

As far as I'm concerned I don't care about this whole debacle. So yeah.
#30
lol not even semantics. it's actually just cryptic insults.

All I was doing was amending your original statement because like I said the code is technically correct. Not even taking it far. It was basically over after you had further clarified yourself. Saw "calm yourself" and decided to poke fun at that considering I was never worked up at all in this thread.

I assume you got defensive and decided to draw this out by saying "you sound ridiculous."

But if you really look at the situation, you're the one taking it far. Not me.

As far as I'm concerned I don't care about this whole debacle. So yeah.


Lol okay
#32
lol not even semantics. it's actually just cryptic insults.

All I was doing was amending your original statement because like I said the code is technically correct. Not even taking it far. It was basically over after you had further clarified yourself. Saw "calm yourself" and decided to poke fun at that considering I was never worked up at all in this thread.

I assume you got defensive and decided to draw this out by saying "you sound ridiculous."

But if you really look at the situation, you're the one taking it far. Not me.

As far as I'm concerned I don't care about this whole debacle. So yeah.


"technically correct" ... are you missing the point?

Create a program that asks the user for their name, and once they enter it, says "Hello, [personsname]" with the name that the person entered being where [personsname] is.[/personsname][/personsname]


NO where in his code does it say Hello, [personsname]
So the code is technically incorrect as it does not follow the assigned challenge.[/personsname]
#33
Zachafer wrote:
"technically correct" ... are you missing the point?



NO where in his code does it say Hello, [personsname]
So the code is technically incorrect as it does not follow the assigned challenge.[/personsname]


The point here was made pretty clear. It does technically qualify. It doesn't matter about the manner in which he completed the challenge in. He did it in his own unique way. All criterions were satisfied. Flare awards extraneous elements.

There is nothing wrong in alternating in a non-serious challenge. Saying otherwise is just being really pedantic. I don't know how this is so hard for you to understand.

name = input('What is your name? ')
print('Why hello there ' + name + '.')


He literally has to change this one key part, to this:

name = input('What is your name? ')
print('Hello, ' + name + '.')


I rest my case here.
#34
HEY GUYS NEW RULE FROM NOW ON AS LONG AS IT GENERALLY FITS THE CRITERIA I'LL ACCEPT IT.

I really don't give a shit if it says Hello or Hi or Hola or whatever the hell you want to write, as long as it's generally it.
#35
HEY GUYS NEW RULE FROM NOW ON AS LONG AS IT GENERALLY FITS THE CRITERIA I'LL ACCEPT IT.

I really don't give a shit if it says Hello or Hi or Hola or whatever the hell you want to write, as long as it's generally it.


It's funny because the solution he submitted qualified much more broadly than just "generally." It's not a general solution, it pretty much had every necessary facet. People are just griping for no reason being overly technical and whatnot.

Thanks for clarifying though.
#36
I'm proud, my drunken code has inspired pages of argument.
Thanks for defending me, I guess?
#37
When we going to see another challenge?
#38
<?php
$name = $argv[1];
echo 'Hello, ' . $name . ".";
?>[/1]


Or you can do it with an HTML form.

1st file:
<html>
<body>

<form action="php.php" method="post">
Name: <input type="text" name="personsname">
<input type="submit">
</form>

</body>
</html>


2nd file:
<html>
<body>

Hello, <?php echo $_POST["personsname"]; ?>!

</body>
</html>