Skip to content

Commit 7c05aab

Browse files
committed
golang problem solve
1 parent 89fc5f8 commit 7c05aab

16 files changed

+311
-1
lines changed

Uri-online-judge/1018/1018.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ package main
22

33
import "fmt"
44

5-
func main(){
5+
func currencyCounter(amount int64) {
6+
notes := [7]int64{100, 50, 20, 10, 5, 2, 1}
7+
noteCounter := [7]int64{0, 0, 0, 0, 0, 0, 0}
8+
for i := 0; i < 7; i++ {
9+
if amount >= notes[i] {
10+
noteCounter[i] = amount / notes[i]
11+
amount = amount - noteCounter[i]*notes[i]
12+
}
13+
}
14+
for i := 0; i < 7; i++ {
15+
fmt.Printf("%d nota(s) de R$ %d,00\n", noteCounter[i], notes[i])
16+
}
17+
}
18+
19+
func main() {
620
var x int64
721
fmt.Scan(&x)
22+
fmt.Printf("%d\n",x)
23+
currencyCounter(x)
824
}

Uri-online-judge/1019/1019.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
var x int64
7+
fmt.Scan(&x)
8+
if x < 3600{
9+
min := x/60
10+
sec := x%60
11+
fmt.Printf("0:%d:%d\n",min, sec)
12+
}else{
13+
hour := x/3600
14+
min := (x%3600)/60
15+
sec := (x%3600)%60
16+
fmt.Printf("%d:%d:%d\n",hour, min, sec)
17+
}
18+
}
19+
20+
//556
21+
//
22+
//0:9:16

Uri-online-judge/1020/1020.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main(){
6+
var x int64
7+
fmt.Scan(&x)
8+
year := x/365
9+
month := (x%365)/30
10+
days := (x%365)%30
11+
fmt.Printf("%d ano(s)\n",year)
12+
fmt.Printf("%d mes(es)\n",month)
13+
fmt.Printf("%d dia(s)\n", days)
14+
}

democonsole/Program.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace democonsole
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Console.WriteLine("Hello World!");
10+
}
11+
}
12+
}

democonsole/democonsole.csproj

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj": {}
5+
},
6+
"projects": {
7+
"/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj",
11+
"projectName": "democonsole",
12+
"projectPath": "/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj",
13+
"packagesPath": "/Users/nayon/.nuget/packages/",
14+
"outputPath": "/Users/nayon/Desktop/project/problem-solving/democonsole/obj/",
15+
"projectStyle": "PackageReference",
16+
"configFilePaths": [
17+
"/Users/nayon/.nuget/NuGet/NuGet.Config"
18+
],
19+
"originalTargetFrameworks": [
20+
"netcoreapp3.1"
21+
],
22+
"sources": {
23+
"https://api.nuget.org/v3/index.json": {}
24+
},
25+
"frameworks": {
26+
"netcoreapp3.1": {
27+
"projectReferences": {}
28+
}
29+
},
30+
"warningProperties": {
31+
"warnAsError": [
32+
"NU1605"
33+
]
34+
}
35+
},
36+
"frameworks": {
37+
"netcoreapp3.1": {
38+
"imports": [
39+
"net461",
40+
"net462",
41+
"net47",
42+
"net471",
43+
"net472",
44+
"net48"
45+
],
46+
"assetTargetFallback": true,
47+
"warn": true,
48+
"frameworkReferences": {
49+
"Microsoft.NETCore.App": {
50+
"privateAssets": "all"
51+
}
52+
},
53+
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.301/RuntimeIdentifierGraph.json"
54+
}
55+
}
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/nayon/.nuget/packages/</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/nayon/.nuget/packages/</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<PropertyGroup>
13+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
14+
</PropertyGroup>
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
</Project>

