Categories
Easy Problems

โจทย์เขียนโปรแกรมข้อ VZ0097

จงเขียนฟังก์ชั่นที่รับค่า string ที่ประกอบไปด้วยตัวอักษร 1 หรือ 0 แล้วให้ส่ง array ของ string ที่ค่า true สำหรับ 1 และ false สำหรับ 0 ออกมา

Examples
integerBoolean(” 0110″) ➞ [false,true,true,false]

integerBoolean (“100101”) ➞ [true, false, false, true, false, true]

integerBoolean (“10”) ➞ [true, false]

integerBoolean (“001”) ➞ [false, false, true]

เฉลย ด้วยภาษา Python

Categories
Easy Problems

โจทย์เขียนโปรแกรมข้อ VZ0095

จงเขียนฟังก์ชั่นที่ รับค่าตัวเลขจำนวนเต็มเข้าไปสามตัว คือ a, b และ c แล้วให้ส่งค่า true ออกมา หากตัวเลขตัวสุดท้ายของแต่ละ a,b,c ทำให้ last digit of a * last digit of b = last digit of c เป็นจริง นอกเหนือจากนั้นให้ส่ง false ออกมา

Examples
lastDig(25, 21, 125) ➞ true

เฉลย ด้วยภาษา Python

Categories
Easy Problems

โจทย์เขียนโปรแกรมข้อ VZ0081

จงเขียนฟังก์ชั่นที่หา index ของ string ที่ต้องการหา ว่าอยู่ใน index ไหนใน array ของ string ที่ป้อนเข้า หากไม่เจอให้ส่ง -1 ออกมา

Examples

findIndex([“how”,”are”,”you”],”you”) 

findIndex([“red”,”blue”,”green”],”blue”)

เฉลย ด้วยภาษา Python

Categories
Easy Problems

โจทย์เขียนโปรแกรมข้อ VZ0060

จงเขียนฟังก์ชั่นเพื่อให้ค่า determinant (ad-bc)ของ matrix 2*2 โดยค่าที่ป้อนเข้าคือ a,b,c,d แทน matrix

[[a, b], [c, d]]

Examples
calcDeterminant([
[1, 2],
[3, 4]
]) ➞ -2

calcDeterminant([
[5, 3],
[3, 1]
]) ➞ -4

calcDeterminant([
[1, 1],
[1, 1]
]) ➞ 0

เฉลย ด้วยภาษา Python

Categories
Easy Problems

โจทย์เขียนโปรแกรมข้อ VZ0024

จงเขียนฟังก์ชั่นที่รับค่าจำนวนเต็มของ นาที และ วินาที ที่ฉาย video เข้าไปแล้ว ส่งค่าของจำนวน frames ทั้งหมดออกมา (1 วินาทีมี 60 frames)

Examples
frames(1, 1) ➞ 3660

frames(10, 1) ➞ 36060

frames(10, 25) ➞ 37500

เฉลย ด้วยภาษา Python