Skip to content

mohamedmohdy/problem_solving_with_dart

Repository files navigation

problem_solving_with_dart

1- palindrom_string
Ask the user for a string and print out whether this string is a palindrome or not.
A palindrome is a string that reads the same forwards and backwards.
code : https://cutt.us/IyUib
--------------------------------------------------

2-Manipulate list items.dart
Let’s say you are given a list saved in a variable:
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].
Write a Dart code that takes this list and makes a new list that has only the even elements of this list in it.
code : https://cutt.us/lXMJO
-------------------------------------------------

3- Rock, paper and scissors game
Make a two-player Rock-Paper-Scissors game against computer.
Ask for player’s input, compare them, print out a message to the winner.
code : https://cutt.us/6Wgye
-------------------------------------------------

4- Generate a random number between 1 and 100.
Ask the user to guess the number,
then tell them whether they guessed too low, too high, or exactly right.
Keep track of how many guesses the user has taken, and when the game ends, print this out.
code : https://cutt.us/5hUqo
-------------------------------------------------

5- Ask the user for a number and determine whether the number is prime or not.
code : https://cutt.us/Un2B3
-------------------------------------------------

6-Write a program that takes a list of numbers for example
a = [5, 10, 15, 20, 25]
and makes a new list of only the first and last elements of the given list
code : https://cutt.us/RpoYM
-------------------------------------------------

7-Write a program that asks the user how many Fibonnaci numbers to generate and then generates them
Make sure to ask the user to enter the number of numbers in the sequence to generate.
code : https://cutt.us/dbFFp
-------------------------------------------------

8-Write a program that takes a list
and returns a new list that contains all the elements of the first list minus all the duplicates.
code : https://cutt.us/8cntT
-------------------------------------------------

9-Write a program that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order.
For example, say I type the string:
My name is Michele
Then I would see the string:
Michele is name My
code : https://cutt.us/ad5pN
-------------------------------------------------

10-Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit the user guessed correctly in the correct place, they have a “cow”.
For every digit the user guessed correctly in the wrong place is a “bull.”
Every time the user makes a guess, tell them how many “cows” and “bulls” they have.
Once the user guesses the correct number, the game is over.
Keep track of the number of guesses the user makes throughout the game and tell the user at the end.
code : https://cutt.us/HOqqm
-------------------------------------------------

11- Given an array of integers nums and an integer target
return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Example 2 :
Input: nums = [3,3], target = 6
Output: [0,1]
code : https://cutt.us/HGQZz

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages