Categories
Medium Problems

โจทย์ข้อที่ MX0046

จงเขียนโปรแกรมที่รับค่า string และตัวเลขจำนวนเต็มเข้าไป แล้วส่ง string ออกมาโดยประกอบไปด้วยตัวอักษรแต่ละตัวที่มีจำนวนเท่ากับตัวเลขที่ส่งเข้าไป

Examples

repeat(” mice”,5) ➞ “mmmmmiiiiiccccceeeee”

repeat(“hello”,3) ➞ “hhheeellllllooo”

repeat(“stop”,1) ➞ “stop”



Categories
Medium Problems

โจทย์ข้อที่ MX0045

จงเขียนฟังก์ชั่นที่รับค่า ค่าเฉลี่ยคนหายป่วยต่อวัน, ค่าเฉลี่ยคนป่วยใหม่ต่อวัน และ จำนวนรวมคนที่กำลังป่วยอยู่ ของโควิท 19 แล้วให้ส่งจำนวนวันที่จะเป็นถึงจุดที่คนป่วยอยู่เป็น 0

Examples

endCorona(4000, 2000, 77000) ➞ 39

endCorona(3000, 2000, 50699) ➞ 51

endCorona(30000, 25000, 390205) ➞ 79

Categories
Medium Problems

โจทย์ข้อที่ MX0044

จงเขียนฟังก์ชั่นที่รับค่าวันแบบ GregorianCalendar เข้าไป แล้วส่งค่า true ออกมาหากวันนั้นตรงกับ Christmas Eve (24 ธันวาคม) นอกเหนือจากนั้นให้ส่งค่า false ออกมา

Examples

GregorianCalendar(2013, 11, 24) ➞ true

GregorianCalendar(2013, 0, 23) ➞ false

GregorianCalendar(3000, 11, 24) ➞ true

Categories
Medium Problems

โจทย์ข้อที่ MX0043

จงเขียนฟังก์ชั่นที่ รับค่า array ของ object เข้าไป ซึ่งสมาชิกแต่ละตัวประกอบไปด้วย name , age และ bugget ให้ส่งค่าผลรวมของbudget จากข้อมูลที่ป้อนเข้าไป

Examples

getBudgets([ { name: ” john”,=”” age:=”” 21,=”” budget:=”” 23000=”” },=”” {=”” name:=”” “steve”,=”” 32,=”” 40000=”” “martin”,=”” 16,=”” 2700=”” }=”” ]) ➞ 65700

Categories
Medium Problems

โจทย์ข้อที่ MX0042

จงเขียนฟังก์ชั่นที่รับ string เข้าไป 3 ค่าคือ first, last และ word แล้วให้ส่งค่า true ออกมาหาก word นั้นอยู่ระหว่าง first และ last ใน dictionary นอกนั้นเป็น false

Examples

isBetween(” apple”,”banana”,”azure”) ➞ true

isBetween (“monk”,”monument”,”monkey”) ➞ true

isBetween (“bookend”,”boolean”,”boost”) ➞ false