# ある範囲の連続した数字で１の位が特定の数の場合は省いてみる

```#!/usr/bin/env python
# *-# -*- coding: utf-8 -*-

def f(s, e):
return "\n".join([str(i)
for i in range(s, e + 1)
if not str(i)[-1] in ["4","9"]])

print f(90,110)
```

```90
91
92
93
95
96
97
98
100
101
102
103
105
106
107
108
110```

もっとスマートな方法あった気がする？(´･ω･`)

#### 『下一桁は10で割った余り』

```>>> 99 % 10
9
>>> 101 % 10
1
>>> for i in range(100, 111):
...     print i % 10
...
0
1
2
3
4
5
6
7
8
9
0
```

んで

```def f(s, e):
return "\n".join([str(i) for i in range(s, e + 1)
if not i % 10 in [4, 9]])

print f(90,110)
```

こう？

#### map使った方が速いかもということで

```#!/usr/bin/env python
# *-# -*- coding: utf-8 -*-

import timeit

t1 = timeit.Timer(stmt="""
def f(s, e):
return [str(i) for i in range(s, e + 1) if not str(i)[-1] in ['4', '9']]
f(99, 1200)
""")
print t1.timeit(number = 1000)

t2 = timeit.Timer(stmt="""
def f(s, e):
return [str(i) for i in range(s, e + 1)  if not i % 10 in [4, 9]]
f(99, 1200)
""")
print t2.timeit(number = 1000)

t3 = timeit.Timer(stmt="""
def f(s, e):
return map(str, [i for i in range(s, e + 1)  if not i % 10 in [4, 9]])
f(99, 1200)
""")
print t3.timeit(number = 1000)
```

```4.62032008171
2.56785511971
2.16774392128```

mapのが速い
んで

```def f(s, e):
return "\n".join(map(str, [i for i in range(s, e + 1)
if not i % 10 in [4, 9]]))
```

こうかな？