democonsole/obj/project.assets.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version": 3,
3+
"targets": {
4+
".NETCoreApp,Version=v3.1": {}
5+
},
6+
"libraries": {},
7+
"projectFileDependencyGroups": {
8+
".NETCoreApp,Version=v3.1": []
9+
},
10+
"packageFolders": {
11+
"/Users/nayon/.nuget/packages/": {}
12+
},
13+
"project": {
14+
"version": "1.0.0",
15+
"restore": {
16+
"projectUniqueName": "/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj",
17+
"projectName": "democonsole",
18+
"projectPath": "/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj",
19+
"packagesPath": "/Users/nayon/.nuget/packages/",
20+
"outputPath": "/Users/nayon/Desktop/project/problem-solving/democonsole/obj/",
21+
"projectStyle": "PackageReference",
22+
"configFilePaths": [
23+
"/Users/nayon/.nuget/NuGet/NuGet.Config"
24+
],
25+
"originalTargetFrameworks": [
26+
"netcoreapp3.1"
27+
],
28+
"sources": {
29+
"https://api.nuget.org/v3/index.json": {}
30+
},
31+
"frameworks": {
32+
"netcoreapp3.1": {
33+
"projectReferences": {}
34+
}
35+
},
36+
"warningProperties": {
37+
"warnAsError": [
38+
"NU1605"
39+
]
40+
}
41+
},
42+
"frameworks": {
43+
"netcoreapp3.1": {
44+
"imports": [
45+
"net461",
46+
"net462",
47+
"net47",
48+
"net471",
49+
"net472",
50+
"net48"
51+
],
52+
"assetTargetFallback": true,
53+
"warn": true,
54+
"frameworkReferences": {
55+
"Microsoft.NETCore.App": {
56+
"privateAssets": "all"
57+
}
58+
},
59+
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.301/RuntimeIdentifierGraph.json"
60+
}
61+
}
62+
}
63+
}

democonsole/obj/project.nuget.cache

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": 2,
3+
"dgSpecHash": "mwW7gIoxLZRJxZxDgsA0CWv8Iviw/e5zRwPwoS+BvTyBU1aImZZIPeumBIA+ZTT9pcxitbYJaj3XtBNOIcYGdQ==",
4+
"success": true,
5+
"projectFilePath": "/Users/nayon/Desktop/project/problem-solving/democonsole/democonsole.csproj",
6+
"expectedPackageFiles": [],
7+
"logs": []
8+
}

geeksforgeeks/greedy/BankNotes.class

1.11 KB
Binary file not shown.

geeksforgeeks/greedy/BankNotes.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
public class BankNotes{
3+
public static void countCurrency(int amount){
4+
int[] notes = new int[]{2000, 500, 200, 100, 50, 20, 10, 5, 1 };
5+
int[] noteCounter = new int[9];
6+
for(int i =0; i<9; i++){
7+
if (amount >= notes[i]){
8+
noteCounter[i] = amount / notes[i];
9+
amount = amount - noteCounter[i]*notes[i];
10+
}
11+
}
12+
13+
// print notes
14+
for(int i = 0; i < 9; i++){
15+
Console.WriteLine(notes[i] + " : " + noteCounter[i] );
16+
}
17+
}
18+
public static void Main()
19+
{
20+
int amount = 868;
21+
countCurrency(amount);
22+
}
23+
}

geeksforgeeks/greedy/BankNotes.java

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
4+
public class BankNotes{
5+
public static void countCurrency(int amount){
6+
int[] notes = new int[]{2000,500,200,100,50,20,10,5,1};
7+
int[] noteCounter = new int[9];
8+
for(int i = 0; i < 9; i++){
9+
if(amount >= notes[i]){
10+
noteCounter[i] = amount / notes[i];
11+
amount = amount - noteCounter[i] * notes[i];
12+
}
13+
}
14+
for(int i = 0; i < 9; i++){
15+
System.out.println(notes[i] + " : "+noteCounter[i]);
16+
}
17+
}
18+
public static void main(String argc[]){
19+
int amount = 868;
20+
countCurrency(amount);
21+
}
22+
}

geeksforgeeks/greedy/banknotes

22.9 KB
Binary file not shown.

geeksforgeeks/greedy/banknotes.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
void currencyCurrecny(int amount)
5+
{
6+
int notes[9] = {2000,500,200,100,50,20,10,5,1};
7+
int notesCounter[9] = {0};
8+
9+
// count notes using Greedy approch
10+
for(int i = 0; i < 9;i++){
11+
if (amount >= notes[i]) {
12+
notesCounter[i] = amount / notes[i];
13+
amount = amount - notesCounter[i] * notes[i];
14+
}
15+
}
16+
// print notes
17+
for(int i = 0; i < 9; i++)
18+
{
19+
cout << notes[i] << " : " << notesCounter[i] << endl;
20+
}
21+
}
22+
23+
int main()
24+
{
25+
int amount = 868;
26+
currencyCurrecny(amount);
27+
return 0;
28+
}

geeksforgeeks/greedy/banknotes.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def countCurrency(amount):
2+
notes = [2000,500,200,100,50,20,10,5,1]
3+
notesCounter = [0,0,0,0,0,0,0,0,0]
4+
5+
for i in range(len(notes)):
6+
if amount >= notes[i]:
7+
notesCounter[i] = amount // notes[i]
8+
amount = amount - notesCounter[i] * notes[i]
9+
10+
for i in range(len(notes)):
11+
print(notes[i],notesCounter[i])
12+
13+
14+
amount = 868
15+
countCurrency(amount)

0 commit comments

Comments
 (0)