Posts

Showing posts from March, 2015

interesting def

Interesting  ~

>>> i =5
>>>
>>> def f(arg=i):
print(arg)

>>> i =7
>>> f()

guess what number??

the result is 5


List Type

I think Python is very simple to learn
simple to understand
simple to code...

there are many advantage if I use this language.

Now I start to learn list

Make List:
squares = [1,2,3,4,5]

Add List:
squares.append(6)

Copy List:
sqaures[:]

Range List:
sqaures[0:2]

Clear List:
sqaures = []

Problem 84

Image
Before solving this problem
I thought lost of time. because. It request to me that I had to make monopoly rules and playing it to make statistic.
Anyway I made up~ never give up~!


What I learned from this problem is that statistics are very strong~!!!!!!




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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 1…

Project euler 81~ 83 : BFS(Breadth-First-Search)

Image
These questions were very easy to me~!

Because I studied graph algorithm very hard and posted on my blogger.

https://projecteuler.net/problem=83


# List #

1. BFS(Breadth-First-Search),
2. DFS(Depth-First-Search),
3. Prim algorithm,
4. Union Find algorithm,
5. Kruskal algorithm,
6. Topology algorithm,
7. dijkstra's algorithm



What I had to do was thinking about how to efficiently access good solution by past times.

I choosed BFS login with Queue and find all possible path.

condition
up case : if (sum[po.y - 1][po.x] > curSum + val[po.y - 1][po.x]) {
  sum[po.y - 1][po.x] = curSum + val[po.y - 1][po.x];
  queue.add(new Position(po.x, po.y - 1));
}

right down, left ...




[P (y=0 , x=0)]
[131, max, max, max, max]
[max, max, max, max, max]
[max, max, max, max, max]
[max, max, max, max, max]
[max, max, max, max, max]

[P (y=0 , x=1), P (y=1 , x=0)]
[131, 804, max, max, max]
[332, max, max, max, max]
[max, max, max, max, max]
[max, max, max, max, max]
[max, max, max, max, max]

[P (y=1 , x=0), …

Problem 80

Image
I solve this problem by using 57 problem, 64, 65
I think problem is getting harder than before and....
because of time and difficulty, It seem that I want to stop it.
but I wil do it continuously


I started Just Python

My first Language was Java
Second is javascript,
third is c
fourth is Python which I'm trying to learn ~!

Compare to java.
this is amazing and very simple

ex)
>>> 3 * 'abc' + 'de'
'abcabcabcde'

>>> word = 'Python'
>>> word[0:2]
'Py'

Very Very Interesting..

I will use it more and more