SRL Archive - General

Programming HW


Simtoon

2010-11-29 06:18:57

Question One

Australians like to pay out our New Zealand cousins for their funny accent. To Australians. the Kiwi pronunciation of the letter i sounds more like our pronunciation of the letter u. The typical example we use is that fish and chips spoken in a Kiwi accent often sounds like fush and chups.

Your program should read in what John is trying to say, and replace every i with a u, and print out the result. For example:

Enter sentence: Fish and chips please.

Fush and chups please.

Here is another example:

Enter sentence: I'd like to go for a swim.

U'd luke to go for a swum.


WTF HOW DO I DO THAT IN PESUDOCODE!! HELP!!

Capricorn

2010-11-29 06:20:49

If character = i then character = u

?

Simtoon

2010-11-29 06:22:47

My teacher said use an array..

Frement

2010-11-29 06:28:08

char_array = split(string);
foreach (char_array as char) do
if (char == i) then
replace(char, u)
end
end
string = NULL
foreach (char_array as char) do
string += char
end
print string

In PHP:
[PHP]$string = str_replace("i", "u", $string);
echo $string;[/PHP]

i luffs yeww

2010-11-29 06:30:20


#! /usr/bin/env python

import re

if __name__ == '__main__':
print re.sub('i', 'u', 'fish and chips please.')

Capricorn

2010-11-29 06:38:19

To be honest I do not know how close you can get to using Pesudocode with such a simple request… The real code is so quick and easy to write there really isn't a point to mocking up any code.

Simtoon

2010-11-29 06:40:30

I don't know this question is stupid.. i guess Frement gave me enough

Bad Boy JH

2010-12-06 19:46:04

I = 0
REPEAT
if String == i then
string = u
i = i + 1
until stringlength <= i

think of a string as an array of characters

i luffs yeww

2010-12-07 01:42:59

From: Bad Boy JH
I = 0
REPEAT
if String == i then
string = u
i = i + 1
until stringlength <= i

think of a string as an array of characters


A string is an array of chars.. :p

Bad Boy JH

2010-12-08 21:38:43

yes, I know. However most people don't see it that way, view 3 as a decimal, its still tecnically a decimal… sorta

sadmemories20

2011-03-15 02:41:47

I don't know this question is stupid.. i guess Frement gave me enough

Sex

2011-03-15 03:43:45

In what language? This is super simple though man. Omg. Haha.

Gu3st...

2011-03-15 11:09:26

Gravedug by a spam bot :/

Sex

2011-03-16 00:05:24

I can't believe I didn't realize that. So sorry..lmao.