Skip to content

Instantly share code, notes, and snippets.

@z123
z123 / problems.py
Created September 30, 2022 16:59 — forked from agrison/problems.py
Five programming problems every Software Engineer should be able to solve in less than 1 hour... in Python
# This is a solution to a blog post I just found at https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
# I wrote it in Python because it shines for such challenges.
# It took me approximately 35 minutes (edit: added 5 minutes because of a bug in problem #4), so if I trust the internet, I'm definitely a Software Engineer.
# How cool is that? :-)
# Problem 1
# ---------
# Write three functions that compute the sum of the numbers in a given list
# using a for-loop, a while-loop, and recursion.
def problem1_1(l):
" My Configs
syntax on " Syntax highlighting
set nowrap " Do not wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)