Skip to content

Instantly share code, notes, and snippets.

@minerscale
Created July 28, 2017 10:50
Show Gist options
  • Save minerscale/ab6e3009f0eb7feb94b891b8a72bcb36 to your computer and use it in GitHub Desktop.
Save minerscale/ab6e3009f0eb7feb94b891b8a72bcb36 to your computer and use it in GitHub Desktop.
Solution to a problem
def findVicinals(words):
word = words.lower()
VicinalLetters = []
for i in word:
test = (ord(i)+59)%26
for j in word:
othertest = (ord(j)+59)%26
if ((test + 1)%26 == othertest or (test - 1)%26 == othertest):
VicinalLetters.append(test)
break
if (len(VicinalLetters) == len(word)):
return (1)
elif (len(VicinalLetters) == 0):
return (2)
else:
return (0)
while (True):
string = input ("Line: ")
if (string == ""):
break
wordlist = string.split()
vicinals = []
nonVicinals = []
for word in wordlist:
isVicinal = findVicinals(word)
if (isVicinal == 1):
vicinals.append(word)
elif (isVicinal == 2):
nonVicinals.append(word)
if (vicinals != []):
print ("Vicinals:",end="")
for word in vicinals:
print (" " + word,end = "")
print ("")
if (nonVicinals != []):
print ("Non-vicinals:",end="")
for word in nonVicinals:
print (" " + word,end = "")
print ("")
@PickledCow
Copy link

PickledCow commented Jul 28, 2017

noOfDiv = int(input("Divisions: ")) # number of divisions
divBy = [] # The numbers to check if it is divisible
for i in range(noOfDiv):
  divBy.append(int(input("Divisible by: ")))

noOfBeats = int(input("Number of beats to print: ")) # How many beats there are

beat = 0

for i in range(noOfBeats):
  divCheck = 0
  memory = []
  beat += 1
  for j in range(len(divBy)):
    if beat % int(divBy[divCheck]) == 0:
      memory.append("X")
    else:
      memory.append(" ")
    divCheck += 1

  # spacing if the numbers are 1, 2, or 3 digits
  if noOfBeats >= 100: # 0-100+
    if beat >= 100:
      final = (str(beat) + ":" + "".join(memory))
    elif beat >= 10:
      final = (" " + str(beat) + ":" + "".join(memory))
    elif beat < 10:
      final = ("  " + str(beat) + ":" + "".join(memory))

  elif noOfBeats >= 10: # 0-99
    if beat < 10:
      final = (" " + str(beat) + ":" + "".join(memory))
    elif beat >= 10:
      final = (str(beat) + ":" + "".join(memory))

  elif beat < 10: # 0-9
    final = (str(beat) + ":" + "".join(memory))

  print(final.rstrip())

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