When you suggest a synonym a vote box shows up on that page, which implies that you vote on the synonym page, however if you navigate away and back it's not there because you need to go to the master page instead.
@Adám If the falsey output is allowed to be different for different input lists, then Pip, 3 bytes: MNg (gives nil instead of 0 when the list is empty). Otherwise, MNg|0
@Adám F#: let rec f=function|[b]->b|true::t->f t|_->false
Probably not optimally golfed, at all.
AKA: If the input list has one element, return that element. If the first element is true, check if the rest of the list is true recursively. Otherwise (empty list or first element is false), return false.
Could be a bit shorter if you substitute true/false for 1/0.
@Theo Python's comparison operators work just like they do in math: a > b > c means "a is greater than b, which is greater than c." So sum(l)==len(l)>0 means "sum of l is equal to length of l, which is greater than 0."
@Theo Nope. Python docs: "Unlike C, expressions like a < b < c have the interpretation that is conventional in mathematics... Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z"
You are fish in a pond that needs to survive by eating other fish. You can only eat fish that are the same size or smaller than yourself. You must create a program that takes a shoal of fish as an input string. From this you must work out how many fish you can eat and ultimately the size you will...
CMC (That might be moved to main): Write the longest program such that the program errors, however removing any continuous substring of the program causes it to run without errors.
@CatWizard ⎕ takes no args. By itself it returns an input line evaluated. ← is set a variable. ⎕← has no right arg for it, but by itself (←) it evaluates to the function of itself
@CatWizard It makes sense. The best way to make sure that deleting any character removes the error, is to make all the characters contribute to the same error.
CMC: What's the longest English word of length N, where you can make a chain of N English words where each word can be formed by removing one letter from the previous word?
For example, fine works because fine -> fin -> in -> I are all words, but the does not work because the -> he -> ?? has length 2 instead of 3
@DJMcMayhem Hm. Puzzling.SE has done stuff like this, but I think they allowed anagramming at each step. The max length was something like 18. Without anagrams, it'll be rather shorter, of course.
how about this slightly tricky question. Given two sets of integers X and Y of sizes m and n and m<n, find a bipartite matching (missing out n-m integers in Y of course) that minimizes the sum of the absolute differences of the pairs of integers. The tricky part is to make it run in O(m^2 + n) time
fineWords = {}
def isFine(word):
global fineWords
if not isWord(word):
return False
if len(word) == 1:
return True
return any((word[:i] + word[i+1:]) in fineWords for i in range(len(word)))
for word in sorted(wordList):
if isFine(word):
fineWords.add(word)
Trades time inefficiency for memory inefficiency :P
I was thinking it might be more efficient to work from the bottom up, considering that you can for example only start with i or a, then only go to an, at, as, ah etc.