-
-
Save trishume/4151426 to your computer and use it in GitHub Desktop.
Partial solution for q4 of latest DWITE in Turing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var costumes : flexible array 1..0 of string | |
% is the costume already in the costumes array | |
fcn taken(costume : string) : boolean | |
for i : 1..upper(costumes) | |
if costume = costumes(i) | |
result true | |
end if | |
end for | |
result false | |
end taken | |
var n : int | |
var any := false | |
get : file, n | |
for i : 1..n | |
var name, costume : string | |
get : file, name | |
get : file, costume | |
if taken(costume) then | |
any := true | |
put name .. | |
end if | |
new costumes, i % allocate new element | |
costumes(i) := costume | |
end for | |
if not any then | |
put "SPOOKY" | |
else | |
put "" | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment