Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed Week2 homework #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file added week2/Nat/Nat Count/.vs/Nat Count/v17/.futdcache.v2
Binary file not shown.
Binary file added week2/Nat/Nat Count/.vs/Nat Count/v17/.suo
Binary file not shown.
37 changes: 37 additions & 0 deletions week2/Nat/Nat Count/.vs/Nat Count/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{2C68E036-5014-4668-B509-3AEBAAE3AB73}|Nat Count\\Nat Count.csproj|c:\\users\\v-abintijaaf\\my_c-_practise\\week2\\nat\\nat count\\nat count\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{2C68E036-5014-4668-B509-3AEBAAE3AB73}|Nat Count\\Nat Count.csproj|solutionrelative:nat count\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Program.cs",
"RelativeDocumentMoniker": "Nat Count\\Program.cs",
"ToolTip": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Program.cs",
"RelativeToolTip": "Nat Count\\Program.cs",
"ViewState": "AQIAABwAAAAAAAAAAAAuwDQAAAABAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-30T08:15:33.663Z",
"EditorCaption": ""
}
]
}
]
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions week2/Nat/Nat Count/Nat Count.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35201.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nat Count", "Nat Count\Nat Count.csproj", "{2C68E036-5014-4668-B509-3AEBAAE3AB73}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2C68E036-5014-4668-B509-3AEBAAE3AB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C68E036-5014-4668-B509-3AEBAAE3AB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C68E036-5014-4668-B509-3AEBAAE3AB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C68E036-5014-4668-B509-3AEBAAE3AB73}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DD4C3BD6-70F6-4CAD-9657-99A80A134D25}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions week2/Nat/Nat Count/Nat Count/Nat Count.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Nat_Count</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
53 changes: 53 additions & 0 deletions week2/Nat/Nat Count/Nat Count/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

class Program
{
static string CountAndSay(int seq)
{
if (seq == 1) return "1";

string result = "1";

for (int i = 2; i <= seq; i++)
{
string current = "";
int count = 1;
char say = result[0];

for (int j = 1; j < result.Length; j++)
{
if (result[j] == say)
{
count++;
}
else
{
current += count.ToString() + say;
count = 1;
say = result[j];
}
}

current += count.ToString() + say;
result = current;
}

return result;
}

static void Main()
{
Console.WriteLine("Hello, Count and say!");
string retry;
do
{
Console.Write("Enter sequence : ");
int seq = Convert.ToInt32(Console.ReadLine()); //enter term
Console.WriteLine($"Answer : {CountAndSay(seq)}");
Console.Write("\nRetry ? \ny-Yes n-No : "); //to retry
retry = Console.ReadLine();
Console.WriteLine("");
}
while (retry == "y");

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that we should remove extra line in code.

}
}
23 changes: 23 additions & 0 deletions week2/Nat/Nat Count/Nat Count/bin/Debug/net8.0/Nat Count.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Nat Count/1.0.0": {
"runtime": {
"Nat Count.dll": {}
}
}
}
},
"libraries": {
"Nat Count/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Nat Count")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0e9110531d43c7b50e003cc91b13024e695c040")]
[assembly: System.Reflection.AssemblyProductAttribute("Nat Count")]
[assembly: System.Reflection.AssemblyTitleAttribute("Nat Count")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fbb6b23574f8f1e468d5ee4eb1e819908efe97c0b75dff2bc93c70a9b1b1acd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Nat_Count
build_property.ProjectDir = C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
75949c19b051ec9811c76fa234f5595fe3029cbaf500eaf4dfabf1e4ef2c8fbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\bin\Debug\net8.0\Nat Count.exe
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\bin\Debug\net8.0\Nat Count.deps.json
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\bin\Debug\net8.0\Nat Count.runtimeconfig.json
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\bin\Debug\net8.0\Nat Count.dll
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\bin\Debug\net8.0\Nat Count.pdb
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.AssemblyInfoInputs.cache
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.AssemblyInfo.cs
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.csproj.CoreCompileInputs.cache
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.sourcelink.json
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.dll
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\refint\Nat Count.dll
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.pdb
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\Nat Count.genruntimeconfig.cache
C:\Users\v-abintijaaf\MY_C-_Practise\week2\Nat\Nat Count\Nat Count\obj\Debug\net8.0\ref\Nat Count.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4174992181f1df0ba83332151c0df386f5234e1b54cb919341910a91ed850e8e
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\Users\\v-abintijaaf\\MY_C-_Practise\\*":"https://raw.githubusercontent.com/AinatulJaafar/MY_C-_Practise/c0e9110531d43c7b50e003cc91b13024e695c040/*"}}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Nat Count.csproj": {}
},
"projects": {
"C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Nat Count.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Nat Count.csproj",
"projectName": "Nat Count",
"projectPath": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\Nat Count.csproj",
"packagesPath": "C:\\Users\\v-abintijaaf\\.nuget\\packages\\",
"outputPath": "C:\\Users\\v-abintijaaf\\MY_C-_Practise\\week2\\Nat\\Nat Count\\Nat Count\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\v-abintijaaf\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.304/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
16 changes: 16 additions & 0 deletions week2/Nat/Nat Count/Nat Count/obj/Nat Count.csproj.nuget.g.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\v-abintijaaf\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.10.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\v-abintijaaf\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
Loading