[Halloween]What is your serial killer name?

Pages: 123
BHXspecter wrote:
Me: Uptown Killer
Wife: Swamp Killer
Son: Uptown Killer


i am definitely tired. The first thought i had when i saw that was "wow, their last name all ended with the same letter; what a coincidence"

My name is "Boxcar flayer" which is rather disappointing.

if you the results, it ends up being "Igloo smotherer" which sounds amazing though
@Chirsname

Your code does not compile in mingw 4.7 Worked on IDEONE though.


edit: scratch that, was looking at the wrong window. It's 9 in the morning, give me a break :P
Last edited on
closed account (N36fSL3A)
Wait wait wait, why are you not passing strings by reference?

Oh, that makes me cringe at that thought.
I'll just leave this here...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//This work is public domain, authored by Albatross (Amaya S).
#include <iostream>
#include <string>
#include <cctype>
#include <array>

int main() {
    const std::array<std::string, 26> firstname = { "Back Alley", "Railroad",
        "Uptown", "Bay Harbor", "Circus", "Carpool", "Meat Locker", "Flophouse",
        "Igloo", "Boxcar", "Outback", "Watchtower", "Playground", "Conservatory",
        "Delicatessen", "Beach House", "Backstage", "Ice Truck", "Garage Sale",
        "Box Factory", "Hangar", "Swamp", "Nursery", "Strip Mall", "Octagon",
        "Kitchen" };
    
    const std::array<std::string, 26> lastname = { "Strangler", "Tickler", "Slicer",
        "Slasher", "Stabber", "Hacker", "Smasher", "Mangler", "Flayer",
        "Smotherer", "Skinner", "Pickler", "Chomper", "Butcher", "Peeler",
        "Disemboweler", "Cutter", "Killer", "Asphyxiator", "Chef", "Diner",
        "Monster", "Boiler", "Pounder", "Collector", "Keeper" };
    
    bool nospaceflag, onenameflag;
    char firstlet, lastlet;
    std::string naem = "";
    std::cout << "What is your full name, without titles or suffixes?" << std::endl;
    do {
        nospaceflag = true;
        onenameflag = true;
        firstlet = '\0';
        
        std::getline(std::cin, naem);
        for(char it : naem) {
            if(std::isalpha(it)) {
                lastlet = std::tolower(it);
                if(firstlet == '\0')
                    firstlet = std::tolower(it);
                if(!nospaceflag && onenameflag)
                    onenameflag = false;
            }
            else if(it == ' ' || it == '\t') {
                if(firstlet != '\0')
                    nospaceflag = false;
            }
        }
        if(firstlet == '\0') {
            std::cout << "Please enter your full name." << std::endl;
            continue;
        }
        if(onenameflag)
            std::cout << "No, no, no. What's your FULL name?" << std::endl;
    } while(onenameflag);
    
    std::cout << "No it's not.\n" << "Your real name is "
    << firstname[firstlet - 'a'] << " " << lastname[lastlet - 'a'] << ".\n"
    << "We are watching your every move.\n"
    << "Did you think we didn't know?" << std::endl;
	
    return 0;
}

What is your name, without titles or suffixes?
Chrisname
No, no, no. What's your FULL name?
    Chrisname
No, no, no. What's your FULL name?
     Chrisname    ~
No, no, no. What's your FULL name?
Chris-name
No, no, no. What's your FULL name?
...Chrisname.
No, no, no. What's your FULL name?
   Chris Name   .
No it's not.
Your real name is Uptown Stabber.
We are watching your every move.
Did you think we didn't know?


EDIT1: Added example output to show that chrisname dun goofed.
EDIT2: Added a simple check for whether or not the user entered anything with letters (the program would have worked fine before, but now it outputs a dedicated message).
EDIT3: Added todos.

TODO: Use regexes in a separate version.
TODO: Interpret commas as an indication that the first and last names have been reversed.

-Albatross
Last edited on
closed account (S6k9GNh0)
Well done. :)
@Lumpkin
... There is no benefit to passing by reference here and the application is so small it isn't needed as passing a copy won't effect the execution of the program enough to justify worrying of reference or copy.
closed account (S6k9GNh0)
... actually, strings are heavy to pass (or really, anything larger than pointer size), so it is more efficient to pass by reference here.
Also, the string should probably be passed as const given the nature of the function.
closed account (Dy7SLyTq)
@albatross: do you care if i "steal" that for what was going to be my halloween suite? although i would edit it to take command line arguments (to keep with the seen but not heard linux paradigm)
@DTSCode
Go right ahead. It's public domain (although attribution would be nice).

-Albatross
closed account (Dy7SLyTq)
Go right ahead. It's public domain (although attribution would be nice).

