The Way
아희 코드를 더 다채롭게 만드는 코드 본문
아희는 그 특성상 빈 공간이 꽤 많이 생기게 된다.
또한, 아직 완성도가 부족한 언어라서 종성의 경우 ㅁ, ㅂ, ㅅ, ㅆ를 제외하면 존재 의미가 없다.
빈 공간을 랜덤 한글로 채워주고, 불필요한 종성을 추가해주는 코드다.
박, 반, 밧 등은 모두 똑같은 역할을 하며, 망과 맣을 제외한 ㅁ 시리즈도 다 같은 역할이다.
코드를 작성하다보면 똑같은 글자가 많이 나오기 마련인데, (ex 빠빠빠) 다양한 글자가 섞여들어갈 수 있도록 만들어 코드를 더 다채롭고, 읽기 힘들게 만들어주는 python 코드를 작성해 보았다.
(전)
(후)
사실 다채롭다기보다는 난독화시키는 코드다.
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 | import random KOR_BASE = 0xAC00 jong = [[], [], [ 1 , 4 , 19 ], [ 7 , 22 , 24 ], [ 2 , 3 , 16 , 17 , 20 , 23 , 25 , 26 ], [ 5 , 6 , 8 ], [], [ 9 , 12 ], [], [ 10 , 11 , 13 , 14 ]] def first(i): i = ord (i) i - = KOR_BASE return i / / ( 21 * 28 ) def second(i): i = ord (i) i - = KOR_BASE return (i % ( 21 * 28 )) / / 28 def third(i): i = ord (i) i - = KOR_BASE return i % 28 def make(i, j, k): return chr (KOR_BASE + i * ( 21 * 28 ) + j * 28 + k) with open ( 'Main.aheui' , 'rt' , encoding = 'utf-8' ) as f: a = f.read() with open ( 'Main.aheui' , 'wt' , encoding = 'utf-8' ) as f: for i in a: if ord (i) > = KOR_BASE and ord (i) < KOR_BASE + 19 * 21 * 28 : if first(i) not in [ 6 , 7 , 9 , 10 ]: f.write(make(first(i), second(i), random.randrange( 28 ))) elif first(i) = = 7 : k = third(i) for x in range ( 2 , 10 ): if k in jong[x]: k = jong[x][random.randrange( len (jong[x]))] f.write(make(first(i), second(i), k)) elif first(i) = = 6 and third(i) not in [ 21 , 27 ]: k = random.randrange( 26 ) if k > = 27 : k + = 1 if k > = 21 : k + = 1 f.write(make(first(i), second(i), k)) else : f.write(i) else : if i = = 'ㅎ' : f.write( chr (random.randrange(KOR_BASE, KOR_BASE + 19 * 21 * 28 ))) else : f.write(i) |
'잡정보' 카테고리의 다른 글
VMWare side channel mitigation 성능 저하 (VMware Workstation 16 Player 기준) (7) | 2021.10.26 |
---|---|
주어진 텍스트를 출력하는 아희 코드 만들기 (0) | 2019.08.14 |
로또 확률 및 검증 (5) | 2019.05.06 |
2019 대구 국제마라톤 10km 참가자 평균 기록 (5) | 2019.04.07 |
헷갈리는 음식물 쓰레기 (0) | 2018.11.24 |