소스 검색

Done another

master
Lachlan Jacob 5 년 전
부모
커밋
0a554fe723
3개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 25
    0
      1304/main.py
  2. 1
    0
      1304/problem.txt
  3. 3
    0
      1304/run.sh

+ 25
- 0
1304/main.py 파일 보기

@@ -0,0 +1,25 @@
class Solution:
def sumZero(self, n):
# two cases: even and odd
result = []
count = 1
neg = True
# this ensure the odd case works
if n % 2 != 0:
result.append(0)
while len(result) != n:
if neg:
result.append(-count)
neg = False
else:
result.append(count)
count += 1
neg = True
return result

s = Solution()
print("Expected: 0")
print("Got:", str(sum(s.sumZero(32))))

+ 1
- 0
1304/problem.txt 파일 보기

@@ -0,0 +1 @@
Given an integer n, return any array containing n unique integers such that they add up to 0.

+ 3
- 0
1304/run.sh 파일 보기

@@ -0,0 +1,3 @@
#!/bin/bash

python3 main.py

Loading…
취소
저장