Stack

Stack it :3

IN

add 1
add 3
add 3
add 7
pop
pop
add 9
pop
pop

OUT

7
3
9
3

IN

add 7
add 7
pop
pop
add 7
pop

OUT

7
7
7

IN

add 1
add 2
add 3
add 4
pop
pop
pop
pop

OUT

4
3
2
1
Login to submit solution


16 symbols pyth
Mon Sep 19 15:02:25 2016 Sait2000
VeM.z .xaYsN
.)Y
25 symbols perl
Sat Aug 13 00:44:41 2016 vakorol
#!/usr/bin/perl -p
$_=/ /?!push@a,$':pop@a
26 symbols perl
Mon Aug 8 18:55:35 2016 k-mx
#!/usr/bin/perl -nl
/ /?$a.=$':print chop$a
27 symbols perl
Sat Jul 30 22:33:03 2016 k-mx
#!/usr/bin/perl -nl
/\d/?$a.=$&:print chop$a
29 symbols perl
Mon Sep 29 20:23:52 2014 vakorol
#!/usr/bin/perl -nl
/\d/?push@a,$&:print pop@a
30 symbols ruby2.0
Sun Oct 5 19:23:11 2014 fl00r
#!/usr/bin/ruby2.0 -n
$_[4]?$:<<$_[4]:puts($:.pop)
30 symbols ruby2.0
Sun Oct 5 19:28:36 2014 fl00r
#!/usr/bin/ruby2.0 -n
$_[4]?$:<<$_[4,2]:$><<$:.pop
32 symbols ruby2.0
Sun Oct 5 19:07:27 2014 fl00r
#!/usr/bin/ruby2.0 -n
$_[4]?($:<<$_[4]):puts($:.pop)
32 symbols ruby2.0
Sun Oct 5 19:11:55 2014 fl00r
#!/usr/bin/ruby2.0 -n
$_[4]&&$:<<$_[4]||puts($:.pop)
32 symbols bash
Wed Jul 27 05:34:08 2016 hidefromkgb
sed '{s/.* //;G};/p/{g;P;D};h;d'
34 symbols perl
Fri Aug 8 21:44:14 2014 avkhozov
#!/usr/bin/perl -aln
$F[1]?push@s,$F[1]:print pop@s
34 symbols perl
Fri Sep 5 20:17:20 2014 sago35
#!/usr/bin/perl -p
!s/.* (..)//s?$_=pop@x:push@x,$1
37 symbols ruby2.0
Sun Oct 5 19:05:38 2014 fl00r
#!/usr/bin/ruby2.0 -p
$_[4]?($:<<$_[4,2];$_=''):$_=$:.pop
40 symbols ruby2.0
Sat Aug 9 20:08:06 2014 nooodl
$_[4]?($:<<$_[4]):puts($:.pop)while gets
45 symbols bash
Wed Jul 27 05:27:15 2016 hidefromkgb
sed '{s/add //;G};/p/{g;P;s/^[^\n]*\n//};h;d'
46 symbols bash
Wed Jul 27 05:18:21 2016 hidefromkgb
sed '/a/G;/p/{g;s/add //;P;s/^[^\n]*\n//};h;d'
47 symbols perl
Tue Sep 16 02:26:56 2014 maxymania
m'.* (.*)'?push@_,$1:print(pop(@_),"\n")while<>
75 symbols ruby
Mon Aug 15 18:56:43 2016 mhib
@a=[]
def self.method_missing n,*a
p @a.send n
rescue
@a+=a
end
eval gets p
83 symbols ruby2.0
Fri Aug 8 21:09:40 2014 Nakilon
@stack = []
def add x
  @stack.push x
end
def pop
  puts @stack.pop
end
eval gets p
86 symbols python2
Sat Aug 9 20:18:35 2014 nooodl
import os;s=[]
for i in os.read(0,99).split():
 s+=[i]*(i<'a')
 if i>'b':print s.pop()

View all solutions