###Introduction

The [I Ching](https://en.wikipedia.org/wiki/I_Ching) (Yijing, or Book of Changes) is an ancient Chinese book of sixty-four hexagrams. 
A hexagram is a figure composed of six stacked horizontal lines, where each line is either Yang (an unbroken line) or Yin (a broken line):
```
---------    ---- ----    ---------    
---- ----    ---- ----    ---------    
---- ----    ---- ----    ---------    
---------    ---- ----    ---- ----    
---------    ---------    ---- ----    
---- ----    ---- ----    ---------    
```
The book is commonly used as an oracle. After asking it a question about one's present scenario,
each line is determined by random methods to be Yang or Yin. The resulting hexagram is then interpreted by the querent as a symbol of their current situation, and how it might unfold.

This kata will consult the I Ching using the three coin method.

###Instructions

A coin is flipped three times and lands heads
or tails. The three results are used to
determine a line as being either:
```
3 tails          ----x----  Yin (Moving Line*)
2 tails 1 heads  ---------  Yang
1 tails 2 heads  ---- ----  Yin 
3 heads          ----o----  Yang (Moving Line*)

*See bottom of description if curious.
```
This process is repeated six times to determine
each line of the hexagram. The results of these
operations are then stored in a 2D Array like so:
In each array the first index will always be the number of the line ('one' is the bottom line, and 'six' the top), and the other three values will be the results of the coin flips that belong to that line as heads ('h') and tails ('t').

Write a function that will take a 2D Array like the above as argument and return its hexagram as a string. Each line of the hexagram should begin on a new line.

should return:
```
---------
---------
----x----
----o----
---- ----
---- ----
```
You are welcome to consult your new oracle program with a question before pressing submit. You can compare your result [here](http://www.ichingfortune.com/hexagrams.php). The last test case is random and can be used for your query.

*[1] A Moving Line is a Yang line that will change
to Yin or vice versa. The hexagram made by the coin
throws represents the querent's current situation,
and the hexagram that results from changing its
moving lines represents their upcoming situation.*

Difficulty: EASY
Tags: Fundamentals

Sorting

Data structures

Game theory
Skill types: Sorting

Data structures

Starter code:
def oracle(arr):
	

Solutions:
l = {'one': 5, 'two': 4, 'three': 3, 'four': 2, 'five': 1, 'six': 0}
y = {'hhh': '----o----', 'hht': '---- ----', 'htt': '---------', 'ttt': '----x----'}

def oracle(arr):
	s = [''] * 6
	for x in arr:
		s[l[x[0]]] = y[''.join(sorted(x[1:]))]
	return '\n'.join(s)


ORDER = 'one two three four five six'.split()[::-1]
TBL = {'ttt': '----x----', 'htt': '---------', 'hht': '---- ----', 'hhh': '----o----'}

def oracle(arr):
	d = {n: TBL[''.join(sorted(rest))] for (n, *rest) in arr}
	return '\n'.join((d[o] for o in ORDER))


nums = ['six', 'five', 'four', 'three', 'two', 'one']
lines = {'hhh': '----o----', 'hht': '---- ----', 'htt': '---------', 'ttt': '----x----'}

def oracle(arr):
	return '\n'.join((lines[''.join(sorted(l[1:]))] for l in sorted(arr, key=lambda l: nums.index(l[0]))))


def oracle(arr):
	return '\n'.join(('----{}----'.format('x- o'[item.count('h')]) for item in sorted(arr, key=lambda x: 'six five four three two one'.index(x[0]))))


POS = {'one': 5, 'two': 4, 'three': 3, 'four': 2, 'five': 1, 'six': 0}
TYPE = {'ttt': 'x', 'htt': '-', 'hht': ' ', 'hhh': 'o'}
LINE = '----{}----'

def oracle(arr):
	lst = [0] * 6
	for params in arr:
		lst[POS[params[0]]] = LINE.format(TYPE[''.join(sorted(params[1:]))])
	return '\n'.join(lst)


ORDER = ('six', 'five', 'four', 'three', 'two', 'one')
YIN_YANG = {'hhh': '----o----', 'hht': '---- ----', 'htt': '---------', 'ttt': '----x----'}

def oracle(arr):
	return '\n'.join((YIN_YANG[''.join(sorted(a[1:]))] for a in sorted(arr, key=lambda b: ORDER.index(b[0]))))


def oracle(arr):
	lines = ['----x----', '---------', '---- ----', '----o----']
	data = {row[0]: row[1:].count('h') for row in arr}
	arr = [data[key] for key in ['six', 'five', 'four', 'three', 'two', 'one']]
	return '\n'.join((lines[count] for count in arr))


oracle = lambda a: '\n'.join(('----%s----' % 'x- o'[i.count('h')] for i in sorted(a, key=lambda x: -ord(x[0][2]))))


def oracle(arr):
	return '\n'.join((f"----{'x- o'[l.count('h')]}----" for l in sorted(arr, key=lambda l: 'xvuroe'.index(l[0][2]))))


d = {'one': 5, 'two': 4, 'three': 3, 'four': 2, 'five': 1, 'six': 0}
ok = {(2, 1): '---- ----', (1, 2): '---------', (3, 0): '----o----', (0, 3): '----x----'}
oracle = lambda a: '\n'.join([ok[i[1:].count('h'), i[1:].count('t')] for i in sorted(a, key=lambda x: d[x[0]])])