GET OVER HERE HUMAN
WRITE A FUNCTION IN THE LANGUAGE OF YOUR CHOICE THAT TAKES A STRING AS INPUT, DOUBLES EVERY CONSONANT AND PLACES AN 'O' IN BETWEEN.
FOR EXAMPLE, 'I'M A GIANT FAGGOT' SHOULD RETURN 'I'MOM A GOGIANONTOT FOFAGOGGOGTOT".
TICK TOCK, BIRD DOESN'T LIKE WAITING.
PUMP A RUM
def foo(string):
result = ""
for letter in string:
if letter != " ":
result += letter
result += "O"
result += letter
else:
result += letter
return result
PICKLE PEE
WHAT ARE REGULAR EXPRESSIONS.
STOP POSTING TRIVIAL EXERCISES. WHAT IS THIS, HIGHSCHOOL COMPUTER LAB?
FUCK OFF.
>>55457820
THEN DO IT
>>55457640<?php
$consonants=str_split("bcdfghjklmnpqrstvwxyz");
function iunno($input) {
global $consonants;
$ret="";
foreach(str_split($input) as $c) {
$ret.=$c;
if(in_array(strtolower($c), $consonants)) $ret.="O$c";
}
return $ret;
}
echo iunno("I'M A GIANT FAGGOT\n");
?>
>>55457876
HOW ABOUT YOU FIX YOUR OWN CODE FIRST.
who is birding who ?
>>55457969
DO YOU WANT TO BE HIRED, BIRD POSER
>>55458033
WHOM BOI
import string
vows="EeUuIiOoAa"
cons=filter(lambda x: x not in vows,string.letters)
def shit_tier_challenge_16271627812(txt):
return reduce(lambda x,y: x+y+"o"+y if y in cons else x+y, txt, "")
Could have been a nice one liner if I wasn't bored to write all the consonants myself or a two liner with import string if I wasn't disgusted from the idea of generating cons every time reduce looped through
>>55458033
Yeah this one is stupid.
>>55458055
THIS IS FIZZBUZZ LEVEL PROGRAMMING, NOBODY IS GOING TO HIRE YOU TO FIZZBUZZ.
FIGHT BIRDS, FIGHT
>>55458064
Will crash on special symbols
Here is my solution#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
vector <char>cons;
queue <char>res;
char symb[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'j',
'k', 'l', 'm', 'n', 'p', 'q', 'r', 's',
't', 'v', 'w', 'x', 'z'};
for (int i = 0 ; i < sizeof(symb)/sizeof(symb[0]); i++) {
cons.push_back(symb[i]);
cons.push_back(toupper(symb[i]));
}
string input;
getline(cin,input);
char ch[input.size()];
strcpy(ch, input.c_str());
for (int i = 0 ; i < input.size() ; i++) {
if (find(cons.begin(), cons.end(), ch[i]) != cons.end()) {
res.push(input[i]);
res.push('o');
res.push(input[i]);
} else {
res.push(input[i]);
}
}
while(res.size()) {
cout<<res.front();
res.pop();
}
return 0;
}
Just do your own homework.
p $*[0].chars.map{|c|/[bcdfghjklmnprstvwxyz]/i=~c ?c+'O'+c : c}.join
>fake knifebird poster
function doTheThing(){
var string = prompt("Enter a sentencef");
var result = [];
for(i=0; i<string.length; i++){
console.log(string[i]);
if(string[i]==='a' ||
string[i]==='e' ||
string[i]==='i' ||
string[i]==='o' ||
string[i]==='u' ||
string[i]===' ' ||
string[i]==='\''||
string[i]==='\,' ||
string[i]==='\.')
{
result.push(string[i]);
}
else{
result.push(string[i] + 'o' + string[i]);
}
}
alert(result.join(""));
}
I'm kinda new to JS so it probably isn't efficient. Feel free to tell me to kill myself but pls point out what I did wrong
>>55458205
maybe for an internship they might lel
>>55457640function fag(x) {
return x.split('').reduce((a,b)=>{return a+((b.match(/[aeiou' ]/i))?b:(b+(b==b.toUpperCase()?'O':'o')+b))})
}> fag("IM A GIGANTIC FAGGOT")
'IMOM A GOGIGOGANONTOTICOC FOFAGOGGOGOTOT'> fag("foo bar baz")
'foo bobaror bobazoz'
>>55457640
In Ruby it's a one liner:"I'M A GIANT FAGGOT".gsub(/[^AEIOU '.!?]/) {|i| i+'O'+i}
>>55458908
Doesn't handle lower case
function ayy(lmao) { return lmao.replace(/([aeiou])/ig, "$1O$1"); };
>>55458923"I'M A GIANT FAGGOT (and a nitpicker)".gsub(/[^AEIOUaeiou '.!?()]/) {|i| i+'O'+i}
>>55458945> ayy('foo bar')
'foOooOo baOar'
Good job fag
>>55458970
>puts an uppercase O between lowercase letters
>>55458908
>>55458970
Breaks on other non-consonants not in the regex.
public static string GShit(string input)
{
string output = "";
foreach (char c in input)
{
if
(
c.ToString().ToUpper() != "A" &&
c.ToString().ToUpper() != "E" &&
c.ToString().ToUpper() != "I" &&
c.ToString().ToUpper() != "O" &&
c.ToString().ToUpper() != "U" &&
char.IsLetter(c)
)
{
output += c;
output += 'O';
output += c;
}
else
{
output += c;
}
}
return output;
}
>>55458993
read the question again
>>55459019
what part of the question do you think i missed
>>55459019
He seems to have gotten it correct
>>55459045
you are actually right, i'm a faggot
>>55458986
>>55458991"that's what I call AUTISM.."
.gsub(/[bcdfghj-np-tv-z]/) {|i| i+'o'+i}
.gsub(/[BCDFGHJ-NP-TV-Z]/) {|i| i+'O'+i}
>>55457640
Nice homework.def insert_o(sentence):
''.join([w + 'o' + w if w not in 'aeiou' and w not in ' 1234567890\'' else w for w in x])
Also, as >>55457820 said, you should use regular expressions, if you don't want to check against a list of all consonants.
There's too many characters to avoid, and in my example I avoided only digits, space and '. To tell the truth, I only did this because I love list comprehensions.
>>55459205
Except 'x' should be 'sentence'. I done goofed when I copy/pasted the line from the terminal.
Basic map:while (<>) {
chomp;
@t = map {
!/[aeiou \W]/ ? $_."O".$_ : $_
} split //;
print join "", @t;
print "\n";
}
Monk:while(<>){chomp;@t=map{!/[aeiou\W]/?$_."O".$_:$_}split//;print join"",@t;print"\n"}
The "eval" uu guy:eval unpack u=>q{_=VAI;&4@*#P^*2!["B`@8VAO;7`["B`@0'0@/2!M87`@>PH@("`@(2];865I;W4@7%==+R`_("1?+B)/(BXDY7R`Z("1?"B`@?2!S<&QI="`O+SL*("!P<FEN="!J;VEN("(B+"!`=#L*("!P<FEN="`B7&XB.PI]}
I live in an other dimension:eval eval '"'.
('['^',').('`'|'(').('`'|')').('`'|',').('`'|'%').('{'^'[').'('.'<'.'>'.')'.('{'^'[').'\\'.'{'.('!'^
'+').('{'^'[').('{'^'[').('`'|'#').('`'|'(').('`'|'/').('`'|'-').('['^'+').';'.('!'^'+').('{'^'[').(
'{'^'[').'\\'.'@'.('['^'/').('{'^'[').'='.('{'^'[').('`'|'-').('`'|'!').('['^'+').('{'^'[').'\\'.'{'
.('!'^'+').('{'^'[').('{'^'[').('{'^'[').('{'^'[').'!'.'/'.'['.('`'|'!').('`'|'%').('`'|')').(('`')|
'/').('['^'.').('{'^'[').'\\'.'\\'.('{'^',').']'.'/'.('{'^'[').'?'.('{'^'[').'\\'.'$'.'_'."\.".'\\'.
'"'.('`'^'/').'\\'.'"'.'.'.'\\'.'$'.'_'.('{'^'[').':'.('{'^'[').'\\'.'$'.'_'.('!'^'+').('{'^('[')).(
'{'^'[').'\\'.'}'.('{'^'[').('['^'(').('['^'+').('`'|',').('`'|')').('['^'/').('{'^'[').'/'.'/'.';'.
('!'^'+').('{'^'[').('{'^'[').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').('`'|'*').
('`'|'/').('`'|')').('`'|'.').('{'^'[').'\\'.'"'.'\\'.'"'.','.('{'^'[').'\\'.'@'.('['^'/').';'.('!'^
'+').('{'^'[').('{'^'[').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'."\"".'\\'.
'\\'.('`'|'.').'\\'.'"'.';'.('!'^'+').'\\'.'}'.'"';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|('.');#;#
And yes, I tested it all.
<code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace just_do_it
{
class Program
{
static void Main(string[] args)
{
string doit;
Console.WriteLine("type something");
doit=Console.ReadLine();
doit=DoTheThing(doit);
Console.WriteLine(doit);
Console.ReadLine();
}
public static string DoTheThing(string Sentence)
{
string ReturnedString = "";
foreach(char letter in Sentence)
{
switch(letter)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
case 'y':
case 'Y':
ReturnedString = ReturnedString + 'O' + letter;
break;
default:
ReturnedString = ReturnedString + letter;
break;
}
}
return ReturnedString;
}
}
}
</code>
>>55457640function conO(str) {
var str = str.replace(/([bcdfghjklmnpqrstvwxyz])/ig, '$1O$1');
return str;
}
>>55459088
Now make it an actual function like it says in the OP
>>55459537
how u put code in a box like this
#ImARetard
>>55459716
Read the fucking sticky
>>55459329
I like the cut of your jib
static void Main(string[] args)
{
var input = Console.ReadLine();
Func<char, bool> isVowel = (char letter) => { return "aouieAOUIE".IndexOf(letter) != -1 ? true : false; };
for (int i = 0; i < input.Length; ++i)
{
if (char.IsLetter(input[i]) && !isVowel(input[i]))
{
input = input.Insert(i, input[i].ToString() + "O");
i += 2;
}
}
Console.WriteLine(input);
}
OP solve your homework yourself faggot
>>55458033
Here come dat boii
>>55457640static void ConsonantReplacementThingie()
{
string userInput = Console.ReadLine();
char[] vowels = new char[] { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y' };
List<char> uI = new List<char>();
foreach (char item in userInput){
uI.Add(item);
for (int i = 0; i < vowels.Length; i++){
if (item == vowels[i]){
uI.Add('o');
uI.Add(item);}}}
string output = "";
foreach (char item in uI)
output += item.ToString();
Console.WriteLine(output);
}
>>55459329
What's the boob code?
>>55459852
I think OP's problems are too small to be homework. Are you a dropout?
>>55457640
Late to the party again.#!/usr/bin/env perl
use strict;
use warnings;
my $o;
my $input = 'hello world';
for (split //, $input) {
$o .= $_ =~ /[bcdfghjklmnpqrstvwxyz]/i
? sprintf('%so%s', $_, $_)
: $_;
}
print "$o\n";
ONTO SOMETHING HERE
>>55457640
Half of these can't into special chars or lower caseconvert :: String -> String
convert = foldr go []
where
go :: Char -> String -> String
go c str
| c `elem` nonVowels = c : toO c : c : str
| otherwise = c : str
nonVowels :: String
nonVowels = filter (`notElem` "aAeEiIoOuU") (['b'..'z'] ++ ['B'..'Z'])
toO :: Char -> Char
toO c
| c `elem` ['B'..'Z'] = 'O'
| otherwise = 'o'
-- short
convert' :: String -> String
convert'=foldr(\c cs->if c`elem`nVs then c:toO c:c:cs else c:cs) []
where
nVs = filter(`notElem`"aAeEiIoOuU") (['b'..'z']++['B'..'Z'])
toO c = if c`elem`['B'..'Z'] then 'O' else 'o'
>>55457640
>Swedish people on the internet