Webã¢ããªã±ã¼ã·ã§ã³ã®ããã°ã©ã ãJavaã§æ¸ãã¦ããã§ãããã¡ãã£ã¨ç²ãã¦ããã®ã§ãããªã¨ã³ããªã¼
ä¸ã®ä¸ä¾¿å©ã«ãªã£ããã®ã§ããããããªããã°ã©ã ã®å¦ç¿è¨äºã溢ãã¦ã¾ãã
ããå¦ã³å§ãã¯ã©ããã¦ããããããªããã§ãã
- 足ãç®ã®ããããå¦ã³ã¾ããã
- ã«ã¼ããã¦ã¿ã¾ããã
- åå²ãã¦ã¿ã¾ããã
- ã¨ãã¨ãã»ã»ã»
ã¨ããã®ãç¶ãã¦ãåã¯ããã°ã©ã ã®ææ³ãå¦ã³ããããããªãã¦ãåããã¨ãã§ããéæ³ã®ãã¼ã«ã®ä½¿ãæ¹ãå¦ã³ãããã ãã©ã»ã»ã»ãã¨æ°ãæ» å ¥ã£ã¦ã¨æãã¾ãï¼æ°å¦ã¿ããã§æ¥½ããï¼ã¨æããããªãã¯ãæ£è§£ã¨ãããããã°ã©ã ã楽ããç´ è³ªãããã®ã§ãã®ã¾ã¾æ¥½ãã¿ã¾ãããï¼ï¼ã
ã³ã³ã½ã¼ã«ç»é¢ã«è¡¨ç¤ºããããã°ã©ã ã§ã©ããªãã¨ãã§ããï¼
ããã°ã©ã ãå¦ã³å§ãã¦æåã¯ãããããã³ã³ã½ã¼ã«ç»é¢ï¼windowsãªãDOSããã³ãããMacãªãã¿ã¼ããã«ï¼ã«ä½ãã表示ããããã°ã©ã ãæ¸ãã¦ãããã¨ã§ãããã
å®ç¨çã¨ãããã使ããããã°ã©ã ãã¨è¨ãããã¨ã»ã»ã»ã»ãã£ã¨ã¡ãã£ã¨å¾®å¦ã§ãã
ã§ãããã§åãå ã»ã©æ¯æãã«æãããã³ã³ã½ã¼ã«ã«è¡¨ç¤ºããããã°ã©ã ããè¦ã¦ã¿ã¾ãããã
import numpy.random as rd # http://trendy.nikkeibp.co.jp/article/pickup/20140904/1059848/?SS=expand-life&FD=993747041 # ããæç²ãã2014年度ã®ãã©ã¸ã£ã¼ã«ããåå¸ oppai_ratio = { "A": 0.056, "B": 0.208, "C": 0.265, "D": 0.242, "E": 0.160, "F": 0.056, "Over H": 0.013 } def oppai(): return list(oppai_ratio.keys())[rd.choice(len(oppai_ratio), p=list(oppai_ratio.values()))] print(oppai())
ä½ãã¨è¨ãã¾ãã¨ããã©ã¸ã£ã¼ã®ã«ãããµã¤ãºã®åå¸ã«ãããã£ã¦ãã«ãããµã¤ãºãè¿ãã¦ãããããã°ã©ã ã§ãï¼
試ãã«å®è¡ãã¦ã¿ã¾ããã
Dã«ããã¨è¿ã£ã¦æ¥ã¾ããï¼è¡ã§å¥³æ§ã¨åºä¼ã£ãã¨ãããDã«ããã ã£ãã¿ãããªãã®ã§ããã
ããã§ã
print(oppai())
ã
for x in range(15): print(oppai())
ã¨ã§ããã¦ã¿ã¾ãããï¼ï¼ï¼å表示ãç¹°ãè¿ããï¼ã
ããã¨çµæã¯ã»ã»ã»ã»
15人ã®å¥³æ§ã¨åºä¼ã£ãã¨ããã¨ãAã«ããã¨Eã«ããã¯ãã©ãã©ã¨ãç®ã«ããããæãã§ãããFãOver Hã¯åºã¦ãã¾ãããå¸å°ä¾¡å¤ã¨ããã°å°ããã¤ã¡ã¼ã¸ã§ãããããã¯ã大ããæ¹ãç¨å°ã ã£ãããã»ã»ã»
ä½ãè¨ããããã¨ããã¨
å²ã¨ã³ã³ã½ã¼ã«ã§è¡¨ç¤ºããããã°ã©ã ã§ãã楽ããããã®ãå®ç¨çãªãã®ã¨ããã®ã¯ä½ããã¨æãã°ä½ãã¡ããã¾ãã
å ã»ã©ã®ãå¿ç¨ããã°ãç°¡åã«ã½ã·ã£ã²ã®ã¬ãã£ã·ãã¥ã¬ã¼ã¿ã¼ãä½ãã¡ããã¾ãããã
ã¡ãªã¿ã«åãå§ãã¦ä½ã£ãå®ç¨çãªããã°ã©ã ã¯ããã¹ã¯ã¼ã解æãã¼ã«ã§ãããa-zãç¹°ãè¿ãã¦æ¡æ°å¢ããã¦ãããã¹ã¯ã¼ã解é¤ã試è¡ã¨ãã£ãæãã§ï¼å¿µã®ããã§ããããããä¸ã®ä½ãã«å¯¾ãã¦ã¯ããã¾ãããããä¸æ£ã¢ã¯ã»ã¹ãªãã¨ãæ³ã§ææªæã¾ãã¾ãï¼
ã¨ãããã¨ã§ãåå¼·ããªããã§ãããä»ã®ç¥èã§ã©ããªãã®ãä½ããããªã¼ãã¨å¦æ³ããªããåå¼·ããã¦ãã£ã¦ããããã°ã¨æãã¾ãããè¯ãã®ãæãã¤ãããå®éã«ä½ã£ã¦ã¿ã¦ããããããªã¼ã¨æã次第ã§ããã¾ã