Skip to content

Instantly share code, notes, and snippets.

@Offirmo
Last active February 27, 2024 23:51
Show Gist options
  • Save Offirmo/a43ec13bedc4c3186b97b062da6ae2b1 to your computer and use it in GitHub Desktop.
Save Offirmo/a43ec13bedc4c3186b97b062da6ae2b1 to your computer and use it in GitHub Desktop.
[Python snippets for hacker rank] python
## starters
x = [ 1, 2, 3, 4, 5 , 6, 7 ]
print(f'{x} => {xyz(x)}')'
x = [ 1, 2, 3, 4, 5 , 6, 7 ]
print(f'{x} => {xyz(x, len(x))}')
x, y = 'foo', 2
print(f'{x},{y} => {xxxxx(x, y)}')
## debug
print(repr(arr))
print(f'{x} => {xyz(x)}')
## string manipulation
arr = list(map(int, '1 2 3 4 5'.strip().split()))
## lists
arr.sort()
create an empty list of size n: result = [0] * 100
unpacking *
## arr
x = [
[ 1, 2, 3],
[ 4, 5, 6],
[ 9, 8, 9],
]
## set
unpacking **
## binary manipulation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment