Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active March 27, 2024 17:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save TheMuellenator/a15238bb2a2ec48298d21dd5c9748fae to your computer and use it in GitHub Desktop.
Save TheMuellenator/a15238bb2a2ec48298d21dd5c9748fae to your computer and use it in GitHub Desktop.
iOS repl.it - Functions 1 Challenge Solution
print("Starting map")
start()
//4 steps right and 5 steps down.
right()
right()
right()
right()
down()
down()
down()
down()
down()
//Don't change the code below this line.
print("Final map")
visualise();
@Zizo0404
Copy link

In any way, when I call down() function by repeating or by using loops, still it doesn't, work . main.swift doesn't recognize
up() and down() function. Are there any ways to implement these functions differently ?

@Zoooooomy2
Copy link

I used this exact solution, but the fox didn't move at all.

@mtzfactory
Copy link

I used this exact solution, but the fox didn't move at all.

You need to fork the project to your own repl.it account...

@Zoooooomy2
Copy link

I used this exact solution, but the fox didn't move at all.

You need to fork the project to your own repl.it account...

Thanks for letting me know, very helpful :)

@phamthienbao
Copy link

print("Starting map")
start()

//Write your code here:

for _ in 0...3 {
right()
}
for _ in 0...4 {
down()
}

//Don't change the code below this line.

print("Final map")
visualise();

@vishalverma865
Copy link

var i = 0
while i <= 4 {
down()
i += 1

}
var p = 0
while p <= 3 {
right()
p += 1
}

@shailparas
Copy link

down()
right()
down()
right()
down()
right()
down()
right()
down()

@thisiskhan
Copy link

thisiskhan commented Apr 27, 2021

var i = 0
while i <= 4 {
down()
i += 1

}
var p = 0
while p <= 3 {
right()
p += 1
}

@JCammon1
Copy link

JCammon1 commented Jun 6, 2021

//Write your code here:
down()
down()
down()
down()
down()
right()
right()
right()
right()
print("Final map")
visualise();

I really don't understand where this code is supposed to go or what we are supposed to do. I see all the examples of solutions that people are giving, but still have no idea where it is supposed to go. I think this challenge needs more explanation.

@diansastro
Copy link

print("Starting map")
start()

//Write your code here:
for i in 0...3 {
right()
}

for i in 0...4 {
down()
}

//Don't change the code below this line.

print("Final map")
visualise();

@rufius97
Copy link

outerArray[0][0] = "⬜️"
outerArray[5][4] = "🦊"

Copy link

ghost commented Aug 15, 2021

print("Starting map")
start()
for _ in 0 ... 4 {
down()
}
for _ in 0 ... 3 {
right()
}

//Write your code here:

//Don't change the code below this line.

print("Final map")
visualise();
Screenshot 2021-08-15 at 10 24 25 AM

@chemazle
Copy link

I don't get this one? how to run?

@charlotte987654321
Copy link

Unable to actually type anything anywhere - is this supposed to be done in a playground? Or is there some way to actually be able to type into the boxes?

@PrettySolution
Copy link

PrettySolution commented Jan 9, 2022

for _ in (0 ... 4) {
down()
}

for _ in (0 ... 3) {
right()
}

@73307
Copy link

73307 commented Jan 22, 2022

print("Starting map")

start()
down()
down()
down()
down()
down()
right()
right()
right()
right()

//Write your code here:

@Imran-Khalid-code
Copy link

would this work ?

func moveFox(){
for i in 0...5{down()};for i in 0...4{right()}
}
moveFox()

@Magdalenaspace
Copy link

func foxMoves() {
for _ in 0...3 {
right() };
for _ in 0...4 {
down() }
}
foxMoves()

@Magdalenaspace
Copy link

func end() {
createWorld();
outerArray[0][0] = "⬜️"
outerArray[5][4] = "🦊"
}
end()

@ashwinirudresh
Copy link

func foxGetCorn()
{
for i in 0...3{
right()
}
for i in 0...4{
down()
}

}
foxGetCorn()

@tmel629
Copy link

tmel629 commented Feb 16, 2023

I could not write my code in at all, nice to know I would have gotten it right though. I guess?

@DaoBaHanh
Copy link

Could you please tell what the issue is and how to fix this?

Снимок экрана 2023-06-18 в 19 43 35

@seejuh
Copy link

seejuh commented Jul 17, 2023

I am getting the same issue as the previous poster. I keep getting an error. Any help would be appreciated as I am not sure what the problem is:

" swiftc -o main main.swift
main.swift:2:1: error: cannot find 'start' in scope
start()
^~~~~
main.swift:8:1: error: cannot find 'down' in scope
down()
^~~~
main.swift:9:1: error: cannot find 'down' in scope
down()
^~~~
main.swift:10:1: error: cannot find 'down' in scope
down()
^~~~
main.swift:11:1: error: cannot find 'down' in scope
down()
^~~~
main.swift:12:1: error: cannot find 'down' in scope
down()
^~~~
main.swift:13:1: error: cannot find 'right' in scope
right()
^~~~~
main.swift:14:1: error: cannot find 'right' in scope
right()
^~~~~
main.swift:15:1: error: cannot find 'right' in scope
right()
^~~~~
main.swift:16:1: error: cannot find 'right' in scope
right()
^~~~~
main.swift:18:1: error: cannot find 'visualise' in scope
visualise();
^~~~~~~~~
main.swift:57:1: error: cannot find 'visualise' in scope
visualise();
^~~~~~~~~
exit status 1"

@Shazanbegum
Copy link

I am having the same issue, its not allowing me type and the bellow shows up after every line.
 down()

down()
bash: syntax error near unexpected token `down'
 down()

@ZiZasaurus
Copy link

ZiZasaurus commented Jan 15, 2024

I figured out the issue. First, you need to fork the project, as mtzfactory mentioned. Secondly, you need to add the game.swift file to the end of the compile list in replit. See this SO post for specifics.

@zora-san
Copy link

Thanks, @ZiZasaurus! <3

@justinking22
Copy link

when using the function "right" the text shows blue in the field but when using "down" or "up" they show up black. I tried the challenge and my code result was identical to the solution but the results were errors. the errors were due to the "down" function not calling correctly. I went into the game.swift section and the coding there had different colors as well. I tried to change the code there to "Down" vs "down" to see if it would have any affect and it did not. I tried to test this further by calling on just the "right" function 3 times and it worked perfectly. the "up" and "down" functions did not work at all.

That's sooo
right

@ERaff83
Copy link

ERaff83 commented Jan 28, 2024

Screenshot 2024-01-28 at 7 32 11 pm
HELP Please

@abrahammella
Copy link

@ERaff83 Follow the instruction as ZiZasaurus's mention, it should work by adding compile = ["swiftc", "-o", "main", "main.swift", "game.swift"] on the hidden .replit config file.

Screen Shot 2024-02-05 at 12 49 45 PM

@abrahammella
Copy link

func moveTheFox(){
  for moves in 1...5{
    if moves != 5{
      right()
    }
    down()
  }
}

moveTheFox()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment