---
# System prepended metadata

title: Untitled

---


class GoogleAnalytics {
    func sentEvent(key)
}

``` kotlin
interface EventService() {
    fun logEvent(name: String, properties: Map<String, String>? = null)
}

class GoogleAnalytics(
    val gaClient: GAClient,
) : EventService() {

    fun init() {
        initialize()
    }
    
    fun initialize() {
        // set uer id
        // set ....
    }

    fun logEvent(name: String, properties: Map<String, String>? = null) {
        gaClient.logEvnet(name, properties)
    }
}

class MixPanel(
    val client: mixPanelClient
) : EventService() {

    fun logEvent(name: String, properties: Map<String, String>? = null) {
        client.logEvnet(name, properties)
    }
}

class EvnetManager(
    val eventServies: List<EventService>()
) {
    fun logEvent(name: String, properties: Map<String, String>? = null) {
        eventServies.forEach {
            it.logEvent(name, properties)
        }
    }
}

class Application {
    fun init() {
        val eventPlanAManager = EventManager(
            list(
                GAClient(),            
            )
        )
        
        val eventPlanBManager = EventManager(
            list(            
                MixPanelClient(),
            )
        )
        
        val testingSession = getSession()
        
        val eventManager = when(session) {
            "A" -> 
            else ->
         }
        
    }
    
    fun getEventManager() {
        return when(session) {
            "A" -> eventPlanAManager
            else -> eventPlanBManager
         }
    }
}

class MainPage() {
    
    val eventManager = eventPlanAManager()
    
    init() {
        eventManager.logEvent("viewLoaded")
    }
    
}

class LoginPage() {
    
    val eventManager = eventPlanBManager()
    
    init() {
        eventManager.logEvent("viewLoaded")
    }
    
}


@Test
class SesstionEventManagerTest {

    val eventPlanAManager by mock<EventManger>()
    val eventPlanBManager by mock<EventManger>()
    val sessionManager by moch<SessionManager>()
    

    @Test
    fun `test session a use event manager plan a` {
        whenevent(sessionManager.getSession).thenReturn("A")
        val target = App.getEventManager()
        eventPlanAManager.logEvent("").assertInvoke()
        eventPlanBManager.logEvent("").assertNotInvoke()
    }
    
    @Test
    fun `test session b use event manager plan B` {
        whenevent(sessionManager.getSession).thenReturn("B")
        val target = App.getEventManager()
        eventPlanAManager.logEvent("").assertInvoke()
        eventPlanBManager.logEvent("").assertNotInvoke()
    }
    
    @Test
    fun `test main page log view loaded event` {
        val eventManager = mock<EventManager>
        val target = MainPage(
            eventManager
        )    
        
        target.init()
        
        eventManager.logEvent("viewLoaded").assertInvoke()
    }

}

```

```swift 
// ex. "aab" => "aba" yes
// ex. "abc" => "abc" no

// ABCCBADDEWR
// h
//   t


class Sol {
	func isPalidrome(String s) -> String? {
    
        var charCounted: [Character: Int] = getCharCounted(s)
        
        guard isCanArrangeToPalindrome(charCounted) else {
            return nil
        }
        
        return buildPalindrome(charCounted)
    
    
    
		// 1. Put all char to Map
		var table = [String: Int]()
		s.foreach {
            // table[$0, default: 0] += 1
        
			if let char = table[s] {
				table[s] += 1
			} else {
				table[s] = 1
			}
		}
        
        
        let oddChars = table.filter { $0.count % 2 == 1 }
        guard oddChars > 1 else {
            return nil
        }
        
    
		var oddCount = 0
		var oddChar = 0

		// 2 
		table.keys.foreach {
			if table[$0] % 2 != 0 { // odd
				oddCount += 1
				oddChar = $0
			} 
		}
        // aa, aba, 
		if oddCount > 1 && (s.length / 2) == 0 {
			return nil
		}

        // bbaaabb
        let centerString = oddChars.join()
        return table.fiter($0.count % 2 == 1).reduce(cneterString) { result, next in
            let count = next.element
            let char = next.key
            let appendStr = Array(repeating: char, count/2)
            return "\(appendStr)\(result)\(appendStr)"
        }
        
		// aaabaaa
		var head = ""
		var tail = ""

		table.keys.foreach {
			if let count = table[$0], count != 1 {
				for (var i = 0; i < count / 2; i++){
					head += $0
			   		tail += $0
				}
			}
		}

		return oddCount == 1 ? head + oddChar + tail : head + tail
	}
}
```