GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — data-structures/stack/waiter.py at main · ejaj/data-structures

Expand file tree

/

waiter.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
28 lines (26 loc) · 710 Bytes
/

waiter.py

Copy path

File metadata and controls

executable file
·
28 lines (26 loc) · 710 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def waiter(number, q):
primegen = [1] * 10000
prime = []
for i in range(2, 10000):
if primegen[i] == 1:
for j in range(i,10000,i):
primegen[j] = 0
prime.append(i)
a = [[] for i in range(q+1)]
b = [[] for i in range(q+1)]
a[0] = number
for i in range(q):
while a[i]:
plate = a[i].pop()
if plate%prime[i] == 0:
b[i+1].append(plate)
else:
a[i+1].append(plate)
result = []
for i in range(q+1):
while b[i]:
result.append(b[i].pop())
for i in range(q+1):
while a[i]:
result.append(a[i].pop())
return result
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.