Redacted! 5,


#1

my code isn't working!
have looked at other posts and mine is the same word for word!

puts "words to evaluate"
text = gets.chomp

puts "words to redact"
redact = gets.chomp

words = text.split(" ")

words.each do |word|
if word = redact
print "REDACTED"
else
print words + " "
end
end



#2

Perhaps considering what it does differently from what you want says something about which part of the code is responsible for this wrongness?


#3

it seems to do what it is meant too?


#4

So it's not wrong?

You just said.. I'm confused.


#5

it wont let me pass this section still, it says it is wrong but it wont say where, and as far as i can see it prints what it should. so maybe i am not clear on this bit? what it should print


#6

Does it just say "wrong" or does it say in what way it's wrong?
It can't possibly say where, but it can say what behaviour wasn't correct and you can use that to figure out where it is by considering where in the code you wrote that behaviour


#7

Let's run it then. If it's mysteriously not passing, then testing it a bit seems like the sensible thing to do next.

words to evaluate
hello there bob how are you bob
words to redact
bob
REDACTEDREDACTEDREDACTEDREDACTEDREDACTEDREDACTEDREDACTED

The word to redact was bob and there are two bobs, so REDACTED should be used twice in the places where bob was, while leaving the rest of the text intact. That's not quite what happened though, so that's probably why it won't let you pass.


#8

ah yes thank you. i will see if i can change that


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.