of course! youll go down as one of the authors
@Albatross
I used the T from my real last name.
closed account (Dy7SLyTq)
so not that there is anything wrong with albatrosses i like the seen but not heard paradigm and have adapted the above code as such. its not done yet (im going to put in some more cmd arg options and some better checking those args

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
    Source Name      : SerialKillerName.cpp
    Compiled with    : the Gnu Compiler Package (GCC)
    Compiler Build   : 4.8.1 on Linux
    Command          : $g++ -std=c++11 SerialKillerName.cpp -o skn
    Author(s)        : Albatross (Amaya S)
                       DTSCode
    Program Version  : 2.2
    Bio              : Meant to generate your Serial Killer Name
    Special Thanks To: BHXSpecter for writing the original code
                       Albatross for gratiously letting me steal
                           her version
*/

#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cctype>

using std::   cout;
using std::   cerr;
using std::   endl;
using std::    cin;
using std:: string;
using std::getline;
using std::  array;
using std:: vector;
using std::isalpha;
using std::tolower;

int main(int argc, char *argv[])
{
    vector<string> Arguments(argv + 1, argv + argc);
    const array<string, 26> FirstName = {
                                                "Back Alley" , "Railroad"   , "Uptown"    , "Bay Harbor"  , "Circus"      ,
                                                "Carpool"    , "Meat Locker", "Flophouse" ,  "Igloo"      , "Boxcar"      ,
                                                "Outback"    , "Watchtower" , "Playground", "Conservatory", "Delicatessen",
                                                "Beach House", "Backstage"  , "Ice Truck" , "Garage Sale" , "Box Factory" ,
                                                "Hangar"     , "Swamp"      , "Nursery"   , "Strip Mall"  , "Octagon"     ,
                                                "Kitchen"
                                        };
    
    const array<string, 26> LastName = {
                                            "Strangler"   , "Tickler", "Slicer" , "Slasher"    , "Stabber"  ,
                                            "Hacker"      , "Smasher", "Mangler", "Flayer"     , "Smotherer",
                                            "Skinner"     , "Pickler", "Chomper", "Butcher"    , "Peeler"   ,
                                            "Disemboweler", "Cutter" , "Killer" , "Asphyxiator", "Chef"     , 
                                            "Diner"       , "Monster", "Boiler" , "Pounder"    , "Collector", 
                                            "Keeper"
                                       };    
    bool   NoSpace     = true,
           OneName     = true;
    char   FirstLetter = '\0',
           LastLetter;
    string Name;

    for(string Current : Arguments)
        Name += Current + " ";

    for(char Counter : Name)
    {
        if(isalpha(Counter))
        {
            LastLetter = tolower(Counter);

            if(FirstLetter == '\0') FirstLetter = tolower(Counter);
            if(!NoSpace && OneName) OneName     = false;
        }

        else if(Counter == ' ' || Counter == '\t') if(FirstLetter != '\0') NoSpace = false;
    }

    if(FirstLetter == '\0' || OneName)
    {
        cerr<<"error: usage <first name> <last name>"<< endl;
        return -1;
    }
    
    cout<< FirstName[FirstLetter - 'a'] <<" "
        << LastName [LastLetter  - 'a'] << endl;

    return 0;
}
closed account (yADwAqkS)
Mine is Meat Locker Pickler.
closed account (S6k9GNh0)
Oh man DTS, those spaces... they kick me in the eyeballs.
closed account (Dy7SLyTq)
sorry :} its just my style
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
    Source Name      : SerialKillerName.cpp
    Compiled with    : the Gnu Compiler Package (GCC)
    Compiler Build  : 4.8.2 on Linux
    Command          : $g++ -std=c++11 SerialKillerName.cpp -o skn
    Author(s)        : Albatross (Amaya S)
                       DTSCode
                       Cheraphy (Alex E)
    Program Version  : 2.3
    Bio              : Meant to generate your Serial Killer Name
    Special Thanks To: BHXSpecter for writing the original code
                       Albatross for gratiously letting him steal
                           her version and Alex for adding regular expressions
*/
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cctype>
#include <regex>
using namespace std;

int main(int argc, char *argv[])
{
    vector<string> Arguments(argv + 1, argv + argc);
    const array<string, 26> FirstName = {
                                                "Back Alley" , "Railroad"   , "Uptown"    , "Bay Harbor"  , "Circus"      ,
                                                "Carpool"    , "Meat Locker", "Flophouse" ,  "Igloo"      , "Boxcar"      ,
                                                "Outback"    , "Watchtower" , "Playground", "Conservatory", "Delicatessen",
                                                "Beach House", "Backstage"  , "Ice Truck" , "Garage Sale" , "Box Factory" ,
                                                "Hangar"     , "Swamp"      , "Nursery"   , "Strip Mall"  , "Octagon"     ,
                                                "Kitchen"
                                        };
    
    const array<string, 26> LastName = {
                                            "Strangler"   , "Tickler", "Slicer" , "Slasher"    , "Stabber"  ,
                                            "Hacker"      , "Smasher", "Mangler", "Flayer"     , "Smotherer",
                                            "Skinner"     , "Pickler", "Chomper", "Butcher"    , "Peeler"   ,
                                            "Disemboweler", "Cutter" , "Killer" , "Asphyxiator", "Chef"     , 
                                            "Diner"       , "Monster", "Boiler" , "Pounder"    , "Collector", 
                                            "Keeper"
                                       };    
    string Name;

    for(string Current : Arguments)
        Name += Current + " ";
    regex rgx("(^[A-Z])*([a-z])*([A-Z])");
    smatch match;
    if(std::regex_search(Name,match,rgx, regex_constants::format_default)) {
	Name = FirstName[match[1] - 'A'] + LastName[match[2] - 'A'];
    } else {
        cerr<<"error: usage <first name> <last name>"<< endl;
        return -1;
    }
    
    cout << Name << endl;
    return 0;


can't test it as I don't have a compiler that supports regex installed, but I think that should work.

edit: Fixed some stuff
Last edited on
closed account (S6k9GNh0)
http://ideone.com/lJGSmv

And where's my credit, yo?? D:
closed account (Dy7SLyTq)
Its because you forgot #include <regex>
closed account (Dy7SLyTq)
What did you contribute computerquip? I'm on my phone and this site is being a pain so its difficult to see
closed account (Dy7SLyTq)
does anyone want to add
--version
--help
--about
--interactive (ie allows you to keep inputting name)
--random
Pages: 123