Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My first thought is below. However I'm not sure if this is a good problem to ask unless you want them to iterate on the solution and you mention you want to do in a functional way.

  def groupByOddThenEvens(someList):

	odds = []
	evens = []

	for x in someList:
	  print x
	  if x % 2 == 0:
	     # Even
	     evens.append(x)
	  else:
	     odds.append(x)

	odds.extend(evens)
	return odds


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: