Skip to content

Instantly share code, notes, and snippets.

@RickGriff
Created December 11, 2017 22:02
Show Gist options
  • Save RickGriff/d9a2eb01588ecfce7a661b1768f50097 to your computer and use it in GitHub Desktop.
Save RickGriff/d9a2eb01588ecfce7a661b1768f50097 to your computer and use it in GitHub Desktop.
Codewars Challenge 3 - Stringy Strings
#write me a function stringy that takes a size and returns a string of alternating '1s' and '0s'.
#the string should start with a 1.
#a string with size 6 should return :'101010'.
#with size 4 should return : '1010'.
#with size 12 should return : '101010101010'.
#The size will always be positive and will only use whole numbers.
#My Solution:
def stringy(size)
"10" * (size/2) + "1" * (size%2)
end
@CypherPaul
Copy link

def stringy(size)
return "10" * int(size/2) + "1" * int(size%2)

Just try

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